Skip to content

Commit

Permalink
adjust references & use clone too much
Browse files Browse the repository at this point in the history
  • Loading branch information
ctb committed Oct 6, 2024
1 parent d9eeafd commit 4ab87e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/core/src/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ impl Select for Signature {
// TODO: also account for LargeMinHash
if let Sketch::MinHash(mh) = sketch {
if (mh.scaled() as u32) < sel_scaled {
*sketch = Sketch::MinHash(mh.downsample_scaled(sel_scaled as u64)?);
*sketch = Sketch::MinHash(mh.clone().downsample_scaled(sel_scaled as u64)?);
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/core/src/sketch/minhash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ impl KmerMinHash {
} else {
(other, self)
};
let downsampled_mh = second.downsample_max_hash(first.max_hash)?;
let downsampled_mh = second.clone().downsample_max_hash(first.max_hash)?;
first.count_common(&downsampled_mh, false)
} else {
self.check_compatible(other)?;
Expand Down Expand Up @@ -691,7 +691,7 @@ impl KmerMinHash {
} else {
(other, self)
};
let downsampled_mh = second.downsample_max_hash(first.max_hash)?;
let downsampled_mh = second.clone().downsample_max_hash(first.max_hash)?;
first.similarity(&downsampled_mh, ignore_abundance, false)
} else if ignore_abundance || self.abunds.is_none() || other.abunds.is_none() {
self.jaccard(other)
Expand Down Expand Up @@ -721,7 +721,7 @@ impl KmerMinHash {
}

// create a downsampled copy of self
pub fn downsample_max_hash(&self, max_hash: u64) -> Result<KmerMinHash, Error> {
pub fn downsample_max_hash(self, max_hash: u64) -> Result<KmerMinHash, Error> {
let scaled = scaled_for_max_hash(max_hash);
self.downsample_scaled(scaled)
}
Expand Down Expand Up @@ -768,7 +768,7 @@ impl KmerMinHash {
}

// create a downsampled copy of self
pub fn downsample_scaled(&self, scaled: u64) -> Result<KmerMinHash, Error> {
pub fn downsample_scaled(self, scaled: u64) -> Result<KmerMinHash, Error> {
// @CTB shouldn't we check that new scaled > old scaled?
if self.scaled() == scaled {
Ok(self.clone()) // avoid clone CTB
Expand Down Expand Up @@ -1365,7 +1365,7 @@ impl KmerMinHashBTree {
} else {
(other, self)
};
let downsampled_mh = second.downsample_max_hash(first.max_hash)?;
let downsampled_mh = second.clone().downsample_max_hash(first.max_hash)?;
first.count_common(&downsampled_mh, false)
} else {
self.check_compatible(other)?;
Expand Down Expand Up @@ -1496,7 +1496,7 @@ impl KmerMinHashBTree {
} else {
(other, self)
};
let downsampled_mh = second.downsample_max_hash(first.max_hash)?;
let downsampled_mh = second.clone().downsample_max_hash(first.max_hash)?;
first.similarity(&downsampled_mh, ignore_abundance, false)
} else if ignore_abundance || self.abunds.is_none() || other.abunds.is_none() {
self.jaccard(other)
Expand Down Expand Up @@ -1532,13 +1532,13 @@ impl KmerMinHashBTree {
}

// create a downsampled copy of self
pub fn downsample_max_hash(&self, max_hash: u64) -> Result<KmerMinHashBTree, Error> {
pub fn downsample_max_hash(self, max_hash: u64) -> Result<KmerMinHashBTree, Error> {
let scaled = scaled_for_max_hash(max_hash);
self.downsample_scaled(scaled)
}

// create a downsampled copy of self
pub fn downsample_scaled(&self, scaled: u64) -> Result<KmerMinHashBTree, Error> {
pub fn downsample_scaled(self, scaled: u64) -> Result<KmerMinHashBTree, Error> {
// @CTB shouldn't we check that new scaled > old scaled?
if self.scaled() == scaled {
Ok(self.clone()) // CTB avoid clone...
Expand Down

0 comments on commit 4ab87e4

Please sign in to comment.