Coarsened checks in test_ap() again. Import complexfloat traits in config

This commit is contained in:
Anne de Jong 2024-07-10 00:23:34 +02:00
parent ed576df32d
commit d695b31426
2 changed files with 4 additions and 3 deletions

View File

@ -42,6 +42,7 @@ if #[cfg(feature = "python-bindings")] {
use ndarray::OwnedRepr; use ndarray::OwnedRepr;
use num::complex::Complex; use num::complex::Complex;
pub use num::complex::ComplexFloat;
/// View into 1D array of floats /// View into 1D array of floats
pub type VdView<'a> = ArrayView1<'a, Flt>; pub type VdView<'a> = ArrayView1<'a, Flt>;

View File

@ -451,9 +451,9 @@ mod test {
} }
#[test] #[test]
fn test_ap() { fn test_ap() {
let nfft = 256; let nfft = 1024;
let distr = Normal::new(1.0, 1.0).unwrap(); let distr = Normal::new(1.0, 1.0).unwrap();
let timedata = Dmat::random((100 * nfft, 1), distr); let timedata = Dmat::random((150 * nfft, 1), distr);
let timedata_mean_square = (&timedata * &timedata).sum() / (timedata.len() as Flt); let timedata_mean_square = (&timedata * &timedata).sum() / (timedata.len() as Flt);
for wt in [ for wt in [
@ -466,7 +466,7 @@ mod test {
let mut aps = AvPowerSpectra::build(nfft, wt, None, None).unwrap(); let mut aps = AvPowerSpectra::build(nfft, wt, None, None).unwrap();
if let ApsResult::OnlyLastResult(v) = aps.compute_last(&timedata) { if let ApsResult::OnlyLastResult(v) = aps.compute_last(&timedata) {
let ap = v.ap(0); let ap = v.ap(0);
assert_abs_diff_eq!((&ap).sum().abs(), timedata_mean_square, epsilon = 8e-3); assert_abs_diff_eq!((&ap).sum().abs(), timedata_mean_square, epsilon = 1e-2);
} else { } else {
assert!(false); assert!(false);
} }