Skip to content

Commit f872205

Browse files
committed
Remove Grid.convolve_subgrid from Python API
1 parent e39af43 commit f872205

File tree

2 files changed

+0
-97
lines changed

2 files changed

+0
-97
lines changed

pineappl_py/src/grid.rs

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -427,57 +427,6 @@ impl PyGrid {
427427
.into_pyarray_bound(py)
428428
}
429429

430-
/// Convolve a single subgrid `(order, bin, channel)` with the distributions.
431-
///
432-
/// # Panics
433-
/// TODO
434-
#[must_use]
435-
#[pyo3(signature = (pdg_convs, xfxs, alphas, ord, bin, channel, xi = None))]
436-
pub fn convolve_subgrid<'py>(
437-
&self,
438-
pdg_convs: Vec<PyRef<PyConv>>,
439-
xfxs: Vec<PyObject>,
440-
alphas: PyObject,
441-
ord: usize,
442-
bin: usize,
443-
channel: usize,
444-
xi: Option<(f64, f64, f64)>,
445-
py: Python<'py>,
446-
) -> Bound<'py, PyArrayDyn<f64>> {
447-
let mut alphas = |q2: f64| {
448-
let result: f64 = alphas.call1(py, (q2,)).unwrap().extract(py).unwrap();
449-
result
450-
};
451-
452-
let mut xfx_funcs: Vec<_> = xfxs
453-
.iter()
454-
.map(|xfx| {
455-
move |id: i32, x: f64, q2: f64| {
456-
xfx.call1(py, (id, x, q2)).unwrap().extract(py).unwrap()
457-
}
458-
})
459-
.collect();
460-
461-
let mut convolution_cache = ConvolutionCache::new(
462-
pdg_convs.into_iter().map(|pdg| pdg.conv.clone()).collect(),
463-
xfx_funcs
464-
.iter_mut()
465-
.map(|fx| fx as &mut dyn FnMut(i32, f64, f64) -> f64)
466-
.collect(),
467-
&mut alphas,
468-
);
469-
470-
self.grid
471-
.convolve_subgrid(
472-
&mut convolution_cache,
473-
ord,
474-
bin,
475-
channel,
476-
xi.unwrap_or((1.0, 1.0, 0.0)),
477-
)
478-
.into_pyarray_bound(py)
479-
}
480-
481430
/// Collect information for convolution with an evolution operator.
482431
///
483432
/// # Panics

pineappl_py/tests/test_grid.py

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -433,52 +433,6 @@ def test_polarized_convolution(
433433
expected_results,
434434
)
435435

436-
def test_convolve_subgrid(self, fake_grids):
437-
binning = [1e-2, 1e-1, 0.5, 1]
438-
g = fake_grids.grid_with_generic_convolution(
439-
nb_convolutions=2,
440-
channels=CHANNELS,
441-
orders=ORDERS,
442-
convolutions=[CONVOBJECT, CONVOBJECT],
443-
bins=binning,
444-
)
445-
446-
# Fill the grid with `fill_array`
447-
rndgen = Generator(PCG64(seed=1234))
448-
ntuples = [
449-
np.array([q2, x1, x2])
450-
for q2, x1, x2 in itertools.product(Q2GRID, XGRID, XGRID)
451-
]
452-
obs = [rndgen.uniform(binning[0], binning[-1]) for _ in ntuples]
453-
for pto in range(len(ORDERS)):
454-
for channel_id in range(len(CHANNELS)):
455-
g.fill_array(
456-
order=pto,
457-
observables=obs,
458-
channel=channel_id,
459-
ntuples=ntuples,
460-
weights=np.repeat(10, len(obs)),
461-
)
462-
463-
ptos_res = []
464-
for pto in range(len(g.orders())):
465-
res_by_bin = []
466-
for bin in range(g.bins()):
467-
res_by_channel = 0
468-
for channel in range(len(g.channels())):
469-
res_by_channel += g.convolve_subgrid(
470-
pdg_convs=[CONVOBJECT, CONVOBJECT],
471-
xfxs=[lambda pid, x, q2: x, lambda pid, x, q2: x],
472-
alphas=lambda q2: 1.0,
473-
ord=pto,
474-
bin=bin,
475-
channel=channel,
476-
).sum()
477-
res_by_bin.append(res_by_channel)
478-
ptos_res.append(res_by_bin)
479-
480-
np.testing.assert_allclose(ptos_res, [FILL_CONV_RESUTLS])
481-
482436
def test_many_convolutions(self, fake_grids, pdf, nb_convolutions: int = 3):
483437
"""Test for fun many convolutions."""
484438
expected_results = [

0 commit comments

Comments
 (0)