Skip to content

Commit

Permalink
Use convolve instead of convolute in CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
cschwan committed Apr 16, 2024
1 parent 22b0eff commit a824508
Show file tree
Hide file tree
Showing 20 changed files with 95 additions and 89 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- changed the official name of the CLI subcommand `convolute` to `convolve`,
because the latter is the proper verb of 'convolution'. The old name
`convolute` is now an alias of `convolve`, which means both can be used. The
methods `Grid::convolute*` are left unchanged and will be renamed in later
version
- changed switch `--silence-lhapdf` to `--lhapdf-banner` and suppress LHAPDF's
banners by default, unless `--lhapdf-banner` is given
- `Grid::evolve` has now been marked deprecated
Expand Down
6 changes: 3 additions & 3 deletions pineappl_cli/src/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ impl Subcommand for CkfOpts {
};

let limit = grid.lumi().len().min(self.limit);
let limits = helpers::convolute_limits(&grid, &[], ConvoluteMode::Normal);
let limits = helpers::convolve_limits(&grid, &[], ConvoluteMode::Normal);
let results: Vec<_> = (0..grid.lumi().len())
.map(|lumi| {
let mut lumi_mask = vec![false; grid.lumi().len()];
lumi_mask[lumi] = true;
helpers::convolute(
helpers::convolve(
&grid,
&mut pdf,
&[self.order],
Expand All @@ -101,7 +101,7 @@ impl Subcommand for CkfOpts {
.map(|lumi| {
let mut lumi_mask = vec![false; grid.lumi().len()];
lumi_mask[lumi] = true;
helpers::convolute(
helpers::convolve(
&grid,
&mut pdf,
&orders_den,
Expand Down
4 changes: 2 additions & 2 deletions pineappl_cli/src/channels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl Subcommand for Opts {
} else {
limit.min(lumis.len())
};
let limits = helpers::convolute_limits(
let limits = helpers::convolve_limits(
&grid,
&[],
if self.integrated {
Expand All @@ -87,7 +87,7 @@ impl Subcommand for Opts {
.map(|lumi| {
let mut lumi_mask = vec![false; grid.lumi().len()];
lumi_mask[lumi] = true;
helpers::convolute(
helpers::convolve(
&grid,
&mut pdf,
&self.orders,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::process::ExitCode;

/// Convolutes a PineAPPL grid with a PDF set.
#[derive(Parser)]
#[command(alias = "convolute")]
pub struct Opts {
/// Path of the input grid.
#[arg(value_hint = ValueHint::FilePath)]
Expand Down Expand Up @@ -51,7 +52,7 @@ impl Subcommand for Opts {
let mut pdf = helpers::create_pdf(&self.pdfsets[0])?;
let bins: Vec<_> = self.bins.iter().cloned().flatten().collect();

let results = helpers::convolute(
let results = helpers::convolve(
&grid,
&mut pdf,
&self.orders,
Expand All @@ -65,7 +66,7 @@ impl Subcommand for Opts {
},
cfg,
);
let limits = helpers::convolute_limits(
let limits = helpers::convolve_limits(
&grid,
&bins,
if self.integrated {
Expand All @@ -80,7 +81,7 @@ impl Subcommand for Opts {
.iter()
.flat_map(|pdfset| {
let mut pdf = helpers::create_pdf(pdfset).unwrap();
helpers::convolute(
helpers::convolve(
&grid,
&mut pdf,
&self.orders,
Expand Down
10 changes: 5 additions & 5 deletions pineappl_cli/src/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl Subcommand for Opts {
title.add_cell(cell);
}

let limits1 = helpers::convolute_limits(&grid1, &[], ConvoluteMode::Normal);
let limits1 = helpers::convolve_limits(&grid1, &[], ConvoluteMode::Normal);

if self.ignore_orders {
let mut cell = cell!(c->"diff");
Expand All @@ -146,7 +146,7 @@ impl Subcommand for Opts {

table.set_titles(title);

let results1 = helpers::convolute(
let results1 = helpers::convolve(
&grid1,
&mut pdf,
&orders1,
Expand All @@ -156,7 +156,7 @@ impl Subcommand for Opts {
ConvoluteMode::Normal,
cfg,
);
let results2 = helpers::convolute(
let results2 = helpers::convolve(
&grid2,
&mut pdf,
&orders2,
Expand Down Expand Up @@ -202,7 +202,7 @@ impl Subcommand for Opts {
let order_results1: Vec<Vec<f64>> = orders
.iter()
.map(|&order| {
helpers::convolute(
helpers::convolve(
&grid1,
&mut pdf,
&[order],
Expand All @@ -217,7 +217,7 @@ impl Subcommand for Opts {
let order_results2: Vec<Vec<f64>> = orders
.iter()
.map(|&order| {
helpers::convolute(
helpers::convolve(
&grid2,
&mut pdf,
&[order],
Expand Down
4 changes: 2 additions & 2 deletions pineappl_cli/src/evolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ impl Subcommand for Opts {

let grid = helpers::read_grid(&self.input)?;
let mut pdf = helpers::create_pdf(&self.pdfset)?;
let results = helpers::convolute_scales(
let results = helpers::convolve_scales(
&grid,
&mut pdf,
&self.orders,
Expand All @@ -563,7 +563,7 @@ impl Subcommand for Opts {
self.xif,
self.use_old_evolve,
)?;
let evolved_results = helpers::convolute_scales(
let evolved_results = helpers::convolve_scales(
fk_table.grid(),
&mut pdf,
&[],
Expand Down
2 changes: 1 addition & 1 deletion pineappl_cli/src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl Subcommand for Opts {
println!("file was converted, but we cannot check the conversion for this type");
} else {
let mut pdf = helpers::create_pdf(&self.pdfset)?;
let reference_results = helpers::convolute(
let reference_results = helpers::convolve(
&grid,
&mut pdf,
&orders,
Expand Down
10 changes: 5 additions & 5 deletions pineappl_cli/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pub enum ConvoluteMode {
Normal,
}

pub fn convolute_scales(
pub fn convolve_scales(
grid: &Grid,
lhapdf: &mut Pdf,
orders: &[(u32, u32)],
Expand Down Expand Up @@ -210,7 +210,7 @@ pub fn convolute_scales(
}
}

pub fn convolute(
pub fn convolve(
grid: &Grid,
lhapdf: &mut Pdf,
orders: &[(u32, u32)],
Expand All @@ -220,7 +220,7 @@ pub fn convolute(
mode: ConvoluteMode,
cfg: &GlobalConfiguration,
) -> Vec<f64> {
convolute_scales(
convolve_scales(
grid,
lhapdf,
orders,
Expand All @@ -232,7 +232,7 @@ pub fn convolute(
)
}

pub fn convolute_limits(grid: &Grid, bins: &[usize], mode: ConvoluteMode) -> Vec<Vec<(f64, f64)>> {
pub fn convolve_limits(grid: &Grid, bins: &[usize], mode: ConvoluteMode) -> Vec<Vec<(f64, f64)>> {
let limits: Vec<_> = grid
.bin_info()
.limits()
Expand All @@ -247,7 +247,7 @@ pub fn convolute_limits(grid: &Grid, bins: &[usize], mode: ConvoluteMode) -> Vec
}
}

pub fn convolute_subgrid(
pub fn convolve_subgrid(
grid: &Grid,
lhapdf: &mut Pdf,
order: usize,
Expand Down
2 changes: 1 addition & 1 deletion pineappl_cli/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ impl Subcommand for Opts {
println!("file was converted, but we cannot check the conversion for this type");
} else {
let mut pdf = helpers::create_pdf(&self.pdfset)?;
let results = helpers::convolute(
let results = helpers::convolve(
&grid,
&mut pdf,
&[],
Expand Down
4 changes: 2 additions & 2 deletions pineappl_cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

mod analyze;
mod channels;
mod convolute;
mod convolve;
mod diff;
mod evolve;
mod export;
Expand Down Expand Up @@ -50,7 +50,7 @@ pub trait Subcommand {
pub enum SubcommandEnum {
Analyze(analyze::Opts),
Channels(channels::Opts),
Convolute(convolute::Opts),
Convolve(convolve::Opts),
Diff(diff::Opts),
Evolve(evolve::Opts),
Export(export::Opts),
Expand Down
4 changes: 2 additions & 2 deletions pineappl_cli/src/orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl Subcommand for Opts {
orders.sort();
let orders = orders;

let limits = helpers::convolute_limits(
let limits = helpers::convolve_limits(
&grid,
&[],
if self.integrated {
Expand All @@ -64,7 +64,7 @@ impl Subcommand for Opts {
let results: Vec<Vec<f64>> = orders
.iter()
.map(|order| {
helpers::convolute(
helpers::convolve(
&grid,
&mut pdf,
&[(order.alphas, order.alpha)],
Expand Down
20 changes: 10 additions & 10 deletions pineappl_cli/src/plot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ impl Subcommand for Opts {
let bins: Vec<_> = (slice.0..slice.1).collect();

let results =
helpers::convolute(&grid, &mut pdf, &[], &bins, &[], self.scales, mode, cfg);
helpers::convolve(&grid, &mut pdf, &[], &bins, &[], self.scales, mode, cfg);

let qcd_results = {
let mut orders = grid.orders().to_vec();
Expand All @@ -235,7 +235,7 @@ impl Subcommand for Opts {
})
.collect();

helpers::convolute(
helpers::convolve(
&grid,
&mut pdf,
&qcd_orders,
Expand All @@ -247,7 +247,7 @@ impl Subcommand for Opts {
)
};

let bin_limits: Vec<_> = helpers::convolute_limits(&grid, &bins, mode)
let bin_limits: Vec<_> = helpers::convolve_limits(&grid, &bins, mode)
.into_iter()
.map(|limits| limits.last().copied().unwrap())
.collect();
Expand All @@ -270,7 +270,7 @@ impl Subcommand for Opts {
let mut pdf = helpers::create_pdf(pdfset).unwrap();

let results =
helpers::convolute(&grid, &mut pdf, &[], &bins, &[], 1, mode, cfg);
helpers::convolve(&grid, &mut pdf, &[], &bins, &[], 1, mode, cfg);

Ok(vec![results; 3])
} else {
Expand All @@ -280,7 +280,7 @@ impl Subcommand for Opts {
.mk_pdfs()?
.into_par_iter()
.flat_map(|mut pdf| {
helpers::convolute(
helpers::convolve(
&grid,
&mut pdf,
&[],
Expand Down Expand Up @@ -379,7 +379,7 @@ impl Subcommand for Opts {
grid.has_pdf1(),
grid.has_pdf2(),
),
helpers::convolute(
helpers::convolve(
&grid,
&mut pdf,
&[],
Expand Down Expand Up @@ -523,7 +523,7 @@ impl Subcommand for Opts {
let values1: Vec<_> = pdfset1
.par_iter_mut()
.map(|pdf| {
let values = helpers::convolute(
let values = helpers::convolve(
&grid,
pdf,
&[],
Expand All @@ -540,7 +540,7 @@ impl Subcommand for Opts {
let values2: Vec<_> = pdfset2
.par_iter_mut()
.map(|pdf| {
let values = helpers::convolute(
let values = helpers::convolve(
&grid,
pdf,
&[],
Expand Down Expand Up @@ -576,9 +576,9 @@ impl Subcommand for Opts {
unc1.hypot(unc2)
};

let res1 = helpers::convolute_subgrid(&grid, &mut pdfset1[0], order, bin, lumi, cfg)
let res1 = helpers::convolve_subgrid(&grid, &mut pdfset1[0], order, bin, lumi, cfg)
.sum_axis(Axis(0));
let res2 = helpers::convolute_subgrid(&grid, &mut pdfset2[0], order, bin, lumi, cfg)
let res2 = helpers::convolve_subgrid(&grid, &mut pdfset2[0], order, bin, lumi, cfg)
.sum_axis(Axis(0));

let subgrid = grid.subgrid(order, bin, lumi);
Expand Down
10 changes: 5 additions & 5 deletions pineappl_cli/src/pull.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ impl Subcommand for Opts {
.unwrap();

let limit = grid.lumi().len().min(self.limit);
let bin_limits = helpers::convolute_limits(&grid, &[], ConvoluteMode::Normal);
let bin_limits = helpers::convolve_limits(&grid, &[], ConvoluteMode::Normal);
let results1: Vec<_> = pdfset1
.par_iter_mut()
.flat_map(|pdf| {
helpers::convolute(
helpers::convolve(
&grid,
pdf,
&self.orders,
Expand All @@ -81,7 +81,7 @@ impl Subcommand for Opts {
let results2: Vec<_> = pdfset2
.par_iter_mut()
.flat_map(|pdf| {
helpers::convolute(
helpers::convolve(
&grid,
pdf,
&self.orders,
Expand Down Expand Up @@ -147,7 +147,7 @@ impl Subcommand for Opts {
.map(|lumi| {
let mut lumi_mask = vec![false; grid.lumi().len()];
lumi_mask[lumi] = true;
match helpers::convolute(
match helpers::convolve(
&grid,
&mut pdfset[member],
&self.orders,
Expand All @@ -172,7 +172,7 @@ impl Subcommand for Opts {
.map(|lumi| {
let mut lumi_mask = vec![false; grid.lumi().len()];
lumi_mask[lumi] = true;
match helpers::convolute(
match helpers::convolve(
&grid,
pdf,
&self.orders,
Expand Down
Loading

0 comments on commit a824508

Please sign in to comment.