Skip to content

Commit

Permalink
fix: Fix incorrect usage of references in function arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
cauliyang committed Dec 2, 2024
1 parent 9fbfa9d commit 1092eed
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/kmer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn vectorize_targets(targets: &[usize], length: usize) -> Result<Vec<usize>>
assert!(targets.len() % 2 == 0);

let mut result = vec![0; length];
for (start, end) in targets.into_iter().tuples() {
for (start, end) in targets.iter().tuples() {
if start > end || end > &length {
return Err(Error::from(EncodingError::TargetRegionInvalid));
}
Expand All @@ -71,7 +71,6 @@ pub fn vectorize_targets(targets: &[usize], length: usize) -> Result<Vec<usize>>
Ok(result)
}


#[pyfunction(name = "vectorize_targets")]
pub fn py_vectorize_targets(targets: Vec<usize>, length: usize) -> Result<Vec<usize>> {
vectorize_targets(&targets, length)
Expand Down Expand Up @@ -441,16 +440,15 @@ mod tests {
fn test_vectorize_targets_valid() {
let targets = vec![0, 5, 7, 10];
let length = 15;
let result = vectorize_targets(targets, length).unwrap();
let result = vectorize_targets(&targets, length).unwrap();
assert_eq!(result, vec![1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0]);
}

#[test]
fn test_vectorize_targets_invalid() {
let targets = vec![0, 5, 7, 20];
let length = 15;
let result = vectorize_targets(targets, length);
let result = vectorize_targets(&targets, length);
assert!(result.is_err());
}

}

0 comments on commit 1092eed

Please sign in to comment.