|
|
@ -69,6 +69,14 @@ fn test_validate_params_valid_cim() { |
|
|
|
assert_eq!(Ok(()), param.validate_params()); |
|
|
|
assert_eq!(Ok(()), param.validate_params()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
|
|
|
|
fn test_validate_params_valid_cim_with_huge_values() { |
|
|
|
|
|
|
|
let mut param = utils::generate_discrete_time_continous_param(3); |
|
|
|
|
|
|
|
let cim = array![[[-2e10, 1e10, 1e10], [1.5e10, -3e10, 1.5e10], [1e10, 1e10, -2e10]]]; |
|
|
|
|
|
|
|
let result = param.set_cim(cim); |
|
|
|
|
|
|
|
assert_eq!(Ok(()), result); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
|
fn test_validate_params_cim_not_initialized() { |
|
|
|
fn test_validate_params_cim_not_initialized() { |
|
|
|
let param = utils::generate_discrete_time_continous_param(3); |
|
|
|
let param = utils::generate_discrete_time_continous_param(3); |
|
|
@ -80,7 +88,6 @@ fn test_validate_params_cim_not_initialized() { |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
|
fn test_validate_params_wrong_shape() { |
|
|
|
fn test_validate_params_wrong_shape() { |
|
|
|
let mut param = utils::generate_discrete_time_continous_param(4); |
|
|
|
let mut param = utils::generate_discrete_time_continous_param(4); |
|
|
@ -88,13 +95,12 @@ fn test_validate_params_wrong_shape() { |
|
|
|
let result = param.set_cim(cim); |
|
|
|
let result = param.set_cim(cim); |
|
|
|
assert_eq!( |
|
|
|
assert_eq!( |
|
|
|
Err(ParamsError::InvalidCIM(String::from( |
|
|
|
Err(ParamsError::InvalidCIM(String::from( |
|
|
|
"Incompatible shape [1, 3, 3] with domain 4" |
|
|
|
"Incompatible shape [1, 3, 3] with domain 4" |
|
|
|
))), |
|
|
|
))), |
|
|
|
result |
|
|
|
result |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
|
fn test_validate_params_positive_diag() { |
|
|
|
fn test_validate_params_positive_diag() { |
|
|
|
let mut param = utils::generate_discrete_time_continous_param(3); |
|
|
|
let mut param = utils::generate_discrete_time_continous_param(3); |
|
|
@ -102,13 +108,12 @@ fn test_validate_params_positive_diag() { |
|
|
|
let result = param.set_cim(cim); |
|
|
|
let result = param.set_cim(cim); |
|
|
|
assert_eq!( |
|
|
|
assert_eq!( |
|
|
|
Err(ParamsError::InvalidCIM(String::from( |
|
|
|
Err(ParamsError::InvalidCIM(String::from( |
|
|
|
"The diagonal of each cim must be non-positive", |
|
|
|
"The diagonal of each cim must be non-positive", |
|
|
|
))), |
|
|
|
))), |
|
|
|
result |
|
|
|
result |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
|
fn test_validate_params_row_not_sum_to_zero() { |
|
|
|
fn test_validate_params_row_not_sum_to_zero() { |
|
|
|
let mut param = utils::generate_discrete_time_continous_param(3); |
|
|
|
let mut param = utils::generate_discrete_time_continous_param(3); |
|
|
@ -117,7 +122,7 @@ fn test_validate_params_row_not_sum_to_zero() { |
|
|
|
assert_eq!( |
|
|
|
assert_eq!( |
|
|
|
Err(ParamsError::InvalidCIM(String::from( |
|
|
|
Err(ParamsError::InvalidCIM(String::from( |
|
|
|
"The sum of each row must be 0" |
|
|
|
"The sum of each row must be 0" |
|
|
|
))), |
|
|
|
))), |
|
|
|
result |
|
|
|
result |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|