Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to PineAPPL v1 #206

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,23 @@ jobs:
with:
# tags needed for dynamic versioning
fetch-depth: 0
- name: Install Rust Toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Install Maturin
run: pip install maturin
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: false
installer-parallel: true
- name: Install dependencies
run: poetry install --no-interaction --no-root --with test
run: poetry install --no-interaction --no-root --with test -E nnpdf
- name: Install project
# it is required to repeat extras, otherwise they will be removed from
# the environment
run: poetry install --no-interaction
run: poetry install --no-interaction -E nnpdf
- name: Install task runner
run: pip install poethepoet
- name: Lint with pylint
Expand Down
38 changes: 21 additions & 17 deletions benchmarks/bench_autosv.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,32 @@ def benchmark_compute_ren_sv_grid(test_files, tmp_path, test_pdf, lhapdf_path):
plusrensv_grid_path = tmp_path / name_grid
with lhapdf_path(test_pdf):
pdf = lhapdf.mkPDF(pdf_name)

to_test_grid = pineappl.grid.Grid.read(to_test_grid_path)
plusrensv_grid = pineappl.grid.Grid.read(plusrensv_grid_path)
sv_list = [(0.5, 1.0), (2.0, 1.0)] # Only ren sv have to be tested
sv_list = [(0.5, 1.0, 1.0), (2.0, 1.0, 1.0)] # Only μR have to be tested
bin_number = to_test_grid.bins()
to_test_res = to_test_grid.convolve_with_one(
2212,
pdf.xfxQ2,
pdf.alphasQ2,
np.array([], dtype=bool),
np.array([], dtype=np.uint64),
np.array([], dtype=bool),
sv_list,

to_test_res = to_test_grid.convolve(
pdg_convs=to_test_grid.convolutions,
xfxs=[pdf.xfxQ2],
alphas=pdf.alphasQ2,
order_mask=np.array([], dtype=bool),
bin_indices=np.array([], dtype=np.uint64),
channel_mask=np.array([], dtype=bool),
xi=sv_list,
).reshape(bin_number, len(sv_list))
plusrensv_res = plusrensv_grid.convolve_with_one(
2212,
pdf.xfxQ2,
pdf.alphasQ2,
np.array([], dtype=bool),
np.array([], dtype=np.uint64),
np.array([], dtype=bool),
sv_list,

plusrensv_res = plusrensv_grid.convolve(
pdg_convs=plusrensv_grid.convolutions,
xfxs=[pdf.xfxQ2],
alphas=pdf.alphasQ2,
order_mask=np.array([], dtype=bool),
bin_indices=np.array([], dtype=np.uint64),
channel_mask=np.array([], dtype=bool),
xi=sv_list,
).reshape(bin_number, len(sv_list))

rtol = 1.0e-14
for sv in sv_list:
for n_res, old_res in zip(
Expand Down
3 changes: 2 additions & 1 deletion benchmarks/bench_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ def benchmark_compare_cli(lhapdf_path, test_files, test_pdf):
command,
["compare", str(fk_path), str(grid_path), "2", "0", "NNPDF40_nlo_as_01180"],
)
assert "yll left" in result.output
assert "left" in result.output
assert "right" in result.output


def benchmark_convolve_cli(test_files, tmp_path):
Expand Down
10 changes: 6 additions & 4 deletions benchmarks/bench_comparator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import numpy as np
import pineappl

import pineko
Expand All @@ -8,9 +9,10 @@ def benchmark_compare(lhapdf_path, test_files, test_pdf):
grid = pineappl.grid.Grid.read(pine_path)
fk_path = test_files / "data/fktables/208/LHCB_DY_13TEV_DIMUON.pineappl.lz4"
fk = pineappl.fk_table.FkTable.read(fk_path)
pdf = "NNPDF40_nlo_as_01180"
pdfs = ["NNPDF40_nlo_as_01180"]
xi = (1.0, 1.0, 1.0)
with lhapdf_path(test_pdf):
comp_table = pineko.comparator.compare(grid, fk, 2, 0, pdf, 1.0, 1.0)
comp_table = pineko.comparator.compare(grid, fk, 2, 0, pdfs, xi)
# TODO: Check if there is NOW a slight difference in PineAPPL convolve
errors = comp_table["permille_error"].values
assertions = [er < 5.0 for er in errors]
assert False not in assertions
assert np.all(errors < 5.0)
19 changes: 10 additions & 9 deletions benchmarks/bench_evolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,20 @@ def benchmark_evolve_grid(tmp_path, lhapdf_path, test_files, test_pdf):
with eko.EKO.edit(eko_path) as eko_op:
with lhapdf_path(test_pdf):
pineko.evolve.evolve_grid(
pinegrid,
eko_op,
target_path,
max_as,
max_al,
1.0,
1.0,
grid=pinegrid,
operators=[eko_op],
fktable_path=target_path,
max_as=max_as,
max_al=max_al,
xir=1.0,
xif=1.0,
xia=1.0,
assumptions=assumptions,
comparison_pdf1="NNPDF40_nnlo_as_01180",
comparison_pdfs=["NNPDF40_nnlo_as_01180"],
)
# check metadata is there - fixes https://github.com/NNPDF/pineko/issues/70
fk = pineappl.fk_table.FkTable.read(target_path)
kvs = fk.key_values()
kvs = fk.key_values
assert "results_fk" in kvs
assert "eko_theory_card" in kvs
assert json.dumps(eko_op.theory_card.raw) == kvs["eko_theory_card"]
42 changes: 21 additions & 21 deletions benchmarks/bench_kfactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,31 @@ def benchmark_kfactor_inclusion(test_files, tmp_path, test_pdf, lhapdf_path):
with lhapdf_path(test_pdf):
pdf = lhapdf.mkPDF(pdf_name)
pluskfactor_grid = pineappl.grid.Grid.read(pluskfactor_grid_path)
sv_list = [(1.0, 1.0)] # Only ren sv have to be tested
sv_list = [(1.0, 1.0, 1.0)] # Only ren sv have to be tested
bin_number = pluskfactor_grid.bins()
order_mask_nloQCD = pineappl.grid.Order.create_mask(
pluskfactor_grid.orders(), 2, 0, True
order_mask_nloQCD = pineappl.boc.Order.create_mask(
orders=pluskfactor_grid.orders(), max_as=2, max_al=0, logs=True
)
order_mask_nnloQCD = pineappl.grid.Order.create_mask(
pluskfactor_grid.orders(), 3, 0, True
order_mask_nnloQCD = pineappl.boc.Order.create_mask(
orders=pluskfactor_grid.orders(), max_as=3, max_al=0, logs=True
)
to_test_res_nlo = pluskfactor_grid.convolve_with_one(
2212,
pdf.xfxQ2,
pdf.alphasQ2,
order_mask_nloQCD,
np.array([], dtype=np.uint64),
np.array([], dtype=bool),
sv_list,
to_test_res_nlo = pluskfactor_grid.convolve(
pdg_convs=pluskfactor_grid.convolutions,
xfxs=[pdf.xfxQ2],
alphas=pdf.alphasQ2,
order_mask=order_mask_nloQCD,
bin_indices=np.array([], dtype=np.uint64),
channel_mask=np.array([], dtype=bool),
xi=sv_list,
).reshape(bin_number, len(sv_list))
to_test_res_nnlo = pluskfactor_grid.convolve_with_one(
2212,
pdf.xfxQ2,
pdf.alphasQ2,
order_mask_nnloQCD,
np.array([], dtype=np.uint64),
np.array([], dtype=bool),
sv_list,
to_test_res_nnlo = pluskfactor_grid.convolve(
pdg_convs=pluskfactor_grid.convolutions,
xfxs=[pdf.xfxQ2],
alphas=pdf.alphasQ2,
order_mask=order_mask_nnloQCD,
bin_indices=np.array([], dtype=np.uint64),
channel_mask=np.array([], dtype=bool),
xi=sv_list,
).reshape(bin_number, len(sv_list))
centrals_kfactor, _ = kfactor.read_from_file(
test_files / "data" / "kfactors" / "CF_QCD_ATLAS_TTB_8TEV_LJ_TRAP.dat"
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/bench_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def benchmark_regression(tmp_path, dataset):
fkt = FkTable.read(
tmp_path / "data" / "fktables" / str(THEORYID) / f"{grid_name}.pineappl.lz4"
)
result.append(fkt.convolve_with_one(2212, pdf.xfxQ2))
result.append(fkt.convolve(pdg_convs=fkt.convolutions, xfxs=[pdf.xfxQ2]))
result = np.concatenate(result)

if not regression_path.exists():
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/bench_theory.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ def benchmark_fk(test_files, test_configs):
)
theory_obj_hera.opcard(grid_name, pathlib.Path(test_files / grid_path), tcard)

theory_obj_hera.fk(grid_name, grid_path, tcard, pdf1=None, pdf2=None)
theory_obj_hera.fk(grid_name, grid_path, tcard, pdfs=None)
# test overwrite function
theory_obj_hera.fk(grid_name, grid_path, tcard, pdf1=None, pdf2=None)
theory_obj_hera.fk(grid_name, grid_path, tcard, pdfs=None)
log_path = pathlib.Path(test_files / "logs/fk/400-HERA_NC_225GEV_EP_SIGMARED.log")
if os.path.exists(log_path):
os.remove(log_path)
Expand Down
Loading
Loading