Skip to content

Commit 161eec7

Browse files
Fix convolution checks
1 parent f07d9f0 commit 161eec7

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed

pineappl_py/tests/test_fk_table.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ def test_fktable_rotations(
122122
tmp_path,
123123
fkname: str = "FKTABLE_CMSTTBARTOT8TEV-TOPDIFF8TEVTOT.pineappl.lz4",
124124
):
125+
expected_results = [3.72524538e04] # Numbers computed using `v0.8.6`
126+
125127
fk_table = download_objects(f"{fkname}")
126128
fk = FkTable.read(fk_table)
127129

@@ -135,23 +137,20 @@ def test_fktable_rotations(
135137
fk_pdg_facs = fk.channels_factors()
136138
np.testing.assert_array_equal(fk_pdg_facs, 1)
137139

138-
# check that the FK table can be loaded properly
139-
path = f"{tmp_path}/rotated_fktable.pineappl.lz4"
140-
fk.write_lz4(path)
141-
fk_mod = FkTable.read(path)
142-
143-
# check that the convolutions are the same
140+
# check that the convolutions are still the same
144141
np.testing.assert_allclose(
145142
fk.convolve(
146143
pdg_convs=fk.convolutions,
147144
xfxs=[pdf.unpolarized_pdf, pdf.unpolarized_pdf],
148145
),
149-
fk_mod.convolve(
150-
pdg_convs=fk_mod.convolutions,
151-
xfxs=[pdf.unpolarized_pdf, pdf.unpolarized_pdf],
152-
),
146+
expected_results,
153147
)
154148

149+
# check that the FK table can be loaded properly
150+
path = f"{tmp_path}/rotated_fktable.pineappl.lz4"
151+
fk.write_lz4(path)
152+
_ = FkTable.read(path)
153+
155154
def test_unpolarized_convolution(
156155
self,
157156
pdf,
@@ -161,7 +160,7 @@ def test_unpolarized_convolution(
161160
"""Check the convolution of an actual FK table that involves two
162161
symmetrical unpolarized protons:
163162
"""
164-
expected_results = [3.72524538e04]
163+
expected_results = [3.72524538e04] # Numbers computed using `v0.8.6`
165164
fk_table = download_objects(f"{fkname}")
166165
fk = FkTable.read(fk_table)
167166

pineappl_py/tests/test_grid.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,15 @@ def test_grid_rotations(
405405
tmp_path,
406406
gridname: str = "GRID_DYE906R_D_bin_1.pineappl.lz4",
407407
):
408+
expected_results = [
409+
+3.71019208e4,
410+
+3.71019208e4,
411+
+2.13727492e4,
412+
-1.83941398e3,
413+
+3.22728612e3,
414+
+5.45646897e4,
415+
] # Numbers computed using `v0.8.6`
416+
408417
grid = download_objects(f"{gridname}")
409418
g = Grid.read(grid)
410419

@@ -424,25 +433,21 @@ def test_grid_rotations(
424433
g_facs = g.channels_factors()
425434
np.testing.assert_array_equal(g_facs, 1)
426435

427-
# check that the FK table can be loaded properly
428-
path = f"{tmp_path}/grid_merged_factors.pineappl.lz4"
429-
g.write_lz4(path)
430-
g_mod = Grid.read(path)
431-
432-
# check that the convolutions are the same
436+
# check that the convolutions are still the same
433437
np.testing.assert_allclose(
434438
g.convolve(
435439
pdg_convs=g.convolutions,
436440
xfxs=[pdf.polarized_pdf],
437441
alphas=pdf.alphasQ,
438442
),
439-
g_mod.convolve(
440-
pdg_convs=g_mod.convolutions,
441-
xfxs=[pdf.polarized_pdf],
442-
alphas=pdf.alphasQ,
443-
),
443+
expected_results,
444444
)
445445

446+
# check that the FK table can be loaded properly
447+
path = f"{tmp_path}/grid_merged_factors.pineappl.lz4"
448+
g.write_lz4(path)
449+
_ = Grid.read(path)
450+
446451
def test_unpolarized_convolution(
447452
self,
448453
pdf,

0 commit comments

Comments
 (0)