Skip to content

Commit

Permalink
fix test types
Browse files Browse the repository at this point in the history
  • Loading branch information
tph5595 committed Jan 29, 2025
1 parent 7b95af6 commit d08760e
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,26 @@ fn main() -> Result<(), Box<dyn Error>> {

#[cfg(test)]
mod tests {
fn test_runner(k: usize, bd_pairs_vec: Vec<(f32, f32)>, answer_vec: Vec<Vec<(f32, f32)>>) {
fn test_runner(k: usize, bd_pairs_vec: Vec<(f32, f32)>, answer_vec: &[Vec<(f32, f32)>]) {
let bd_pairs = bd_pairs_vec
.into_iter()
.map(|(x, y)| fast_pl::birthdeath::BirthDeath { birth: x, death: y })
.collect();
let answer: Vec<Vec<fast_pl::persistencelandscape::PointOrd>> = answer_vec
.into_iter()
.map(|x| {
x.into_iter()
.map(|(x, y)| fast_pl::persistencelandscape::PointOrd {
x: float_ord::FloatOrd(x),
y: float_ord::FloatOrd(y),
})
.collect()
})
.collect();
// let answer: Vec<Vec<(f32,f32)>> = answer_vec
// .into_iter()
// .map(|x| {
// x.into_iter()
// .map(|(x, y)| fast_pl::persistencelandscape::PointOrd {
// x: float_ord::FloatOrd(x),
// y: float_ord::FloatOrd(y),
// })
// .collect()
// })
// .collect();

let filtered_pairs = fast_pl::barcode::filter(bd_pairs, k);
let landscape = fast_pl::persistencelandscape::generate(filtered_pairs, k, false);
assert!(answer == landscape);
assert!(answer_vec == landscape);
}

#[test]
Expand All @@ -111,7 +111,7 @@ mod tests {
vec![(2.0, 0.0), (2.5, 0.5), (3.0, 0.0)],
vec![],
];
test_runner(k, bd_pairs_vec, answer_vec);
test_runner(k, bd_pairs_vec, &answer_vec);
}
#[test]
fn head_to_tail() {
Expand All @@ -128,6 +128,6 @@ mod tests {
],
vec![],
];
test_runner(k, bd_pairs_vec, answer_vec);
test_runner(k, bd_pairs_vec, &answer_vec);
}
}

0 comments on commit d08760e

Please sign in to comment.