Skip to content

Commit

Permalink
Merge pull request #280 from NNPDF/fix_q2_grid_generate_block
Browse files Browse the repository at this point in the history
fix Q2 grid in generate_block
  • Loading branch information
giacomomagni authored Jun 5, 2023
2 parents 633fbb4 + 1ade0f0 commit 6e5dc8a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ekobox/genpdf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,11 @@ def generate_block(
xfxQ2: Callable, xgrid: List[float], evolgrid: List[EPoint], pids: List[int]
) -> dict:
"""Generate an LHAPDF data block from a callable."""
block: dict = dict(mu2grid=[mu2 for mu2, _ in evolgrid], pids=pids, xgrid=xgrid)
sorted_q2grid = [float(q2) for q2, _ in np.sort(evolgrid, axis=0)]
block: dict = dict(mu2grid=sorted_q2grid, pids=pids, xgrid=xgrid)
data = []
for x in xgrid:
for mu2, _ in evolgrid:
for mu2 in sorted_q2grid:
data.append(np.array([xfxQ2(pid, x, mu2) for pid in pids]))
block["data"] = np.array(data)
return block
1 change: 1 addition & 0 deletions tests/ekobox/test_genpdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def test_generate_block():
assert sorted(b.keys()) == sorted(["data", "mu2grid", "xgrid", "pids"])
assert isinstance(b["data"], np.ndarray)
assert b["data"].shape == (len(xg) * len(mu2s), len(pids))
assert b["mu2grid"] == sorted(b["mu2grid"])


def test_install_pdf(fake_lhapdf, cd):
Expand Down

0 comments on commit 6e5dc8a

Please sign in to comment.