Skip to content

Commit

Permalink
Fixed Clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Genarito committed Oct 20, 2023
1 parent 60491ef commit 8bc6755
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/adjustment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl BenjaminiHochberg {
impl Adjustment for BenjaminiHochberg {
fn adjust(&mut self, p_value: f64, rank: usize) -> f64 {
let valid_rank = self.total_number_of_elements - rank as f64;
let q_value = p_value * (self.total_number_of_elements / valid_rank as f64);
let q_value = p_value * (self.total_number_of_elements / valid_rank);
let q_value = q_value.min(self.previous_max_p_value).min(1.0);
self.previous_max_p_value = q_value;
q_value
Expand Down Expand Up @@ -67,7 +67,7 @@ impl Adjustment for BenjaminiYekutieli {
fn adjust(&mut self, p_value: f64, rank: usize) -> f64 {
let valid_rank = self.total_number_of_elements - rank as f64;
let adjustment_factor =
self.accumulator * self.total_number_of_elements / valid_rank as f64;
self.accumulator * self.total_number_of_elements / valid_rank;
let q_value = p_value * adjustment_factor;
let q_value = q_value.min(self.previous_max_p_value).min(1.0);
self.previous_max_p_value = q_value;
Expand Down
6 changes: 3 additions & 3 deletions src/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl Analysis {
where
J::IntoIter: Clone,
{
i.cartesian_product(j.into_iter())
i.cartesian_product(j)
}

fn run_analysis(
Expand Down Expand Up @@ -201,7 +201,7 @@ impl Analysis {
_ => {
// Benjamini-Hochberg and Benjamini-Yekutieli needs sort by p-value (descending order) to
// make the adjustment
let sorter = ExternalSorter::new().with_segment_size(self.sort_buf_size as usize);
let sorter = ExternalSorter::new().with_segment_size(self.sort_buf_size);
Box::new(sorter.sort_by(filtered, |result_1, result_2| {
result_2
.p_value
Expand Down Expand Up @@ -245,7 +245,7 @@ impl Analysis {

// Sorts by correlation in descending order
let sorter =
ExternalSorter::new().with_segment_size(self.sort_buf_size as usize);
ExternalSorter::new().with_segment_size(self.sort_buf_size);
let sorted_cor_desc =
sorter.sort_by(filtered, |combination_1, combination_2| {
// Unwrap is safe as correlation values are all valid in this stage of algorithm (None
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ create_exception!(ggca, InvalidAdjustmentMethod, pyo3::exceptions::PyException);

// NOTE: Python has named arguments, so this linting warning can be disabled without sacrificing maintainability
#[pyfunction]
#[allow(clippy::too_many_arguments)] fn correlate(
#[allow(clippy::too_many_arguments)]
fn correlate(
py: Python,
gene_file_path: String,
gem_file_path: String,
Expand Down

0 comments on commit 8bc6755

Please sign in to comment.