From 461d53662d3a33f2231b5381e3545e3b118d2c3b Mon Sep 17 00:00:00 2001 From: t7phy Date: Thu, 10 Oct 2024 14:21:36 +0200 Subject: [PATCH] Remove `Convolution::None` and start fixing the importing of DIS grids --- pineappl/src/convolutions.rs | 8 ---- pineappl/src/evolution.rs | 8 ---- pineappl/src/fk_table.rs | 51 ++++++++++----------- pineappl/src/grid.rs | 21 +++------ pineappl_cli/src/export/applgrid.rs | 12 +---- pineappl_cli/src/helpers.rs | 6 +-- pineappl_cli/src/import.rs | 14 +++--- pineappl_cli/src/import/applgrid.rs | 71 ++++++++++++----------------- pineappl_cli/src/import/fastnlo.rs | 12 +---- pineappl_cli/src/import/fktable.rs | 40 ++++++++-------- pineappl_cli/src/plot.rs | 13 +----- pineappl_cli/tests/import.rs | 30 ++++++------ 12 files changed, 111 insertions(+), 175 deletions(-) diff --git a/pineappl/src/convolutions.rs b/pineappl/src/convolutions.rs index 235c8d6e..6edd30ae 100644 --- a/pineappl/src/convolutions.rs +++ b/pineappl/src/convolutions.rs @@ -240,7 +240,6 @@ impl<'a> ConvolutionCache<'a> { let imua2 = self.imua2[indices[0]]; (imua2, self.mua2_grid[imua2]) } - Convolution::None => unreachable!(), }; *xfx_cache.entry((pid, ix, imu2)).or_insert_with(|| { let x = self.x_grid[ix]; @@ -336,9 +335,6 @@ impl<'a> ConvolutionCache<'a> { /// Data type that indentifies different types of convolutions. #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] pub enum Convolution { - // TODO: eventually get rid of this value - /// No convolution. - None, /// Unpolarized parton distribution function. The integer denotes the type of hadron with a PDG /// MC ID. UnpolPDF(i32), @@ -357,7 +353,6 @@ impl Convolution { #[must_use] pub const fn charge_conjugate(&self) -> Self { match *self { - Self::None => Self::None, Self::UnpolPDF(pid) => Self::UnpolPDF(pids::charge_conjugate_pdg_pid(pid)), Self::PolPDF(pid) => Self::PolPDF(pids::charge_conjugate_pdg_pid(pid)), Self::UnpolFF(pid) => Self::UnpolFF(pids::charge_conjugate_pdg_pid(pid)), @@ -369,7 +364,6 @@ impl Convolution { #[must_use] pub const fn pid(&self) -> Option { match *self { - Self::None => None, Self::UnpolPDF(pid) | Self::PolPDF(pid) | Self::UnpolFF(pid) | Self::PolFF(pid) => { Some(pid) } @@ -383,7 +377,6 @@ mod tests { #[test] fn convolution_charge_conjugate() { - assert_eq!(Convolution::None.charge_conjugate(), Convolution::None); assert_eq!( Convolution::UnpolPDF(2212).charge_conjugate(), Convolution::UnpolPDF(-2212) @@ -404,7 +397,6 @@ mod tests { #[test] fn convolution_pid() { - assert_eq!(Convolution::None.pid(), None); assert_eq!(Convolution::UnpolPDF(2212).pid(), Some(2212)); assert_eq!(Convolution::PolPDF(2212).pid(), Some(2212)); assert_eq!(Convolution::UnpolFF(2212).pid(), Some(2212)); diff --git a/pineappl/src/evolution.rs b/pineappl/src/evolution.rs index 0b849e1a..0283d6f5 100644 --- a/pineappl/src/evolution.rs +++ b/pineappl/src/evolution.rs @@ -1,7 +1,6 @@ //! Supporting classes and functions for [`Grid::evolve_with_slice_iter`]. use super::boc::{Channel, Kinematics, Order}; -use super::convolutions::Convolution; use super::grid::{Grid, GridError}; use super::packed_array::PackedArray; use super::packed_subgrid::PackedQ1X2SubgridV1; @@ -388,13 +387,6 @@ pub(crate) fn evolve_slice_with_many( assert_eq!(operators.len(), infos.len()); assert_eq!(operators.len(), grid.convolutions().len()); - assert_eq!( - grid.convolutions() - .iter() - .filter(|&conv| *conv == Convolution::None) - .count(), - 0 - ); let (pid_indices, pids01): (Vec<_>, Vec<_>) = izip!(0..infos.len(), operators, infos) .map(|(d, operator, info)| { diff --git a/pineappl/src/fk_table.rs b/pineappl/src/fk_table.rs index ac7e6faa..f5ec3e76 100644 --- a/pineappl/src/fk_table.rs +++ b/pineappl/src/fk_table.rs @@ -1,12 +1,13 @@ //! Provides the [`FkTable`] type. use super::boc::{Kinematics, Order}; -use super::convolutions::{Convolution, ConvolutionCache}; +use super::convolutions::ConvolutionCache; use super::grid::Grid; use super::subgrid::Subgrid; use float_cmp::approx_eq; use ndarray::ArrayD; use std::fmt::{self, Display, Formatter}; +use std::iter; use std::str::FromStr; use thiserror::Error; @@ -148,43 +149,34 @@ impl FkTable { let x_grid = self.x_grid(); let mut dim = vec![self.grid.bin_info().bins(), self.grid.channels().len()]; - dim.extend(self.grid.convolutions().iter().map(|convolution| { - if *convolution == Convolution::None { - 1 - } else { - x_grid.len() - } - })); + dim.extend(iter::repeat(x_grid.len()).take(self.grid.convolutions().len())); + let mut idx = vec![0; dim.len()]; let mut result = ArrayD::zeros(dim); for ((_, bin, channel), subgrid) in self.grid().subgrids().indexed_iter() { - let indices: Vec<_> = self + let indices: Vec> = self .grid .convolutions() .iter() .enumerate() - .map(|(index, convolution)| { + .map(|(index, _)| { subgrid .node_values() .iter() .zip(self.grid.kinematics()) .find_map(|(node_values, kin)| { matches!(kin, Kinematics::X(i) if *i == index).then(|| { - if *convolution == Convolution::None { - vec![0] - } else { - node_values - .values() - .iter() - .map(|&s| { - x_grid - .iter() - .position(|&x| approx_eq!(f64, s, x, ulps = 2)) - // UNWRAP: must be guaranteed by the grid constructor - .unwrap() - }) - .collect() - } + node_values + .values() + .iter() + .map(|&s| { + x_grid + .iter() + .position(|&x| approx_eq!(f64, s, x, ulps = 2)) + // UNWRAP: must be guaranteed by the grid constructor + .unwrap() + }) + .collect() }) }) // UNWRAP: must be guaranteed by the grid constructor @@ -193,10 +185,13 @@ impl FkTable { .collect(); for (index, value) in subgrid.indexed_iter() { - assert_eq!(index.len(), 3); assert_eq!(index[0], 0); - // result[[bin, channel, indices1[index[1]], indices2[index[2]]]] = value; - result[[bin, channel, indices[0][index[1]], indices[1][index[2]]]] = value; + idx[0] = bin; + idx[1] = channel; + for i in 2..result.shape().len() { + idx[i] = indices[i - 2][index[i - 1]]; + } + result[idx.as_slice()] = value; } } diff --git a/pineappl/src/grid.rs b/pineappl/src/grid.rs index 3c8e881b..ada5f6b4 100644 --- a/pineappl/src/grid.rs +++ b/pineappl/src/grid.rs @@ -1167,21 +1167,15 @@ impl Grid { .node_values() .iter() .zip(self.kinematics()) - .filter(|(_, kin)| matches!(kin, Kinematics::X(_))) - .zip(self.convolutions()) - .filter_map(|((node_values, _), convolution)| { - (*convolution != Convolution::None).then_some(node_values.values()) - }) + .filter_map(|(nv, kin)| matches!(kin, Kinematics::X(_)).then(|| nv.values())) .flatten(), ); x1.sort_by(f64::total_cmp); x1.dedup_by(|a, b| approx_eq!(f64, *a, *b, ulps = EVOLVE_INFO_TOL_ULPS)); - for (index, convolution) in self.convolutions().iter().enumerate() { - if *convolution != Convolution::None { - pids1.extend(channel.entry().iter().map(|(pids, _)| pids[index])); - } + for (index, _) in self.convolutions().iter().enumerate() { + pids1.extend(channel.entry().iter().map(|(pids, _)| pids[index])); } pids1.sort_unstable(); @@ -1359,6 +1353,9 @@ impl Grid { use super::evolution::EVOLVE_INFO_TOL_ULPS; use itertools::izip; + // TODO: generalize this function for an arbitrary number of convolutions + assert_eq!(self.convolutions().len(), 2); + let mut lhs: Option = None; // Q2 slices we use let mut used_op_fac1 = Vec::new(); @@ -1437,12 +1434,6 @@ impl Grid { let views = [operator_a.view(), operator_b.view()]; let infos = [info_a, info_b]; - assert!( - (self.convolutions()[0] != Convolution::None) - && (self.convolutions()[1] != Convolution::None), - "only one convolution found, use `Grid::evolve_with_slice_iter` instead" - ); - let (subgrids, channels) = evolution::evolve_slice_with_many( self, &views, diff --git a/pineappl_cli/src/export/applgrid.rs b/pineappl_cli/src/export/applgrid.rs index 9554470e..40c3fd45 100644 --- a/pineappl_cli/src/export/applgrid.rs +++ b/pineappl_cli/src/export/applgrid.rs @@ -4,7 +4,6 @@ use float_cmp::approx_eq; use lhapdf::Pdf; use ndarray::{s, Axis}; use pineappl::boc::{Kinematics, Order}; -use pineappl::convolutions::Convolution; use pineappl::grid::Grid; use pineappl::interpolation::{Interp, InterpMeth, Map, ReweightMeth}; use pineappl::subgrid::Subgrid; @@ -147,10 +146,7 @@ pub fn convert_into_applgrid( assert_eq!(factor, 1.0); pids.iter() - .zip(grid.convolutions()) - .filter_map(|(&pid, convolution)| { - (*convolution != Convolution::None).then_some(pid) - }) + .copied() .chain(iter::repeat(0)) .take(2) .collect::>() @@ -237,11 +233,7 @@ pub fn convert_into_applgrid( map @ Map::ApplGridF2 => panic!("export does not support {map:?}"), }, grid.channels().len().try_into().unwrap(), - grid.convolutions() - .iter() - .filter(|&conv| *conv != Convolution::None) - .count() - == 1, + grid.convolutions().len() == 1, ); let appl_q2: Vec<_> = (0..igrid.Ntau()).map(|i| igrid.getQ2(i)).collect(); let appl_x1: Vec<_> = (0..igrid.Ny1()).map(|i| igrid.getx1(i)).collect(); diff --git a/pineappl_cli/src/helpers.rs b/pineappl_cli/src/helpers.rs index 9dbcf19e..bf29f920 100644 --- a/pineappl_cli/src/helpers.rs +++ b/pineappl_cli/src/helpers.rs @@ -297,8 +297,7 @@ pub fn convolve_scales( // if we can not figure out the type of the convolution from the PDF set, we // assume it from the grid convolution at the same index match convolution { - // if the grid convolution is None, we assume it's a proton PDF - Convolution::None | Convolution::UnpolPDF(_) => Convolution::UnpolPDF(pid), + Convolution::UnpolPDF(_) => Convolution::UnpolPDF(pid), Convolution::PolPDF(_) => Convolution::PolPDF(pid), Convolution::UnpolFF(_) => Convolution::UnpolFF(pid), Convolution::PolFF(_) => Convolution::PolFF(pid), @@ -468,8 +467,7 @@ pub fn convolve_subgrid( // if we can not figure out the type of the convolution from the PDF set, we // assume it from the grid convolution at the same index match convolution { - // if the grid convolution is None, we assume it's a proton PDF - Convolution::None | Convolution::UnpolPDF(_) => Convolution::UnpolPDF(pid), + Convolution::UnpolPDF(_) => Convolution::UnpolPDF(pid), Convolution::PolPDF(_) => Convolution::PolPDF(pid), Convolution::UnpolFF(_) => Convolution::UnpolFF(pid), Convolution::PolFF(_) => Convolution::PolFF(pid), diff --git a/pineappl_cli/src/import.rs b/pineappl_cli/src/import.rs index e16bcafe..cf6a6ff0 100644 --- a/pineappl_cli/src/import.rs +++ b/pineappl_cli/src/import.rs @@ -20,7 +20,6 @@ fn convert_applgrid( input: &Path, alpha: u32, conv_funs: &mut [Pdf], - dis_pid: i32, _: usize, ) -> Result<(&'static str, Grid, Vec, usize)> { use pineappl_applgrid::ffi; @@ -28,7 +27,7 @@ fn convert_applgrid( // TODO: check AMCATNLO scale variations let mut grid = ffi::make_grid(input.to_str().unwrap())?; - let pgrid = applgrid::convert_applgrid(grid.pin_mut(), alpha, dis_pid)?; + let pgrid = applgrid::convert_applgrid(grid.pin_mut(), alpha)?; let results = applgrid::convolve_applgrid(grid.pin_mut(), conv_funs); Ok(("APPLgrid", pgrid, results, 1)) @@ -39,7 +38,6 @@ fn convert_applgrid( _: &Path, _: u32, _: &mut [Pdf], - _: i32, _: usize, ) -> Result<(&'static str, Grid, Vec, usize)> { Err(anyhow!( @@ -134,14 +132,14 @@ fn convert_fastnlo( } #[cfg(feature = "fktable")] -fn convert_fktable(input: &Path, dis_pid: i32) -> Result<(&'static str, Grid, Vec, usize)> { - let fktable = fktable::convert_fktable(input, dis_pid)?; +fn convert_fktable(input: &Path) -> Result<(&'static str, Grid, Vec, usize)> { + let fktable = fktable::convert_fktable(input)?; Ok(("fktable", fktable, vec![], 1)) } #[cfg(not(feature = "fktable"))] -fn convert_fktable(_: &Path, _: i32) -> Result<(&'static str, Grid, Vec, usize)> { +fn convert_fktable(_: &Path) -> Result<(&'static str, Grid, Vec, usize)> { Err(anyhow!( "you need to install `pineappl` with feature `fktable`" )) @@ -170,9 +168,9 @@ fn convert_grid( input, alpha, fun_names, member, dis_pid, scales, fnlo_mur, fnlo_muf, ); } else if extension == "dat" { - return convert_fktable(input, dis_pid); + return convert_fktable(input); } else if extension == "appl" || extension == "root" { - return convert_applgrid(input, alpha, conv_funs, dis_pid, scales); + return convert_applgrid(input, alpha, conv_funs, scales); } } diff --git a/pineappl_cli/src/import/applgrid.rs b/pineappl_cli/src/import/applgrid.rs index 53b5a076..a876775c 100644 --- a/pineappl_cli/src/import/applgrid.rs +++ b/pineappl_cli/src/import/applgrid.rs @@ -11,7 +11,7 @@ use pineappl::subgrid::{Mu2, NodeValues}; use pineappl_applgrid::ffi::{self, grid}; use std::f64::consts::TAU; use std::pin::Pin; -use std::ptr; +use std::{iter, ptr}; fn convert_to_pdg_id(pid: usize) -> i32 { let pid = i32::try_from(pid).unwrap() - 6; @@ -24,7 +24,7 @@ fn convert_to_pdg_id(pid: usize) -> i32 { } } -fn reconstruct_channels(grid: &grid, order: i32, dis_pid: i32) -> Vec { +fn reconstruct_channels(grid: &grid, order: i32) -> Vec { let pdf = unsafe { &*grid.genpdf(order, false) }; let nproc: usize = pdf.Nproc().try_into().unwrap(); @@ -43,7 +43,7 @@ fn reconstruct_channels(grid: &grid, order: i32, dis_pid: i32) -> Vec { for i in 0..nproc { if results[i] != 0.0 { - channels[i].push((vec![convert_to_pdg_id(a), dis_pid], results[i])); + channels[i].push((vec![convert_to_pdg_id(a)], results[i])); } } } else { @@ -71,7 +71,7 @@ fn reconstruct_channels(grid: &grid, order: i32, dis_pid: i32) -> Vec { channels.into_iter().map(Channel::new).collect() } -pub fn convert_applgrid(grid: Pin<&mut grid>, alpha: u32, dis_pid: i32) -> Result { +pub fn convert_applgrid(grid: Pin<&mut grid>, alpha: u32) -> Result { let bin_limits: Vec<_> = (0..=grid.Nobs_internal()) .map(|i| grid.obslow_internal(i)) .collect(); @@ -125,14 +125,31 @@ pub fn convert_applgrid(grid: Pin<&mut grid>, alpha: u32, dis_pid: i32) -> Resul let mut grids = Vec::with_capacity(orders.len()); // from APPLgrid alone we don't know what type of convolution we have - let mut convolutions = vec![Convolution::UnpolPDF(2212); 2]; - - if grid.isDIS() { - convolutions[1] = Convolution::None; + let convolutions = vec![Convolution::UnpolPDF(2212); if grid.isDIS() { 1 } else { 2 }]; + // TODO: read out interpolation parameters from APPLgrid + let mut interps = vec![Interp::new( + 1e2, + 1e8, + 40, + 3, + ReweightMeth::NoReweight, + Map::ApplGridH0, + InterpMeth::Lagrange, + )]; + for _ in 0..convolutions.len() { + interps.push(Interp::new( + 2e-7, + 1.0, + 50, + 3, + ReweightMeth::ApplGridX, + Map::ApplGridF2, + InterpMeth::Lagrange, + )); } for (i, order) in orders.into_iter().enumerate() { - let channels = reconstruct_channels(&grid, i.try_into().unwrap(), dis_pid); + let channels = reconstruct_channels(&grid, i.try_into().unwrap()); let lumis_len = channels.len(); let mut pgrid = Grid::new( PidBasis::Pdg, @@ -140,38 +157,10 @@ pub fn convert_applgrid(grid: Pin<&mut grid>, alpha: u32, dis_pid: i32) -> Resul vec![order], bin_limits.clone(), convolutions.clone(), - // TODO: read out interpolation parameters from APPLgrid - vec![ - Interp::new( - 1e2, - 1e8, - 40, - 3, - ReweightMeth::NoReweight, - Map::ApplGridH0, - InterpMeth::Lagrange, - ), - Interp::new( - 2e-7, - 1.0, - 50, - 3, - ReweightMeth::ApplGridX, - Map::ApplGridF2, - InterpMeth::Lagrange, - ), - Interp::new( - 2e-7, - 1.0, - 50, - 3, - ReweightMeth::ApplGridX, - Map::ApplGridF2, - InterpMeth::Lagrange, - ), - ], - // TODO: change kinematics for DIS - vec![Kinematics::Scale(0), Kinematics::X1, Kinematics::X2], + interps.clone(), + iter::once(Kinematics::Scale(0)) + .chain((0..convolutions.len()).map(|idx| Kinematics::X(idx))) + .collect(), Scales { ren: ScaleFuncForm::Scale(0), fac: ScaleFuncForm::Scale(0), diff --git a/pineappl_cli/src/import/fastnlo.rs b/pineappl_cli/src/import/fastnlo.rs index 708efefc..34d14fab 100644 --- a/pineappl_cli/src/import/fastnlo.rs +++ b/pineappl_cli/src/import/fastnlo.rs @@ -104,16 +104,8 @@ fn convert_coeff_add_fix( let npdf = usize::try_from(table_as_add_base.GetNPDF()).unwrap(); assert!(npdf <= 2); - let convolutions = (0..2) - .map(|index| { - if index < npdf { - // TODO: how do we determined the PID/type of the convolution for fixed tables? - Convolution::UnpolPDF(2212) - } else { - Convolution::None - } - }) - .collect(); + // TODO: extract the proper convolution PIDs + let convolutions = vec![Convolution::UnpolPDF(2212); npdf]; let mut grid = Grid::new( PidBasis::Pdg, diff --git a/pineappl_cli/src/import/fktable.rs b/pineappl_cli/src/import/fktable.rs index c1b2d747..46cf6b98 100644 --- a/pineappl_cli/src/import/fktable.rs +++ b/pineappl_cli/src/import/fktable.rs @@ -1,7 +1,7 @@ use anyhow::{anyhow, Context, Result}; use flate2::read::GzDecoder; use ndarray::s; -use pineappl::boc::{Kinematics, Order, ScaleFuncForm, Scales}; +use pineappl::boc::{Channel, Kinematics, Order, ScaleFuncForm, Scales}; use pineappl::channel; use pineappl::convolutions::Convolution; use pineappl::grid::Grid; @@ -28,7 +28,7 @@ enum FkTableSection { FastKernel, } -fn read_fktable(reader: impl BufRead, dis_pid: i32) -> Result { +fn read_fktable(reader: impl BufRead) -> Result { let mut section = FkTableSection::Sof; let mut flavor_mask = Vec::::new(); let mut x_grid = Vec::new(); @@ -94,7 +94,7 @@ fn read_fktable(reader: impl BufRead, dis_pid: i32) -> Result { .iter() .enumerate() .filter(|&(_, &value)| value) - .map(|(index, _)| channel![basis[index], dis_pid, 1.0]) + .map(|(index, _)| Channel::new(vec![(vec![basis[index]], 1.0)])) .collect() }; @@ -105,14 +105,11 @@ fn read_fktable(reader: impl BufRead, dis_pid: i32) -> Result { vec![Order::new(0, 0, 0, 0, 0)], (0..=ndata).map(Into::into).collect(), // legacy FK-tables only support unpolarized proton PDFs - vec![ - Convolution::UnpolPDF(2212), - if hadronic { - Convolution::UnpolPDF(2212) - } else { - Convolution::None - }, - ], + if hadronic { + vec![Convolution::UnpolPDF(2212); 2] + } else { + vec![Convolution::UnpolPDF(2212)] + }, // TODO: what are sensible parameters for FK-tables? vec![ Interp::new( @@ -281,11 +278,18 @@ fn read_fktable(reader: impl BufRead, dis_pid: i32) -> Result { { *subgrid = PackedQ1X2SubgridV1::new( array, - vec![ - NodeValues::UseThese(vec![q0 * q0]), - NodeValues::UseThese(x_grid.clone()), - NodeValues::UseThese(if hadronic { x_grid.clone() } else { vec![1.0] }), - ], + if hadronic { + vec![ + NodeValues::UseThese(vec![q0 * q0]), + NodeValues::UseThese(x_grid.clone()), + NodeValues::UseThese(x_grid.clone()), + ] + } else { + vec![ + NodeValues::UseThese(vec![q0 * q0]), + NodeValues::UseThese(x_grid.clone()), + ] + }, ) .into(); } @@ -293,7 +297,7 @@ fn read_fktable(reader: impl BufRead, dis_pid: i32) -> Result { Ok(grid) } -pub fn convert_fktable(input: &Path, dis_pid: i32) -> Result { +pub fn convert_fktable(input: &Path) -> Result { let reader = GzDecoder::new(File::open(input)?); let mut archive = Archive::new(reader); @@ -304,7 +308,7 @@ pub fn convert_fktable(input: &Path, dis_pid: i32) -> Result { if let Some(extension) = path.extension() { if extension == "dat" { - return read_fktable(BufReader::new(file), dis_pid); + return read_fktable(BufReader::new(file)); } } } diff --git a/pineappl_cli/src/plot.rs b/pineappl_cli/src/plot.rs index 82fb44de..35ad37bc 100644 --- a/pineappl_cli/src/plot.rs +++ b/pineappl_cli/src/plot.rs @@ -6,7 +6,6 @@ use clap::{Parser, ValueHint}; use itertools::Itertools; use ndarray::Axis; use pineappl::boc::{Channel, Kinematics}; -use pineappl::convolutions::Convolution; use pineappl::grid::Grid; use pineappl::subgrid::Subgrid; use rayon::{prelude::*, ThreadPoolBuilder}; @@ -77,16 +76,8 @@ fn map_format_channel(channel: &Channel, grid: &Grid) -> String { .entry() .iter() .map(|(pids, _)| { - grid.convolutions() - .iter() - .zip(pids) - .map(|(convolution, &pid)| { - if *convolution == Convolution::None { - "" - } else { - grid.pid_basis().to_latex_str(pid) - } - }) + pids.iter() + .map(|&pid| grid.pid_basis().to_latex_str(pid)) .collect::>() .join("") }) diff --git a/pineappl_cli/tests/import.rs b/pineappl_cli/tests/import.rs index 871b951b..83a8d23f 100644 --- a/pineappl_cli/tests/import.rs +++ b/pineappl_cli/tests/import.rs @@ -675,7 +675,7 @@ fn import_flex_grid_15() { #[test] #[cfg(feature = "fktable")] fn import_dis_fktable() { - use ndarray::Array4; + use ndarray::Array3; use pineappl::fk_table::FkTable; use pineappl::grid::Grid; use std::fs::File; @@ -717,6 +717,7 @@ fn import_dis_fktable() { // TODO: this should ideally be a unit test, but we need an FK table that we don't convert + assert_eq!(fk_table.grid().kinematics().len(), 2); assert_eq!(fk_table.muf2(), 1.65 * 1.65); assert_eq!( fk_table.x_grid(), @@ -820,13 +821,14 @@ fn import_dis_fktable() { 0.8837966741980419, 0.9126417795942889, 0.9416284084927907, - 0.9707498946430192 + 0.9707498946430192, + 1.0 ] ); - let table: Array4 = fk_table.table().into_dimensionality().unwrap(); + let table: Array3 = fk_table.table().into_dimensionality().unwrap(); - assert_eq!(table.dim(), (20, 9, 100, 1)); + assert_eq!(table.dim(), (20, 9, 101)); assert_eq!( table .indexed_iter() @@ -834,16 +836,16 @@ fn import_dis_fktable() { .take(10) .collect::>(), [ - ((0, 0, 0, 0), &4.506605409085538e-8), - ((0, 0, 1, 0), &1.8561090273141668e-8), - ((0, 0, 2, 0), &-3.3821015317570252e-9), - ((0, 0, 3, 0), &1.980084314325426e-9), - ((0, 0, 4, 0), &2.187815687938248e-9), - ((0, 0, 5, 0), &1.3280152778522626e-9), - ((0, 0, 6, 0), &1.3848470515483116e-9), - ((0, 0, 7, 0), &1.5145898293299224e-9), - ((0, 0, 8, 0), &1.6942313031679552e-9), - ((0, 0, 9, 0), &1.9734220063025288e-9), + ((0, 0, 0), &4.506605409085538e-8), + ((0, 0, 1), &1.8561090273141668e-8), + ((0, 0, 2), &-3.3821015317570252e-9), + ((0, 0, 3), &1.980084314325426e-9), + ((0, 0, 4), &2.187815687938248e-9), + ((0, 0, 5), &1.3280152778522626e-9), + ((0, 0, 6), &1.3848470515483116e-9), + ((0, 0, 7), &1.5145898293299224e-9), + ((0, 0, 8), &1.6942313031679552e-9), + ((0, 0, 9), &1.9734220063025288e-9), ] ); }