Skip to content

Commit

Permalink
init fixing benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomomagni committed Nov 13, 2024
1 parent d9b60e7 commit f5a47c5
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 17 deletions.
35 changes: 25 additions & 10 deletions benchmarks/bench_checks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import eko
import numpy as np
import pineappl
import pytest
from eko.io import manipulate

import pineko.check

Expand All @@ -16,12 +16,27 @@ def benchmark_check_grid_and_eko_compatible(test_files, tmp_path):
with eko.EKO.edit(
test_files / "data/ekos/400/HERA_NC_225GEV_EP_SIGMARED.tar"
) as ekoop:
with pytest.raises(ValueError):
pineko.check.check_grid_and_eko_compatible(wrong_grid, ekoop, 1.0, 3, 3)
pineko.check.check_grid_and_eko_compatible(grid, ekoop, 1.0, 3, 3)
eko.io.manipulate.xgrid_reshape(
ekoop, targetgrid=eko.interpolation.XGrid([0.0001, 0.001, 0.1, 0.5, 1.0])
)
with pytest.raises(ValueError):
pineko.check.check_grid_and_eko_compatible(grid, ekoop, 1.0, 10, 10)
eko.io.manipulate.xgrid_reshape(ekoop, targetgrid=ekoop.xgrid)
eko_xgrid = ekoop.xgrid.tolist()
for (eko_mu2, _), _ in ekoop.items():
with pytest.raises(ValueError):
pineko.check.check_grid_and_eko_compatible(
wrong_grid, eko_xgrid, eko_mu2, 1.0, 3, 3
)
pineko.check.check_grid_and_eko_compatible(
grid, eko_xgrid, eko_mu2, 1.0, 3, 3
)

# test a wrong rotation
wrong_xgrid = eko.interpolation.XGrid([0.0001, 0.001, 0.1, 0.5, 1.0])
for (eko_mu2, _), op in ekoop.items():
# TODO: here we can only check inputgrid as this eko has dimension (14,40,14,50)
# and ekoop.xgrid has 50
op = manipulate.xgrid_reshape(op, ekoop.xgrid, 4, inputgrid=wrong_xgrid)
assert op.operator.shape[-1] == len(wrong_xgrid)
with pytest.raises(ValueError):
pineko.check.check_grid_and_eko_compatible(
grid, wrong_xgrid.tolist(), eko_mu2, 1.0, 10, 10
)
# restore xgrid
op = manipulate.xgrid_reshape(op, wrong_xgrid, 4, inputgrid=ekoop.xgrid)
assert op.operator.shape[-1] == len(ekoop.xgrid)
3 changes: 1 addition & 2 deletions benchmarks/bench_cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pathlib
import shutil

import lhapdf
from click.testing import CliRunner

from pineko.cli._base import command
Expand All @@ -19,7 +18,7 @@ def benchmark_check_cli(test_files):
result = runner.invoke(
command, ["check", "compatibility", str(grid_path), str(eko_path)]
)
assert "Success: grids are compatible" in result.output
assert "Success: grids and eko are compatible" in result.output
wrong_result = runner.invoke(
command, ["check", "compatibility", str(wrong_grid_path), str(eko_path)]
)
Expand Down
1 change: 0 additions & 1 deletion benchmarks/bench_evolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import pathlib

import eko
import eko.io.legacy
import numpy as np
import pineappl
import pytest
Expand Down
7 changes: 4 additions & 3 deletions benchmarks/bench_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ def xfxQ2(self, pid, x, q2):

def _trim_template(template_card, take_points=10):
"""Trim the template card so that the number of x-values to compute is much smaller"""
card_info = OperatorCard.from_dict(
safe_load(template_card.read_text(encoding="utf-8"))
)
raw_card = safe_load(template_card.read_text(encoding="utf-8"))
raw_card["init"] = (raw_card["mu0"], 4)
del raw_card["mu0"]
card_info = OperatorCard.from_dict(raw_card)
original_x = card_info.xgrid
size = len(original_x.raw)
skip = int(size / take_points)
Expand Down
1 change: 0 additions & 1 deletion src/pineko/theory.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import time

import eko
import eko.io.legacy
import numpy as np
import pineappl
import rich
Expand Down

0 comments on commit f5a47c5

Please sign in to comment.