Skip to content

Commit

Permalink
Add some cosmetic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cschwan committed Oct 22, 2024
1 parent 06e16b9 commit 6f83118
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 31 deletions.
22 changes: 10 additions & 12 deletions pineappl/src/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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());
}

Expand Down Expand Up @@ -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());
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
18 changes: 0 additions & 18 deletions pineappl/src/subgrid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -90,23 +89,6 @@ pub trait Subgrid {
fn static_scale(&self) -> Option<Mu2>;
}

// // this is needed in the Python interface
// impl From<&SubgridEnum> for Array3<f64> {
// 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<dyn Iterator<Item = (Vec<usize>, f64)> + 'a>;
2 changes: 1 addition & 1 deletion pineappl_cli/src/export/applgrid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6f83118

Please sign in to comment.