diff --git a/Cargo.toml b/Cargo.toml index 2444171091def3d587c74c8128a37d42d5010236..c71be9acccc4955add6e9b15466925e2b8eba114 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ strip-ansi-escapes = "0.2.0" tch = { git = "https://github.com/LaurentMazare/tch-rs", rev = "d068b18", version = "0.15.0" } toml = "0.8.10" unicode-width = "0.1.11" +float_eq = { version = "1.0.1", features = ["derive"] } [dev-dependencies] -float_eq = { version = "1.0.1", features = ["derive"] } itertools = "0.12.1" diff --git a/src/bin/aphid/main.rs b/src/bin/aphid/main.rs index 5d6dddfcc1d7618f468fc711ec3ccec2b8d1dc73..0416b47af70c0c2676b85fb11c8b559f25732eba 100644 --- a/src/bin/aphid/main.rs +++ b/src/bin/aphid/main.rs @@ -18,6 +18,7 @@ use lexical_sort::natural_lexical_cmp; mod display_tree_analysis; mod justify; use display_tree_analysis::display_topological_tree_analysis; +use float_eq::float_eq; use justify::{justify, terminal_width}; use crate::display_tree_analysis::display_geometrical_tree_analysis; @@ -495,6 +496,18 @@ fn run() -> Result<(), AphidError> { display_tree_lnl_detail(&opt, opt_lnl); eprintln!("\nEnding point: {opt:#?}\n"); + + // Smoke test: + // TODO: turn into actual testing by including 'official' example data. + let r = ln_likelihood(&triplets, &opt); + let t = opt_lnl; + assert!( + float_eq!(t, r, abs <= 1e-6), + "Discrepancy between regular and tensor likelihood calculations?\n\ + regular: {r}\n\ + tensors: {t}\n" + ); + Ok(()) }