Skip to content

Commit

Permalink
fix all warnings from clippy (non-deps related)
Browse files Browse the repository at this point in the history
  • Loading branch information
Radonirinaunimi committed Oct 1, 2024
1 parent d848bd4 commit ced2f8e
Show file tree
Hide file tree
Showing 24 changed files with 61 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/cli-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ used already, run
Depending on the version of PineAPPL this will show output similar to the
following:

Convolutes a PineAPPL grid with a PDF set
Convolves a PineAPPL grid with a PDF set

Usage: pineappl convolve [OPTIONS] <INPUT> <PDFSETS>...

Expand Down
2 changes: 2 additions & 0 deletions pineappl/src/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ pub enum ParseBinRemapperError {
},
}

#[allow(clippy::assigning_clones)]
impl FromStr for BinRemapper {
type Err = ParseBinRemapperError;

Expand Down Expand Up @@ -787,6 +788,7 @@ impl BinLimits {
}
}

#[allow(clippy::float_cmp)]
#[cfg(test)]
mod test {
use super::*;
Expand Down
1 change: 1 addition & 0 deletions pineappl/src/convolutions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ impl<'a> LumiCache<'a> {
}

/// Set the grids.
#[allow(clippy::float_cmp)]
pub fn set_grids(
&mut self,
mu2_grid: &[Mu2],
Expand Down
1 change: 1 addition & 0 deletions pineappl/src/empty_subgrid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ impl Subgrid for EmptySubgridV1 {
}
}

#[allow(clippy::float_cmp)]
#[cfg(test)]
mod tests {
use super::*;
Expand Down
1 change: 1 addition & 0 deletions pineappl/src/fk_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ impl FkTable {
}
}

#[allow(clippy::float_cmp)]
impl TryFrom<Grid> for FkTable {
type Error = TryFromGridError;

Expand Down
17 changes: 16 additions & 1 deletion pineappl/src/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ bitflags! {

/// Main data structure of `PineAPPL`. This structure contains a `Subgrid` for each `LumiEntry`,
/// bin, and coupling order it was created with.
#[allow(clippy::unsafe_derive_deserialize)]
#[derive(Clone, Deserialize, Serialize)]
pub struct Grid {
subgrids: Array3<SubgridEnum>,
Expand Down Expand Up @@ -257,6 +258,7 @@ impl Grid {
/// # Errors
///
/// If `subgrid_type` is none of the values listed above, an error is returned.
#[allow(clippy::needless_pass_by_value)]
pub fn with_subgrid_type(
channels: Vec<Channel>,
orders: Vec<Order>,
Expand Down Expand Up @@ -333,6 +335,7 @@ impl Grid {
/// # Panics
///
/// TODO
#[allow(clippy::float_cmp)]
pub fn convolve(
&self,
lumi_cache: &mut LumiCache,
Expand Down Expand Up @@ -414,7 +417,7 @@ impl Grid {
bins
}

/// Convolutes a single subgrid `(order, bin, channel)` with the PDFs strong coupling given by
/// Convolves a single subgrid `(order, bin, channel)` with the PDFs strong coupling given by
/// `xfx1`, `xfx2` and `alphas`. The convolution result is fully differentially, such that the
/// axes of the result correspond to the values given by the subgrid `q2`, `x1` and `x2` grid
/// values.
Expand Down Expand Up @@ -841,6 +844,7 @@ impl Grid {
}

/// Set the convolution type for this grid for the corresponding `index`.
#[allow(clippy::needless_pass_by_value)]
pub fn set_convolution(&mut self, index: usize, convolution: Convolution) {
// remove outdated metadata
self.key_values_mut()
Expand Down Expand Up @@ -1391,6 +1395,11 @@ impl Grid {
/// Returns a [`GridError::EvolutionFailure`] if either the `operator` or its `info` is
/// incompatible with this `Grid`. Returns a [`GridError::Other`] if the iterator from `slices`
/// return an error.
///
/// # Panics
///
/// This function will panic if the dimension of the operators do not match the operator
/// information.
pub fn evolve_with_slice_iter<'a, E: Into<anyhow::Error>>(
&self,
slices: impl IntoIterator<Item = Result<(OperatorSliceInfo, CowArray<'a, f64, Ix4>), E>>,
Expand Down Expand Up @@ -1513,6 +1522,11 @@ impl Grid {
/// Returns a [`GridError::EvolutionFailure`] if either the `operator` or its `info` is
/// incompatible with this `Grid`. Returns a [`GridError::Other`] if the iterator from `slices`
/// return an error.
///
/// # Panics
///
/// This function will panic if the dimension of the operators do not match the operator
/// information.
pub fn evolve_with_slice_iter2<'a, E: Into<anyhow::Error>>(
&self,
slices_a: impl IntoIterator<Item = Result<(OperatorSliceInfo, CowArray<'a, f64, Ix4>), E>>,
Expand Down Expand Up @@ -1661,6 +1675,7 @@ impl Grid {

/// Deletes bins with the corresponding `bin_indices`. Repeated indices and indices larger or
/// equal the bin length are ignored.
#[allow(clippy::range_plus_one)]
pub fn delete_bins(&mut self, bin_indices: &[usize]) {
let mut bin_indices: Vec<_> = bin_indices
.iter()
Expand Down
3 changes: 3 additions & 0 deletions pineappl/src/import_only_subgrid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ impl Subgrid for ImportOnlySubgridV1 {
self.array.is_empty()
}

#[allow(clippy::float_cmp)]
fn merge(&mut self, other: &mut SubgridEnum, transpose: bool) {
if let SubgridEnum::ImportOnlySubgridV1(other_grid) = other {
if self.array.is_empty() && !transpose {
Expand Down Expand Up @@ -243,6 +244,7 @@ impl Subgrid for ImportOnlySubgridV2 {
self.array.is_empty()
}

#[allow(clippy::float_cmp)]
fn merge(&mut self, other: &mut SubgridEnum, transpose: bool) {
if let SubgridEnum::ImportOnlySubgridV2(other_grid) = other {
if self.array.is_empty() && !transpose {
Expand Down Expand Up @@ -433,6 +435,7 @@ impl From<&SubgridEnum> for ImportOnlySubgridV2 {
}
}

#[allow(clippy::float_cmp)]
#[cfg(test)]
mod tests {
use super::*;
Expand Down
5 changes: 5 additions & 0 deletions pineappl/src/lagrange_subgrid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ use std::borrow::Cow;
use std::iter;
use std::mem;

#[allow(clippy::suboptimal_flops)]
fn weightfun(x: f64) -> f64 {
(x.sqrt() / (1.0 - 0.99 * x)).powi(3)
}

#[allow(clippy::suboptimal_flops)]
fn fx(y: f64) -> f64 {
let mut yp = y;

Expand Down Expand Up @@ -412,6 +414,7 @@ pub struct LagrangeSubgridV2 {
pub(crate) static_q2: f64,
}

#[allow(clippy::float_cmp)]
impl LagrangeSubgridV2 {
/// Constructor.
#[must_use]
Expand Down Expand Up @@ -493,6 +496,7 @@ impl LagrangeSubgridV2 {
}
}

#[allow(clippy::float_cmp)]
impl Subgrid for LagrangeSubgridV2 {
fn convolve(
&self,
Expand Down Expand Up @@ -1055,6 +1059,7 @@ impl From<&LagrangeSubgridV1> for LagrangeSparseSubgridV1 {
}
}

#[allow(clippy::float_cmp)]
#[cfg(test)]
mod tests {
use super::*;
Expand Down
1 change: 1 addition & 0 deletions pineappl/src/pids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ pub const fn charge_conjugate_pdg_pid(pid: i32) -> i32 {
/// Given `tuples` represting a linear combination of PDG MC IDs, return a PID for the `evol`
/// basis. The order of each tuple in `tuples` is not relevant. This function inverts
/// [`evol_to_pdg_mc_ids`]. If the inversion is not possible, `None` is returned.
#[allow(clippy::float_cmp)]
#[must_use]
pub fn pdg_mc_ids_to_evol(tuples: &[(i32, f64)]) -> Option<i32> {
let mut tuples = tuples.to_vec();
Expand Down
2 changes: 2 additions & 0 deletions pineappl/src/sparse_array3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ impl<T: Clone + Default + PartialEq> SparseArray3<T> {
}

/// Return an iterator over the elements, including zero elements.
#[allow(clippy::iter_without_into_iter)]
pub fn iter_mut(&mut self) -> IterMut<'_, T> {
self.entries.iter_mut()
}
Expand Down Expand Up @@ -420,6 +421,7 @@ impl<T: Clone + Default + PartialEq> SparseArray3<T> {
}
}

#[allow(clippy::float_cmp)]
#[cfg(test)]
mod tests {
use super::*;
Expand Down
2 changes: 2 additions & 0 deletions pineappl/tests/drell_yan_lo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ fn int_photo(s: f64, t: f64, u: f64) -> f64 {
}

// Eq. (2.12) - quark-antiquark contribution to DY lepton pair production
#[allow(clippy::suboptimal_flops)]
fn int_quark(s: f64, t: f64, u: f64, qq: f64, i3_wq: f64) -> f64 {
let alphagf: f64 = 1.0 / 132.30818655547878;
let mw = 80.35198454966643;
Expand Down Expand Up @@ -77,6 +78,7 @@ struct Psp2to2 {
jacobian: f64,
}

#[allow(clippy::suboptimal_flops)]
fn hadronic_pspgen(rng: &mut impl Rng, mmin: f64, mmax: f64) -> Psp2to2 {
let smin = mmin * mmin;
let smax = mmax * mmax;
Expand Down
8 changes: 8 additions & 0 deletions pineappl_capi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@ pub unsafe extern "C" fn pineappl_grid_clone(grid: *const Grid) -> Box<Grid> {
}

/// Wrapper for [`pineappl_grid_convolve_with_one`].
///
/// # Safety
///
/// This function should not be used anymore. Use `pineappl_grid_convolve_with_one` instead.
#[deprecated(
since = "0.8.0",
note = "please use `pineappl_grid_convolve_with_one` instead"
Expand Down Expand Up @@ -326,6 +330,10 @@ pub unsafe extern "C" fn pineappl_grid_convolute_with_one(
}

/// Wrapper for [`pineappl_grid_convolve_with_two`].
///
/// # Safety
///
/// This function should not be used anymore. Use `pineappl_grid_convolve_with_two` instead.
#[deprecated(
since = "0.8.0",
note = "please use `pineappl_grid_convolve_with_two` instead"
Expand Down
3 changes: 2 additions & 1 deletion pineappl_cli/src/convolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ use std::ops::RangeInclusive;
use std::path::PathBuf;
use std::process::ExitCode;

/// Convolutes a PineAPPL grid with a PDF set.
/// Convolves a PineAPPL grid with a PDF set.
#[allow(clippy::doc_markdown)]
#[derive(Parser)]
#[command(alias = "convolute")]
pub struct Opts {
Expand Down
1 change: 1 addition & 0 deletions pineappl_cli/src/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub struct Opts {
digits_rel: usize,
}

#[allow(clippy::float_cmp)]
impl Subcommand for Opts {
fn run(&self, cfg: &GlobalConfiguration) -> Result<ExitCode> {
let grid1 = helpers::read_grid(&self.input1)?;
Expand Down
1 change: 1 addition & 0 deletions pineappl_cli/src/evolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ pub struct Opts {
use_old_evolve: bool,
}

#[allow(clippy::float_cmp)]
impl Subcommand for Opts {
fn run(&self, cfg: &GlobalConfiguration) -> Result<ExitCode> {
use prettytable::row;
Expand Down
2 changes: 2 additions & 0 deletions pineappl_cli/src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ fn convert_into_grid(
}

/// Converts PineAPPL grids to APPLgrid files.
#[allow(clippy::doc_markdown)]
#[derive(Parser)]
pub struct Opts {
/// Path to the input grid.
Expand Down Expand Up @@ -97,6 +98,7 @@ pub struct Opts {
digits_rel: usize,
}

#[allow(clippy::float_cmp)]
impl Subcommand for Opts {
fn run(&self, cfg: &GlobalConfiguration) -> Result<ExitCode> {
use prettytable::{cell, row};
Expand Down
2 changes: 2 additions & 0 deletions pineappl_cli/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ const fn fnlo_mu_possible_values() -> Vec<&'static str> {
}

/// Converts APPLgrid/fastNLO/FastKernel files to PineAPPL grids.
#[allow(clippy::doc_markdown)]
#[derive(Parser)]
pub struct Opts {
/// Path to the input grid.
Expand Down Expand Up @@ -251,6 +252,7 @@ pub struct Opts {
dis_pid: i32,
}

#[allow(clippy::float_cmp)]
impl Subcommand for Opts {
fn run(&self, cfg: &GlobalConfiguration) -> Result<ExitCode> {
use prettytable::{cell, row};
Expand Down
3 changes: 2 additions & 1 deletion pineappl_cli/src/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ use std::path::PathBuf;
use std::process::ExitCode;

/// Merges one or more PineAPPL grids together.
#[allow(clippy::doc_markdown)]
#[derive(Parser)]
pub struct Opts {
/// Path of the merged PineAPPL file.
/// Path of the merged `PineAPPL` file.
#[arg(value_hint = ValueHint::FilePath)]
output: PathBuf,
/// Path(s) of the files that should be merged.
Expand Down
1 change: 1 addition & 0 deletions pineappl_cli/src/plot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ fn format_metadata(metadata: &[(&String, &String)]) -> String {
.join("\n")
}

#[allow(clippy::float_cmp)]
impl Subcommand for Opts {
fn run(&self, cfg: &GlobalConfiguration) -> Result<ExitCode> {
ThreadPoolBuilder::new()
Expand Down
2 changes: 2 additions & 0 deletions pineappl_cli/src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use std::path::PathBuf;
use std::process::ExitCode;

/// Write a grid modified by various operations.
#[allow(clippy::doc_markdown)]
#[derive(Parser)]
pub struct Opts {
/// Path to the input grid.
Expand Down Expand Up @@ -494,6 +495,7 @@ impl Args for MoreArgs {
}
}

#[allow(clippy::range_plus_one)]
impl Subcommand for Opts {
fn run(&self, _: &GlobalConfiguration) -> Result<ExitCode> {
let mut grid = helpers::read_grid(&self.input)?;
Expand Down
2 changes: 1 addition & 1 deletion pineappl_cli/tests/convolve.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use assert_cmd::Command;
use predicates::str;

const HELP_STR: &str = "Convolutes a PineAPPL grid with a PDF set
const HELP_STR: &str = "Convolves a PineAPPL grid with a PDF set
Usage: pineappl convolve [OPTIONS] <INPUT> <CONV_FUNS>...
Expand Down
2 changes: 2 additions & 0 deletions pineappl_cli/tests/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ fn import_flex_grid_15() {
.stdout(predicates::str::ends_with(IMPORT_FLEX_GRID_15_STR));
}

#[allow(clippy::float_cmp)]
#[test]
#[cfg(feature = "fktable")]
fn import_dis_fktable() {
Expand Down Expand Up @@ -831,6 +832,7 @@ fn import_dis_fktable() {
);
}

#[allow(clippy::float_cmp)]
#[test]
#[cfg(feature = "fktable")]
fn import_hadronic_fktable() {
Expand Down
2 changes: 1 addition & 1 deletion pineappl_cli/tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Usage: pineappl [OPTIONS] <COMMAND>
Commands:
analyze Perform various analyses with grids
channels Shows the contribution for each partonic channel
convolve Convolutes a PineAPPL grid with a PDF set
convolve Convolves a PineAPPL grid with a PDF set
diff Compares the numerical content of two grids with each other
evolve Evolve a grid with an evolution kernel operator to an FK table
export Converts PineAPPL grids to APPLgrid files
Expand Down
2 changes: 1 addition & 1 deletion pineappl_cli/tests/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const HELP_STR: &str = "Merges one or more PineAPPL grids together
Usage: pineappl merge <OUTPUT> <INPUT>...
Arguments:
<OUTPUT> Path of the merged PineAPPL file
<OUTPUT> Path of the merged `PineAPPL` file
<INPUT>... Path(s) of the files that should be merged
Options:
Expand Down

0 comments on commit ced2f8e

Please sign in to comment.