/* Appellation: params Contrib: FL03 */ extern crate concision_core as concision; extern crate concision_data as data; use concision::linarr; use data::params::{ParamKind, Parameter}; use ndarray::linalg::Dot; use ndarray::prelude::*; #[test] fn test_parameter() { let a = linarr::((3,)).unwrap(); let p = linarr::((3, 3)).unwrap(); let mut param = Parameter::::new((10, 1), ParamKind::Bias, "bias"); param.set_params(p.clone()); assert_eq!(param.kind(), &ParamKind::Bias); assert_eq!(param.name(), "bias"); assert_eq!(param.dot(&a), p.dot(&a)); } #[test] fn test_param_kind_map() { let name = "test"; let other = ParamKind::other(name); let data = [ (ParamKind::Bias, "bias"), (ParamKind::Weight, "weight"), (other.clone(), "test"), (ParamKind::other("mask"), "mask"), ]; for (kind, expected) in &data { assert_eq!(kind.to_string(), expected.to_string()); } }