Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: 1.81 # 1.82 seems to break wasm32 tests https://github.com/rustwasm/wasm-bindgen/issues/4274
target: ${{ matrix.platform.target }}
profile: minimal
default: true
Expand Down
8 changes: 4 additions & 4 deletions src/algorithm/neighbour/cover_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl<T: Debug + PartialEq, D: Distance<T>> CoverTree<T, D> {
current_cover_set.push((d, &self.root));

let mut heap = HeapSelection::with_capacity(k);
heap.add(std::f64::MAX);
heap.add(f64::MAX);

let mut empty_heap = true;
if !self.identical_excluded || self.get_data_value(self.root.idx) != p {
Expand All @@ -145,7 +145,7 @@ impl<T: Debug + PartialEq, D: Distance<T>> CoverTree<T, D> {
}

let upper_bound = if empty_heap {
std::f64::INFINITY
f64::INFINITY
} else {
*heap.peek()
};
Expand Down Expand Up @@ -291,7 +291,7 @@ impl<T: Debug + PartialEq, D: Distance<T>> CoverTree<T, D> {
} else {
let max_dist = self.max(point_set);
let next_scale = (max_scale - 1).min(self.get_scale(max_dist));
if next_scale == std::i64::MIN {
if next_scale == i64::MIN {
let mut children: Vec<Node> = Vec::new();
let mut leaf = self.new_leaf(p);
children.push(leaf);
Expand Down Expand Up @@ -435,7 +435,7 @@ impl<T: Debug + PartialEq, D: Distance<T>> CoverTree<T, D> {

fn get_scale(&self, d: f64) -> i64 {
if d == 0f64 {
std::i64::MIN
i64::MIN
} else {
(self.inv_log_base * d.ln()).ceil() as i64
}
Expand Down
10 changes: 1 addition & 9 deletions src/algorithm/neighbour/fastpair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,8 @@ pub struct FastPair<'a, T: RealNumber + FloatNumber, M: Array2<T>> {
}

impl<'a, T: RealNumber + FloatNumber, M: Array2<T>> FastPair<'a, T, M> {
///
/// Constructor
/// Instantiate and inizialise the algorithm
///
/// Instantiate and initialize the algorithm
pub fn new(m: &'a M) -> Result<Self, Failed> {
if m.shape().0 < 3 {
return Err(Failed::because(
Expand All @@ -74,10 +72,8 @@ impl<'a, T: RealNumber + FloatNumber, M: Array2<T>> FastPair<'a, T, M> {
Ok(init)
}

///
/// Initialise `FastPair` by passing a `Array2`.
/// Build a FastPairs data-structure from a set of (new) points.
///
fn init(&mut self) {
// basic measures
let len = self.samples.shape().0;
Expand Down Expand Up @@ -158,9 +154,7 @@ impl<'a, T: RealNumber + FloatNumber, M: Array2<T>> FastPair<'a, T, M> {
self.neighbours = neighbours;
}

///
/// Find closest pair by scanning list of nearest neighbors.
///
#[allow(dead_code)]
pub fn closest_pair(&self) -> PairwiseDistance<T> {
let mut a = self.neighbours[0]; // Start with first point
Expand Down Expand Up @@ -217,9 +211,7 @@ mod tests_fastpair {
use super::*;
use crate::linalg::basic::{arrays::Array, matrix::DenseMatrix};

///
/// Brute force algorithm, used only for comparison and testing
///
pub fn closest_pair_brute(fastpair: &FastPair<f64, DenseMatrix<f64>>) -> PairwiseDistance<f64> {
use itertools::Itertools;
let m = fastpair.samples.shape().0;
Expand Down
4 changes: 2 additions & 2 deletions src/algorithm/neighbour/linear_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl<T, D: Distance<T>> LinearKNNSearch<T, D> {

for _ in 0..k {
heap.add(KNNPoint {
distance: std::f64::INFINITY,
distance: f64::INFINITY,
index: None,
});
}
Expand Down Expand Up @@ -215,7 +215,7 @@ mod tests {
};

let point_inf = KNNPoint {
distance: std::f64::INFINITY,
distance: f64::INFINITY,
index: Some(3),
};

Expand Down
4 changes: 2 additions & 2 deletions src/algorithm/sort/heap_select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ mod tests {
#[test]
fn test_add1() {
let mut heap = HeapSelection::with_capacity(3);
heap.add(std::f64::INFINITY);
heap.add(f64::INFINITY);
heap.add(-5f64);
heap.add(4f64);
heap.add(-1f64);
Expand All @@ -151,7 +151,7 @@ mod tests {
#[test]
fn test_add2() {
let mut heap = HeapSelection::with_capacity(3);
heap.add(std::f64::INFINITY);
heap.add(f64::INFINITY);
heap.add(0.0);
heap.add(8.4852);
heap.add(5.6568);
Expand Down
1 change: 1 addition & 0 deletions src/algorithm/sort/quick_sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use num_traits::Num;
pub trait QuickArgSort {
fn quick_argsort_mut(&mut self) -> Vec<usize>;

#[allow(dead_code)]
fn quick_argsort(&self) -> Vec<usize>;
}

Expand Down
8 changes: 4 additions & 4 deletions src/cluster/kmeans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl<TX: Number, TY: Number, X: Array2<TX>, Y: Array1<TY>> PartialEq for KMeans<
return false;
}
for j in 0..self.centroids[i].len() {
if (self.centroids[i][j] - other.centroids[i][j]).abs() > std::f64::EPSILON {
if (self.centroids[i][j] - other.centroids[i][j]).abs() > f64::EPSILON {
return false;
}
}
Expand Down Expand Up @@ -270,7 +270,7 @@ impl<TX: Number, TY: Number, X: Array2<TX>, Y: Array1<TY>> KMeans<TX, TY, X, Y>

let (n, d) = data.shape();

let mut distortion = std::f64::MAX;
let mut distortion = f64::MAX;
let mut y = KMeans::<TX, TY, X, Y>::kmeans_plus_plus(data, parameters.k, parameters.seed);
let mut size = vec![0; parameters.k];
let mut centroids = vec![vec![0f64; d]; parameters.k];
Expand Down Expand Up @@ -331,7 +331,7 @@ impl<TX: Number, TY: Number, X: Array2<TX>, Y: Array1<TY>> KMeans<TX, TY, X, Y>
let mut row = vec![0f64; x.shape().1];

for i in 0..n {
let mut min_dist = std::f64::MAX;
let mut min_dist = f64::MAX;
let mut best_cluster = 0;

for j in 0..self.k {
Expand Down Expand Up @@ -361,7 +361,7 @@ impl<TX: Number, TY: Number, X: Array2<TX>, Y: Array1<TY>> KMeans<TX, TY, X, Y>
.cloned()
.collect();

let mut d = vec![std::f64::MAX; n];
let mut d = vec![f64::MAX; n];
let mut row = vec![TX::zero(); data.shape().1];

for j in 1..k {
Expand Down
Loading