Skip to content

Commit

Permalink
Fix a few clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
cschwan committed May 13, 2024
1 parent f85f512 commit 05a115f
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pineappl/src/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ impl FromStr for BinRemapper {
}
}

last_indices = indices.clone();
last_indices.clone_from(&indices);

let mut normalization = 1.0;

Expand Down
5 changes: 3 additions & 2 deletions pineappl/src/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use std::str::FromStr;
use thiserror::Error;

/// Error type keeping information if [`Order::from_str`] went wrong.
#[derive(Debug, Error, PartialEq)]
#[derive(Debug, Error, Eq, PartialEq)]
#[error("{0}")]
pub struct ParseOrderError(String);

Expand Down Expand Up @@ -578,6 +578,7 @@ impl Grid {
}

/// Return by which convention the particle IDs are encoded.
#[must_use]
pub fn pid_basis(&self) -> PidBasis {
if let Some(key_values) = self.key_values() {
if let Some(lumi_id_types) = key_values.get("lumi_id_types") {
Expand All @@ -590,7 +591,7 @@ impl Grid {
}

// if there's no basis explicitly set we're assuming to use PDG IDs
return PidBasis::Pdg;
PidBasis::Pdg
}

fn pdg_lumi(&self) -> Cow<[LumiEntry]> {
Expand Down
7 changes: 3 additions & 4 deletions pineappl/src/lumi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ impl LumiEntry {
/// assert_eq!(entry1.common_factor(&entry3), None);
/// assert_eq!(entry1.common_factor(&entry4), None);
/// ```
#[must_use]
pub fn common_factor(&self, other: &Self) -> Option<f64> {
if self.entry.len() != other.entry.len() {
return None;
Expand All @@ -165,7 +166,7 @@ impl LumiEntry {
.map(|(a, b)| ((a.0 == b.0) && (a.1 == b.1)).then_some(a.2 / b.2))
.collect();

if let Some(factors) = result {
result.and_then(|factors| {
if factors
.windows(2)
.all(|win| approx_eq!(f64, win[0], win[1], ulps = 4))
Expand All @@ -174,9 +175,7 @@ impl LumiEntry {
} else {
None
}
} else {
None
}
})
}
}

Expand Down
5 changes: 3 additions & 2 deletions pineappl/src/pids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ impl FromStr for PidBasis {

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"Pdg" | "PDG" | "pdg_mc_ids" => Ok(PidBasis::Pdg),
"Evol" | "EVOL" | "evol" => Ok(PidBasis::Evol),
"Pdg" | "PDG" | "pdg_mc_ids" => Ok(Self::Pdg),
"Evol" | "EVOL" | "evol" => Ok(Self::Evol),
_ => Err(UnknownPidBasis {
basis: s.to_owned(),
}),
Expand Down Expand Up @@ -168,6 +168,7 @@ pub fn evol_to_pdg_mc_ids(id: i32) -> Vec<(i32, f64)> {
}

/// Translates PDG Monte Carlo IDs to particle IDs from the evolution basis.
#[must_use]
pub fn pdg_mc_pids_to_evol(pid: i32) -> Vec<(i32, f64)> {
match pid {
-6 => vec![
Expand Down
2 changes: 1 addition & 1 deletion pineappl_capi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ fn grid_params(key_vals: Option<&KeyVal>) -> (String, SubgridParams, ExtraSubgri
}

if let Some(value) = keyval.strings.get("subgrid_type") {
subgrid_type = value.to_str().unwrap().to_owned();
value.to_str().unwrap().clone_into(&mut subgrid_type);
}
}

Expand Down
2 changes: 1 addition & 1 deletion pineappl_cli/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ fn fnlo_mu_possible_values() -> Vec<&'static str> {
}

#[cfg(not(feature = "fastnlo"))]
fn fnlo_mu_possible_values() -> Vec<&'static str> {
const fn fnlo_mu_possible_values() -> Vec<&'static str> {
vec![]
}

Expand Down
2 changes: 1 addition & 1 deletion pineappl_cli/src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ impl Subcommand for Opts {
grid.orders_mut()[*index] = order.clone();
}
OpsArg::RotatePidBasis(pid_basis) => {
grid.rotate_pid_basis(pid_basis.clone());
grid.rotate_pid_basis(*pid_basis);
}
OpsArg::Scale(factor) => grid.scale(*factor),
OpsArg::Optimize(true) => grid.optimize(),
Expand Down

0 comments on commit 05a115f

Please sign in to comment.