From 6f8311882f4628ee83cae9d064b5eb9a80457662 Mon Sep 17 00:00:00 2001 From: Christopher Schwan Date: Tue, 22 Oct 2024 13:57:31 +0200 Subject: [PATCH] Add some cosmetic fixes --- pineappl/src/grid.rs | 22 ++++++++++------------ pineappl/src/subgrid.rs | 18 ------------------ pineappl_cli/src/export/applgrid.rs | 2 +- 3 files changed, 11 insertions(+), 31 deletions(-) diff --git a/pineappl/src/grid.rs b/pineappl/src/grid.rs index 8e6f3088..f7d40866 100644 --- a/pineappl/src/grid.rs +++ b/pineappl/src/grid.rs @@ -250,9 +250,9 @@ impl Grid { for ((ord, bin, chan), subgrid) in self.subgrids.indexed_iter() { let order = &self.orders[ord]; - if ((order.logxir > 0) && approx_eq!(f64, xir, 1.0, ulps = 4)) - || ((order.logxif > 0) && approx_eq!(f64, xif, 1.0, ulps = 4)) - || ((order.logxia > 0) && approx_eq!(f64, xia, 1.0, ulps = 4)) + if ((order.logxir != 0) && approx_eq!(f64, xir, 1.0, ulps = 4)) + || ((order.logxif != 0) && approx_eq!(f64, xif, 1.0, ulps = 4)) + || ((order.logxia != 0) && approx_eq!(f64, xia, 1.0, ulps = 4)) { continue; } @@ -288,15 +288,15 @@ impl Grid { value += lumi * v; } - if order.logxir > 0 { + if order.logxir != 0 { value *= (xir * xir).ln().powi(order.logxir.into()); } - if order.logxif > 0 { + if order.logxif != 0 { value *= (xif * xif).ln().powi(order.logxif.into()); } - if order.logxia > 0 { + if order.logxia != 0 { value *= (xia * xia).ln().powi(order.logxia.into()); } @@ -356,15 +356,15 @@ impl Grid { array[idx.as_slice()] = lumi * value; } - if order.logxir > 0 { + if order.logxir != 0 { array *= (xir * xir).ln().powi(order.logxir.into()); } - if order.logxif > 0 { + if order.logxif != 0 { array *= (xif * xif).ln().powi(order.logxif.into()); } - if order.logxia > 0 { + if order.logxia != 0 { array *= (xia * xia).ln().powi(order.logxia.into()); } @@ -1466,7 +1466,7 @@ impl Grid { for channel in &mut self.channels { *channel = self_pid_basis.translate(pid_basis, channel.clone()); } - self.pid_basis = pid_basis; + *self.pid_basis_mut() = pid_basis; } /// Deletes channels with the corresponding `channel_indices`. Repeated indices and indices @@ -1886,8 +1886,6 @@ mod tests { assert_eq!(grid.orders().len(), 1); } - // TODO: convolve_subgrid, merge_bins, subgrid, set_subgrid - #[test] fn grid_convolutions() { let mut grid = Grid::new( diff --git a/pineappl/src/subgrid.rs b/pineappl/src/subgrid.rs index 438a3210..027bbd8d 100644 --- a/pineappl/src/subgrid.rs +++ b/pineappl/src/subgrid.rs @@ -10,7 +10,6 @@ use enum_dispatch::enum_dispatch; use super::interpolation::Interp; use serde::{Deserialize, Serialize}; - /// Enum which lists all possible `Subgrid` variants possible. #[enum_dispatch(Subgrid)] #[derive(Clone, Deserialize, Serialize)] @@ -90,23 +89,6 @@ pub trait Subgrid { fn static_scale(&self) -> Option; } -// // this is needed in the Python interface -// impl From<&SubgridEnum> for Array3 { -// fn from(subgrid: &SubgridEnum) -> Self { -// let mut result = Self::zeros(( -// subgrid.mu2_grid().len(), -// subgrid.x1_grid().len(), -// subgrid.x2_grid().len(), -// )); -// -// for ((imu2, ix1, ix2), value) in subgrid.indexed_iter() { -// result[[imu2, ix1, ix2]] = value; -// } -// -// result -// } -// } - /// Type to iterate over the non-zero contents of a subgrid. The tuple contains the indices of the /// `mu2_grid`, the `x1_grid` and finally the `x2_grid`. pub type SubgridIndexedIter<'a> = Box, f64)> + 'a>; diff --git a/pineappl_cli/src/export/applgrid.rs b/pineappl_cli/src/export/applgrid.rs index 210053b9..48293582 100644 --- a/pineappl_cli/src/export/applgrid.rs +++ b/pineappl_cli/src/export/applgrid.rs @@ -119,7 +119,7 @@ pub fn convert_into_applgrid( } let lumis = grid.channels().len(); - let has_pdf1 = grid.convolutions().first().is_some(); + let has_pdf1 = !grid.convolutions().is_empty(); let has_pdf2 = grid.convolutions().get(1).is_some(); // TODO: check that PDG MC IDs are used