diff --git a/src/util.rs b/src/util.rs index c849996..51426e0 100644 --- a/src/util.rs +++ b/src/util.rs @@ -22,7 +22,6 @@ where mod tests { use super::distance_to_space; use crate::distance::squared_euclidean; - use std::f64::{INFINITY, NEG_INFINITY}; #[test] fn test_normal_distance_to_space() { @@ -32,7 +31,12 @@ mod tests { #[test] fn test_distance_outside_inf() { - let dis = distance_to_space(&[0.0, 0.0], &[1.0, 1.0], &[INFINITY, INFINITY], &squared_euclidean); + let dis = distance_to_space( + &[0.0, 0.0], + &[1.0, 1.0], + &[f64::INFINITY, f64::INFINITY], + &squared_euclidean, + ); assert_eq!(dis, 2.0); } @@ -40,8 +44,8 @@ mod tests { fn test_distance_inside_inf() { let dis = distance_to_space( &[2.0, 2.0], - &[NEG_INFINITY, NEG_INFINITY], - &[INFINITY, INFINITY], + &[f64::NEG_INFINITY, f64::NEG_INFINITY], + &[f64::INFINITY, f64::INFINITY], &squared_euclidean, ); assert_eq!(dis, 0.0); @@ -57,8 +61,8 @@ mod tests { fn distance_to_half_space() { let dis = distance_to_space( &[-2.0, 0.0], - &[0.0, NEG_INFINITY], - &[INFINITY, INFINITY], + &[0.0, f64::NEG_INFINITY], + &[f64::INFINITY, f64::INFINITY], &squared_euclidean, ); assert_eq!(dis, 4.0); diff --git a/tests/kdtree.rs b/tests/kdtree.rs index ee1f23b..666993e 100644 --- a/tests/kdtree.rs +++ b/tests/kdtree.rs @@ -61,7 +61,7 @@ fn it_works() { ); let unsorted1 = kdtree.within_unsorted(&POINT_A.0, 0.0, &squared_euclidean).unwrap(); - let ans1 = vec![(0.0, &0)]; + let ans1 = [(0.0, &0)]; assert_eq!(unsorted1.len(), ans1.len()); assert_eq!( kdtree.within_count(&POINT_A.0, 0.0, &squared_euclidean).unwrap(), @@ -72,7 +72,7 @@ fn it_works() { } let unsorted2 = kdtree.within_unsorted(&POINT_B.0, 1.0, &squared_euclidean).unwrap(); - let ans2 = vec![(0.0, &1)]; + let ans2 = [(0.0, &1)]; assert_eq!(unsorted2.len(), ans2.len()); assert_eq!( kdtree.within_count(&POINT_B.0, 1.0, &squared_euclidean).unwrap(), @@ -83,7 +83,7 @@ fn it_works() { } let unsorted3 = kdtree.within_unsorted(&POINT_B.0, 2.0, &squared_euclidean).unwrap(); - let ans3 = vec![(0.0, &1), (2.0, &2), (2.0, &0)]; + let ans3 = [(0.0, &1), (2.0, &2), (2.0, &0)]; assert_eq!(unsorted3.len(), ans3.len()); assert_eq!( kdtree.within_count(&POINT_B.0, 2.0, &squared_euclidean).unwrap(), @@ -178,8 +178,8 @@ fn handles_wrong_dimension() { #[test] fn handles_non_finite_coordinate() { - let point_a = ([std::f64::NAN, std::f64::NAN], 0f64); - let point_b = ([std::f64::INFINITY, std::f64::INFINITY], 0f64); + let point_a = ([f64::NAN, f64::NAN], 0f64); + let point_b = ([f64::INFINITY, f64::INFINITY], 0f64); let mut kdtree = KdTree::with_capacity(2, 1); assert_eq!(kdtree.add(&point_a.0, point_a.1), Err(ErrorKind::NonFiniteCoordinate));