From 4ab87e4b3ed4de1ec55f3177fe8a3fb4b070c814 Mon Sep 17 00:00:00 2001 From: "C. Titus Brown" Date: Sun, 6 Oct 2024 19:14:39 -0400 Subject: [PATCH] adjust references & use clone too much --- src/core/src/signature.rs | 2 +- src/core/src/sketch/minhash.rs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/core/src/signature.rs b/src/core/src/signature.rs index 0ab8190f9..8cc4ba915 100644 --- a/src/core/src/signature.rs +++ b/src/core/src/signature.rs @@ -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)?); } } } diff --git a/src/core/src/sketch/minhash.rs b/src/core/src/sketch/minhash.rs index d777b4f50..df518aa92 100644 --- a/src/core/src/sketch/minhash.rs +++ b/src/core/src/sketch/minhash.rs @@ -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)?; @@ -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) @@ -721,7 +721,7 @@ impl KmerMinHash { } // create a downsampled copy of self - pub fn downsample_max_hash(&self, max_hash: u64) -> Result { + pub fn downsample_max_hash(self, max_hash: u64) -> Result { let scaled = scaled_for_max_hash(max_hash); self.downsample_scaled(scaled) } @@ -768,7 +768,7 @@ impl KmerMinHash { } // create a downsampled copy of self - pub fn downsample_scaled(&self, scaled: u64) -> Result { + pub fn downsample_scaled(self, scaled: u64) -> Result { // @CTB shouldn't we check that new scaled > old scaled? if self.scaled() == scaled { Ok(self.clone()) // avoid clone CTB @@ -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)?; @@ -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) @@ -1532,13 +1532,13 @@ impl KmerMinHashBTree { } // create a downsampled copy of self - pub fn downsample_max_hash(&self, max_hash: u64) -> Result { + pub fn downsample_max_hash(self, max_hash: u64) -> Result { 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 { + pub fn downsample_scaled(self, scaled: u64) -> Result { // @CTB shouldn't we check that new scaled > old scaled? if self.scaled() == scaled { Ok(self.clone()) // CTB avoid clone...