From adeb134960eb112e6d72e32e1ae6c1721a62f435 Mon Sep 17 00:00:00 2001 From: Radonirinaunimi Date: Mon, 2 Dec 2024 21:46:32 +0100 Subject: [PATCH] Check that convolutions remain the same after rotating PID basis --- pineappl_py/tests/test_grid.py | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/pineappl_py/tests/test_grid.py b/pineappl_py/tests/test_grid.py index bb802b35..32d84fdb 100644 --- a/pineappl_py/tests/test_grid.py +++ b/pineappl_py/tests/test_grid.py @@ -213,17 +213,34 @@ def test_bins(self, fake_grids): np.testing.assert_allclose(g.bin_left(1), [2, 3]) np.testing.assert_allclose(g.bin_right(1), [3, 5]) - def test_rotate_pidbasis(self, fake_grids): - g = fake_grids.grid_with_generic_convolution( - nb_convolutions=2, - channels=CHANNELS, - orders=ORDERS, - convolutions=[CONVOBJECT, CONVOBJECT], + def test_rotate_pidbasis( + self, + pdf, + download_objects, + gridname: str = "GRID_STAR_WMWP_510GEV_WP-AL-POL.pineappl.lz4", + target_basis: PidBasis = PidBasis.Evol, + ): + grid = download_objects(f"{gridname}") + g = Grid.read(grid) + + conv_ref = g.convolve( + pdg_convs=g.convolutions, + xfxs=[pdf.polarized_pdf, pdf.unpolarized_pdf], + alphas=pdf.alphasQ, ) - # Rotate the Grid into the PDG basis - g.rotate_pid_basis(PidBasis.Pdg) assert g.pid_basis == PidBasis.Pdg + # Rotate the Grid into the PDG basis + g.rotate_pid_basis(target_basis) + assert g.pid_basis == target_basis + + conv_rot = g.convolve( + pdg_convs=g.convolutions, + xfxs=[pdf.polarized_pdf, pdf.unpolarized_pdf], + alphas=pdf.alphasQ, + ) + np.testing.assert_allclose(conv_ref, conv_rot) + def test_delete_orders( self, download_objects,