Skip to content

Commit

Permalink
Rename PackedQ1X2SubgridV1 to ImportSubgridV1
Browse files Browse the repository at this point in the history
  • Loading branch information
t7phy committed Oct 17, 2024
1 parent c134c7e commit 9182bdb
Show file tree
Hide file tree
Showing 13 changed files with 245 additions and 245 deletions.
4 changes: 2 additions & 2 deletions pineappl/src/empty_subgrid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl Subgrid for EmptySubgridV1 {
mod tests {
use super::*;
use crate::packed_array::PackedArray;
use crate::packed_subgrid::PackedQ1X2SubgridV1;
use crate::import_subgrid::ImportSubgridV1;
use crate::v0;

#[test]
Expand Down Expand Up @@ -96,7 +96,7 @@ mod tests {
let mut array = PackedArray::new(vec![1, 1]);
array[0] = 1.0;
let node_values = vec![NodeValues::UseThese(vec![1.0]); 2];
let subgrid_rhs = PackedQ1X2SubgridV1::new(array, node_values).into();
let subgrid_rhs = ImportSubgridV1::new(array, node_values).into();

subgrid_lhs.merge(&subgrid_rhs, None);
}
Expand Down
4 changes: 2 additions & 2 deletions pineappl/src/evolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::boc::{Channel, Kinematics, Order};
use super::convolutions::ConvType;
use super::grid::{Grid, GridError};
use super::packed_array::PackedArray;
use super::packed_subgrid::PackedQ1X2SubgridV1;
use super::import_subgrid::ImportSubgridV1;
use super::pids::PidBasis;
use super::subgrid::{NodeValues, Subgrid, SubgridEnum};
use float_cmp::approx_eq;
Expand Down Expand Up @@ -489,7 +489,7 @@ pub(crate) fn evolve_slice_with_many(
}

sub_fk_tables.extend(tables.into_iter().map(|table| {
PackedQ1X2SubgridV1::new(
ImportSubgridV1::new(
PackedArray::from(table.insert_axis(Axis(0)).view()),
node_values.clone(),
)
Expand Down
4 changes: 2 additions & 2 deletions pineappl/src/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use super::evolution::{self, AlphasTable, EvolveInfo, OperatorSliceInfo};
use super::fk_table::FkTable;
use super::interpolation::Interp;
use super::interp_subgrid::InterpSubgridV1;
use super::packed_subgrid::PackedQ1X2SubgridV1;
use super::import_subgrid::ImportSubgridV1;
use super::pids::PidBasis;
use super::subgrid::{NodeValues, Subgrid, SubgridEnum};
use super::v0;
Expand Down Expand Up @@ -884,7 +884,7 @@ impl Grid {
}
}

*subgrid = PackedQ1X2SubgridV1::from(&*subgrid).into();
*subgrid = ImportSubgridV1::from(&*subgrid).into();
}
}
}
Expand Down
22 changes: 11 additions & 11 deletions pineappl/src/packed_subgrid.rs → pineappl/src/import_subgrid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ use std::mem;

/// TODO
#[derive(Clone, Deserialize, Serialize)]
pub struct PackedQ1X2SubgridV1 {
pub struct ImportSubgridV1 {
array: PackedArray<f64>,
node_values: Vec<NodeValues>,
}

impl PackedQ1X2SubgridV1 {
impl ImportSubgridV1 {
/// Constructor.
#[must_use]
pub const fn new(array: PackedArray<f64>, node_values: Vec<NodeValues>) -> Self {
Self { array, node_values }
}
}

impl Subgrid for PackedQ1X2SubgridV1 {
impl Subgrid for ImportSubgridV1 {
fn fill(&mut self, _: &[Interp], _: &[f64], _: f64) {
panic!("PackedQ1X2SubgridV1 doesn't support the fill operation");
panic!("ImportSubgridV1 doesn't support the fill operation");
}

fn node_values(&self) -> Vec<NodeValues> {
Expand Down Expand Up @@ -121,7 +121,7 @@ impl Subgrid for PackedQ1X2SubgridV1 {
}
}

impl From<&SubgridEnum> for PackedQ1X2SubgridV1 {
impl From<&SubgridEnum> for ImportSubgridV1 {
fn from(subgrid: &SubgridEnum) -> Self {
// find smallest ranges
let ranges: Vec<_> = subgrid.indexed_iter().fold(
Expand Down Expand Up @@ -185,9 +185,9 @@ mod tests {
use crate::v0;

#[test]
#[should_panic(expected = "PackedQ1X2SubgridV1 doesn't support the fill operation")]
#[should_panic(expected = "ImportSubgridV1 doesn't support the fill operation")]
fn fill_packed_q1x2_subgrid_v1() {
let mut subgrid = PackedQ1X2SubgridV1::new(
let mut subgrid = ImportSubgridV1::new(
PackedArray::new(vec![0, 0, 0]),
vec![NodeValues::UseThese(Vec::new()); 3],
);
Expand All @@ -199,7 +199,7 @@ mod tests {
let x = vec![
0.015625, 0.03125, 0.0625, 0.125, 0.1875, 0.25, 0.375, 0.5, 0.75, 1.0,
];
let mut grid1: SubgridEnum = PackedQ1X2SubgridV1::new(
let mut grid1: SubgridEnum = ImportSubgridV1::new(
PackedArray::new(vec![1, 10, 10]),
vec![
NodeValues::UseThese(vec![0.0]),
Expand All @@ -221,7 +221,7 @@ mod tests {
assert!(grid1.is_empty());

// only use exactly representable numbers here so that we can avoid using approx_eq
if let SubgridEnum::PackedQ1X2SubgridV1(ref mut x) = grid1 {
if let SubgridEnum::ImportSubgridV1(ref mut x) = grid1 {
x.array[[0, 1, 2]] = 1.0;
x.array[[0, 1, 3]] = 2.0;
x.array[[0, 4, 3]] = 4.0;
Expand All @@ -236,7 +236,7 @@ mod tests {
assert_eq!(grid1.indexed_iter().nth(3), Some((vec![0, 7, 1], 8.0)));

// create grid with transposed entries, but different q2
let mut grid2: SubgridEnum = PackedQ1X2SubgridV1::new(
let mut grid2: SubgridEnum = ImportSubgridV1::new(
PackedArray::new(vec![1, 10, 10]),
vec![
NodeValues::UseThese(vec![1.0]),
Expand All @@ -245,7 +245,7 @@ mod tests {
],
)
.into();
if let SubgridEnum::PackedQ1X2SubgridV1(ref mut x) = grid2 {
if let SubgridEnum::ImportSubgridV1(ref mut x) = grid2 {
x.array[[0, 2, 1]] = 1.0;
x.array[[0, 3, 1]] = 2.0;
x.array[[0, 3, 4]] = 4.0;
Expand Down
2 changes: 1 addition & 1 deletion pineappl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ pub mod grid;
pub mod interpolation;
pub mod interp_subgrid;
pub mod packed_array;
pub mod packed_subgrid;
pub mod import_subgrid;
pub mod pids;
pub mod subgrid;
4 changes: 2 additions & 2 deletions pineappl/src/subgrid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use super::empty_subgrid::EmptySubgridV1;
use super::interp_subgrid::InterpSubgridV1;
use super::packed_subgrid::PackedQ1X2SubgridV1;
use super::import_subgrid::ImportSubgridV1;
use enum_dispatch::enum_dispatch;
// use float_cmp::approx_eq;
// use ndarray::Array3;
Expand Down Expand Up @@ -99,7 +99,7 @@ pub enum SubgridEnum {
/// Empty subgrid.
EmptySubgridV1,
/// TODO
PackedQ1X2SubgridV1,
ImportSubgridV1,
}

/// Structure denoting renormalization and factorization scale values.
Expand Down
4 changes: 2 additions & 2 deletions pineappl/src/v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use super::empty_subgrid::EmptySubgridV1;
use super::grid::{Grid, GridError, Mmv4, MoreMembers};
use super::interpolation::{Interp, InterpMeth, Map, ReweightMeth};
use super::packed_array::PackedArray;
use super::packed_subgrid::PackedQ1X2SubgridV1;
use super::import_subgrid::ImportSubgridV1;
use super::pids::PidBasis;
use super::subgrid::{Mu2, NodeValues};
use ndarray::Array3;
Expand Down Expand Up @@ -104,7 +104,7 @@ pub fn read_uncompressed_v0(mut reader: impl BufRead) -> Result<Grid, GridError>
if convolutions[1].is_some() {
node_values.push(NodeValues::UseThese(subgrid.x2_grid().into_owned()));
}
PackedQ1X2SubgridV1::new(array, node_values).into()
ImportSubgridV1::new(array, node_values).into()
}
})
.collect(),
Expand Down
4 changes: 2 additions & 2 deletions pineappl/tests/drell_yan_lo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ fn grid_optimize() {
// `OPTIMIZE_SUBGRID_TYPE` changes the subgrid type ...
assert!(matches!(
grid2.subgrids()[[0, 0, 0]],
SubgridEnum::PackedQ1X2SubgridV1 { .. }
SubgridEnum::ImportSubgridV1 { .. }
));
// and the dimensions of the subgrid
let node_values = grid2.subgrids()[[0, 0, 0]].node_values();
Expand All @@ -713,7 +713,7 @@ fn grid_optimize() {

assert!(matches!(
grid.subgrids()[[0, 0, 0]],
SubgridEnum::PackedQ1X2SubgridV1 { .. }
SubgridEnum::ImportSubgridV1 { .. }
));
// if `STATIC_SCALE_DETECTION` is present the scale dimension is better optimized
let node_values = grid.subgrids()[[0, 0, 0]].node_values();
Expand Down
4 changes: 2 additions & 2 deletions pineappl_cli/src/import/applgrid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use pineappl::convolutions::{Conv, ConvType};
use pineappl::grid::Grid;
use pineappl::interpolation::{Interp, InterpMeth, Map, ReweightMeth};
use pineappl::packed_array::PackedArray;
use pineappl::packed_subgrid::PackedQ1X2SubgridV1;
use pineappl::import_subgrid::ImportSubgridV1;
use pineappl::pids::PidBasis;
use pineappl::subgrid::{Mu2, NodeValues};
use pineappl_applgrid::ffi::{self, grid};
Expand Down Expand Up @@ -235,7 +235,7 @@ pub fn convert_applgrid(grid: Pin<&mut grid>, alpha: u32) -> Result<Grid> {

if !array.is_empty() {
pgrid.subgrids_mut()[[0, bin.try_into().unwrap(), lumi]] =
PackedQ1X2SubgridV1::new(
ImportSubgridV1::new(
array,
vec![
NodeValues::UseThese(
Expand Down
6 changes: 3 additions & 3 deletions pineappl_cli/src/import/fastnlo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use pineappl::convolutions::{Conv, ConvType};
use pineappl::grid::Grid;
use pineappl::interpolation::{Interp, InterpMeth, Map, ReweightMeth};
use pineappl::packed_array::PackedArray;
use pineappl::packed_subgrid::PackedQ1X2SubgridV1;
use pineappl::import_subgrid::ImportSubgridV1;
use pineappl::pids::PidBasis;
use pineappl::subgrid::{Mu2, NodeValues};
use pineappl_fastnlo::ffi::{
Expand Down Expand Up @@ -263,7 +263,7 @@ fn convert_coeff_add_fix(
if !array.is_empty() {
grid.subgrids_mut()
[[0, obs.try_into().unwrap(), subproc.try_into().unwrap()]] =
PackedQ1X2SubgridV1::new(
ImportSubgridV1::new(
array,
vec![
NodeValues::UseThese(
Expand Down Expand Up @@ -475,7 +475,7 @@ fn convert_coeff_add_flex(
// continue;
// }

// *subgrid = PackedQ1X2SubgridV1::new(array, todo!()).into();
// *subgrid = ImportSubgridV1::new(array, todo!()).into();
// }
// }
// }
Expand Down
6 changes: 3 additions & 3 deletions pineappl_cli/src/import/fktable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use pineappl::convolutions::{Conv, ConvType};
use pineappl::grid::Grid;
use pineappl::interpolation::{Interp, InterpMeth, Map, ReweightMeth};
use pineappl::packed_array::PackedArray;
use pineappl::packed_subgrid::PackedQ1X2SubgridV1;
use pineappl::import_subgrid::ImportSubgridV1;
use pineappl::pids::PidBasis;
use pineappl::subgrid::NodeValues;
use std::fs::File;
Expand Down Expand Up @@ -246,7 +246,7 @@ fn read_fktable(reader: impl BufRead) -> Result<Grid> {
.iter_mut()
.zip(arrays.into_iter())
{
*subgrid = PackedQ1X2SubgridV1::new(
*subgrid = ImportSubgridV1::new(
array,
if hadronic {
vec![
Expand Down Expand Up @@ -318,7 +318,7 @@ fn read_fktable(reader: impl BufRead) -> Result<Grid> {
.iter_mut()
.zip(arrays.into_iter())
{
*subgrid = PackedQ1X2SubgridV1::new(
*subgrid = ImportSubgridV1::new(
array,
if hadronic {
vec![
Expand Down
2 changes: 1 addition & 1 deletion pineappl_cli/src/subgrids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl Subcommand for Opts {
match subgrid {
SubgridEnum::InterpSubgridV1(_) => "InterpSubgridV1",
SubgridEnum::EmptySubgridV1(_) => "EmptySubgridV1",
SubgridEnum::PackedQ1X2SubgridV1(_) => "PackedQ1X2SubgridV1",
SubgridEnum::ImportSubgridV1(_) => "ImportSubgridV1",
}
));
}
Expand Down
Loading

0 comments on commit 9182bdb

Please sign in to comment.