Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MRG: fix clippy warnings about max_value #3146

Merged
merged 2 commits into from
May 7, 2024
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 src/core/src/index/linear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ impl LinearIndex {
threshold: usize,
query: &KmerMinHash,
) -> std::result::Result<Vec<GatherResult>, Box<dyn std::error::Error>> {
let mut match_size = usize::max_value();
let mut match_size = usize::MAX;
let mut matches = vec![];
let template = self.template();

Expand Down
2 changes: 1 addition & 1 deletion src/core/src/sketch/hyperloglog/estimators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub fn counts(registers: &[CounterType], q: usize) -> Vec<u16> {
pub fn mle(counts: &[u16], p: usize, q: usize, relerr: f64) -> f64 {
let m = 1 << p;
if counts[q + 1] == m {
return std::f64::INFINITY;
return f64::INFINITY;
}

let (k_min, _) = counts.iter().enumerate().find(|(_, v)| **v != 0).unwrap();
Expand Down
14 changes: 7 additions & 7 deletions src/core/src/sketch/minhash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ use crate::Error;
pub fn max_hash_for_scaled(scaled: u64) -> u64 {
match scaled {
0 => 0,
1 => u64::max_value(),
_ => (u64::max_value() as f64 / scaled as f64) as u64,
1 => u64::MAX,
_ => (u64::MAX as f64 / scaled as f64) as u64,
}
}

pub fn scaled_for_max_hash(max_hash: u64) -> u64 {
match max_hash {
0 => 0,
_ => (u64::max_value() as f64 / max_hash as f64) as u64,
_ => (u64::MAX as f64 / max_hash as f64) as u64,
}
}

Expand All @@ -48,7 +48,7 @@ pub struct KmerMinHash {
#[builder(default = 42u64)]
seed: u64,

#[builder(default = u64::max_value())]
#[builder(default = u64::MAX)]
max_hash: u64,

#[builder(default)]
Expand Down Expand Up @@ -313,7 +313,7 @@ impl KmerMinHash {
pub fn add_hash_with_abundance(&mut self, hash: u64, abundance: u64) {
let current_max = match self.mins.last() {
Some(&x) => x,
None => u64::max_value(),
None => u64::MAX,
};

if hash > self.max_hash && self.max_hash != 0 {
Expand Down Expand Up @@ -960,7 +960,7 @@ pub struct KmerMinHashBTree {
#[builder(default = 42u64)]
seed: u64,

#[builder(default = u64::max_value())]
#[builder(default = u64::MAX)]
max_hash: u64,

#[builder(default)]
Expand Down Expand Up @@ -1309,7 +1309,7 @@ impl KmerMinHashBTree {
let union = self.mins.union(&other.mins);

let to_take = if self.num == 0 {
usize::max_value()
usize::MAX
} else {
self.num as usize
};
Expand Down
Loading