Skip to content

Commit

Permalink
test: Copy convolution test for fk table from grid one
Browse files Browse the repository at this point in the history
  • Loading branch information
alecandido authored and cschwan committed Apr 18, 2024
1 parent 9557d63 commit 2b22b3d
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions pineappl_py/tests/test_fk_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import numpy as np

import pineappl


class TestFkTable:
def fake_grid(self, bins=None):
lumis = [pineappl.lumi.LumiEntry([(1, 21, 0.1)])]
orders = [pineappl.grid.Order(3, 0, 0, 0)]
bin_limits = np.array([1e-7, 1e-3, 1] if bins is None else bins, dtype=float)
subgrid_params = pineappl.subgrid.SubgridParams()
g = pineappl.grid.Grid.create(lumis, orders, bin_limits, subgrid_params)
return g

def test_convolute_with_one(self):
g = self.fake_grid()

# DIS grid
xs = np.linspace(0.5, 1.0, 5)
vs = xs.copy()
subgrid = pineappl.import_only_subgrid.ImportOnlySubgridV1(
vs[np.newaxis, :, np.newaxis],
np.array([90.0]),
xs,
np.array([1.0]),
)
g.set_subgrid(0, 0, 0, subgrid)
fk = pineappl.fk_table.FkTable(g)
np.testing.assert_allclose(
fk.convolute_with_one(2212, lambda pid, x, q2: 0.0, lambda q2: 0.0),
[0.0] * 2,
)
np.testing.assert_allclose(
fk.convolute_with_one(2212, lambda pid, x, q2: 1, lambda q2: 1.0),
[5e6 / 9999, 0.0],
)
np.testing.assert_allclose(
fk.convolute_with_one(2212, lambda pid, x, q2: 1, lambda q2: 2.0),
[2**3 * 5e6 / 9999, 0.0],
)

0 comments on commit 2b22b3d

Please sign in to comment.