Skip to content

Commit

Permalink
Remove deprecated Grid::evolve method
Browse files Browse the repository at this point in the history
  • Loading branch information
cschwan committed Sep 1, 2024
1 parent 2c9ade2 commit ebf6770
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 117 deletions.
48 changes: 2 additions & 46 deletions pineappl/src/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::bin::{BinInfo, BinLimits, BinRemapper};
use super::boc::{Channel, Order};
use super::convolutions::{Convolution, LumiCache};
use super::empty_subgrid::EmptySubgridV1;
use super::evolution::{self, AlphasTable, EvolveInfo, OperatorInfo, OperatorSliceInfo};
use super::evolution::{self, AlphasTable, EvolveInfo, OperatorSliceInfo};
use super::fk_table::FkTable;
use super::lagrange_subgrid::LagrangeSubgridV2;
use super::packed_subgrid::PackedQ1X2SubgridV1;
Expand All @@ -15,7 +15,7 @@ use bitflags::bitflags;
use float_cmp::approx_eq;
use git_version::git_version;
use lz4_flex::frame::{FrameDecoder, FrameEncoder};
use ndarray::{s, Array3, ArrayView3, ArrayView5, ArrayViewMut3, Axis, CowArray, Dimension, Ix4};
use ndarray::{s, Array3, ArrayView3, ArrayViewMut3, Axis, CowArray, Dimension, Ix4};
use serde::{Deserialize, Serialize};
use std::borrow::Cow;
use std::collections::BTreeMap;
Expand Down Expand Up @@ -1137,50 +1137,6 @@ impl Grid {
}
}

/// Converts this `Grid` into an [`FkTable`] using an evolution kernel operator (EKO) given as
/// `operator`. The dimensions and properties of this operator must be described using `info`.
/// The parameter `order_mask` can be used to include or exclude orders from this operation,
/// and must correspond to the ordering given by [`Grid::orders`]. Orders that are not given
/// are enabled, and in particular if `order_mask` is empty all orders are activated.
///
/// # Errors
///
/// Returns a [`GridError::EvolutionFailure`] if either the `operator` or its `info` is
/// incompatible with this `Grid`.
#[deprecated(since = "0.7.4", note = "use evolve_with_slice_iter instead")]
pub fn evolve(
&self,
operator: ArrayView5<f64>,
info: &OperatorInfo,
order_mask: &[bool],
) -> Result<FkTable, GridError> {
self.evolve_with_slice_iter(
info.fac1
.iter()
.zip(operator.axis_iter(Axis(0)))
.map(|(&fac1, op)| {
Ok::<_, GridError>((
OperatorSliceInfo {
fac0: info.fac0,
pids0: info.pids0.clone(),
x0: info.x0.clone(),
fac1,
pids1: info.pids1.clone(),
x1: info.x1.clone(),
pid_basis: info.pid_basis,
},
CowArray::from(op),
))
}),
order_mask,
(info.xir, info.xif),
&AlphasTable {
ren1: info.ren1.clone(),
alphas: info.alphas.clone(),
},
)
}

// TODO:
// - try to find a better solution than to require that E must be convertible into
// anyhow::Error
Expand Down
65 changes: 14 additions & 51 deletions pineappl_cli/src/evolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,11 +429,9 @@ fn evolve_grid(
orders: &[(u32, u32)],
xir: f64,
xif: f64,
use_old_evolve: bool,
) -> Result<FkTable> {
use anyhow::bail;
use eko::EkoSlices;
use pineappl::evolution::{AlphasTable, OperatorInfo};
use pineappl::evolution::AlphasTable;

let order_mask: Vec<_> = grid
.orders()
Expand All @@ -452,51 +450,19 @@ fn evolve_grid(
.collect::<Result<_, _>>()?;
let alphas_table = AlphasTable::from_grid(grid, xir, &|q2| use_alphas_from.alphas_q2(q2));

if use_old_evolve {
assert_eq!(eko_slices.len(), 1);

if let EkoSlices::V0 {
fac1,
info,
operator,
} = eko_slices.remove(0)
{
let op_info = OperatorInfo {
fac0: info.fac0,
pids0: info.pids0.clone(),
x0: info.x0.clone(),
fac1,
pids1: info.pids1.clone(),
x1: info.x1.clone(),
ren1: alphas_table.ren1,
alphas: alphas_table.alphas,
xir,
xif,
pid_basis: info.pid_basis,
};

#[allow(deprecated)]
Ok(grid.evolve(operator.view(), &op_info, &order_mask)?)
} else {
bail!("`--use-old-evolve` can only be used with the old EKO format (`V0`)")
}
} else {
match eko_slices.as_mut_slice() {
[eko] => {
Ok(grid.evolve_with_slice_iter(eko, &order_mask, (xir, xif), &alphas_table)?)
}
[eko_a, eko_b] => Ok(grid.evolve_with_slice_iter2(
eko_a,
eko_b,
&order_mask,
(xir, xif),
&alphas_table,
)?),
_ => unimplemented!(
"evolution with {} EKOs is not implemented",
eko_slices.len()
),
}
match eko_slices.as_mut_slice() {
[eko] => Ok(grid.evolve_with_slice_iter(eko, &order_mask, (xir, xif), &alphas_table)?),
[eko_a, eko_b] => Ok(grid.evolve_with_slice_iter2(
eko_a,
eko_b,
&order_mask,
(xir, xif),
&alphas_table,
)?),
_ => unimplemented!(
"evolution with {} EKOs is not implemented",
eko_slices.len()
),
}
}

Expand Down Expand Up @@ -559,8 +525,6 @@ pub struct Opts {
/// Rescale the fragmentation scale with this factor.
#[arg(default_value_t = 1.0, long)]
xia: f64,
#[arg(hide = true, long)]
use_old_evolve: bool,
}

impl Subcommand for Opts {
Expand Down Expand Up @@ -590,7 +554,6 @@ impl Subcommand for Opts {
&self.orders,
self.xir,
self.xif,
self.use_old_evolve,
)?;

let evolved_results = helpers::convolve_scales(
Expand Down
20 changes: 0 additions & 20 deletions pineappl_cli/tests/evolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,26 +238,6 @@ fn lhcb_wp_7tev() {
.stdout(LHCB_WP_7TEV_OPTIMIZED_STR);
}

#[test]
fn lhcb_wp_7tev_use_old_evolve() {
let output = NamedTempFile::new("fktable1c.lz4").unwrap();

Command::cargo_bin("pineappl")
.unwrap()
.args([
"evolve",
"../test-data/LHCB_WP_7TEV_opt.pineappl.lz4",
"../test-data/LHCB_WP_7TEV.tar",
output.path().to_str().unwrap(),
"NNPDF40_nlo_as_01180",
"--orders=a2,as1a2",
"--use-old-evolve",
])
.assert()
.success()
.stdout(LHCB_WP_7TEV_STR);
}

#[test]
fn lhcb_wp_7tev_v2() {
let output = NamedTempFile::new("fktable2a.lz4").unwrap();
Expand Down

0 comments on commit ebf6770

Please sign in to comment.