Skip to content

Commit

Permalink
test: panic test for invalid pdf argument
Browse files Browse the repository at this point in the history
  • Loading branch information
henryjac committed Dec 26, 2022
1 parent 280fa7e commit 9433a39
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/distribution/multivariate_normal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,4 +373,11 @@ mod tests {
test_case(vec![0., 0.], vec![f64::INFINITY, 0., 0., f64::INFINITY], f64::NEG_INFINITY, ln_pdf(dvec![10., 10.]));
test_case(vec![0., 0.], vec![f64::INFINITY, 0., 0., f64::INFINITY], f64::NEG_INFINITY, ln_pdf(dvec![100., 100.]));
}

#[test]
#[should_panic]
fn test_pdf_mismatched_arg_size() {
let mvn = MultivariateNormal::new(vec![0., 0.], vec![1., 0., 0., 1.,]).unwrap();
mvn.pdf(&dvec![1.]); // x.size != mu.size
}
}
7 changes: 7 additions & 0 deletions src/distribution/multivariate_students_t.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,4 +449,11 @@ mod tests {
test_almost_multivariate_normal(vec![0., 0.,], vec![1., 0., 0., 1.], 1e10, 1e-5, dvec![1., 1.], pdf_mvs, pdf_mvn);
test_almost_multivariate_normal(vec![0., 0.,], vec![1., 0., 0., 1.], f64::INFINITY, 1e-50, dvec![1., 1.], pdf_mvs, pdf_mvn);
}

#[test]
#[should_panic]
fn test_pdf_mismatched_arg_size() {
let mvs = MultivariateStudent::new(vec![0., 0.], vec![1., 0., 0., 1.,], 3.).unwrap();
mvs.pdf(&dvec![1.]); // x.size != mu.size
}
}

0 comments on commit 9433a39

Please sign in to comment.