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 Nov 1, 2024
1 parent 2020712 commit 7d1e3f5
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 70 deletions.
10 changes: 2 additions & 8 deletions pineappl/src/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ impl Grid {

cache.set_grids(self, subgrid, xi);

let node_values: Vec<_> = subgrid.node_values();
let node_values = subgrid.node_values();
// TODO: generalize this to N dimensions
assert_eq!(node_values.len(), 3);
let dim: Vec<_> = node_values.iter().map(Vec::len).collect();
Expand Down Expand Up @@ -1181,13 +1181,7 @@ impl Grid {
type Item = Vec<T::Item>;

fn next(&mut self) -> Option<Self::Item> {
let v: Vec<_> = self.iters.iter_mut().filter_map(Iterator::next).collect();

if v.len() == self.iters.len() {
Some(v)
} else {
None
}
self.iters.iter_mut().map(Iterator::next).collect()
}
}

Expand Down
2 changes: 1 addition & 1 deletion pineappl/src/interpolation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ impl Interp {
Self {
min: self.gety(range.start),
max: self.gety(range.end - 1),
nodes: range.clone().count(),
nodes: range.count(),
order: self.order,
reweight: self.reweight,
map: self.map,
Expand Down
5 changes: 1 addition & 4 deletions pineappl/src/subgrid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
use super::empty_subgrid::EmptySubgridV1;
use super::import_subgrid::ImportSubgridV1;
use super::interp_subgrid::InterpSubgridV1;
use enum_dispatch::enum_dispatch;
// use float_cmp::approx_eq;
// use ndarray::Array3;
// use super::evolution::EVOLVE_INFO_TOL_ULPS;
use super::interpolation::Interp;
use enum_dispatch::enum_dispatch;
use float_cmp::approx_eq;
use serde::{Deserialize, Serialize};

Expand Down
4 changes: 3 additions & 1 deletion pineappl/tests/drell_yan_lo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ fn int_photo(s: f64, t: f64, u: f64) -> f64 {
alpha0.powi(2) / 2.0 / s * (t / u + u / t)
}

// ALLOW: in this example we care more about readability than floating-point accuracy
#[allow(clippy::suboptimal_flops)]
// Eq. (2.12) - quark-antiquark contribution to DY lepton pair production
fn int_quark(s: f64, t: f64, u: f64, qq: f64, i3_wq: f64) -> f64 {
let alphagf: f64 = 1.0 / 132.30818655547878;
Expand Down Expand Up @@ -701,7 +703,7 @@ fn grid_optimize() {
grid.subgrids()[[0, 0, 0]],
SubgridEnum::InterpSubgridV1 { .. }
));
let node_values = dbg!(grid.subgrids()[[0, 0, 0]].node_values());
let node_values = grid.subgrids()[[0, 0, 0]].node_values();
assert_eq!(node_values[0].len(), 1);
assert_eq!(node_values[1].len(), 6);
assert_eq!(node_values[2].len(), 6);
Expand Down
75 changes: 22 additions & 53 deletions pineappl_cli/src/import/fastnlo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,59 +122,28 @@ fn convert_coeff_add_fix(
.collect(),
convolutions,
// TODO: read out interpolation parameters from fastNLO
if npdf == 2 {
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,
),
]
} else {
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,
),
]
},
// TODO: change kinematics for DIS
iter::once(Interp::new(
1e2,
1e8,
40,
3,
ReweightMeth::NoReweight,
Map::ApplGridH0,
InterpMeth::Lagrange,
))
.chain(
iter::repeat(Interp::new(
2e-7,
1.0,
50,
3,
ReweightMeth::ApplGridX,
Map::ApplGridF2,
InterpMeth::Lagrange,
))
.take(npdf),
)
.collect(),
if npdf == 2 {
vec![Kinematics::Scale(0), Kinematics::X1, Kinematics::X2]
} else {
Expand Down
4 changes: 1 addition & 3 deletions pineappl_cli/src/import/fktable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,7 @@ fn read_fktable(reader: impl BufRead) -> Result<Grid> {
hadronic = match value {
"0" => false,
"1" => true,
_ => {
unimplemented!("hadronic value: '{value}' is not supported")
}
_ => unreachable!(),
}
}
"*NDATA:" => ndata = value.parse()?,
Expand Down

0 comments on commit 7d1e3f5

Please sign in to comment.