From c92953f9450ea7d7e6908f454f743d04857280a8 Mon Sep 17 00:00:00 2001 From: giacomomagni Date: Mon, 8 Nov 2021 09:47:26 +0100 Subject: [PATCH 1/5] Adding nf0, and fix VFNS lha bench --- benchmarks/runners/lha_paper_bench.py | 5 +++-- src/eko/thresholds.py | 2 ++ tests/benchmark_evol_to_unity.py | 1 + tests/test_ev_op_grid.py | 1 + tests/test_ev_operator.py | 1 + tests/test_ome.py | 1 + tests/test_runner.py | 1 + tests/test_thresholds.py | 1 + 8 files changed, 11 insertions(+), 2 deletions(-) diff --git a/benchmarks/runners/lha_paper_bench.py b/benchmarks/runners/lha_paper_bench.py index b5270f03e..bdb4462c4 100644 --- a/benchmarks/runners/lha_paper_bench.py +++ b/benchmarks/runners/lha_paper_bench.py @@ -136,6 +136,7 @@ class BenchmarkVFNS(LHABenchmark): "kcThr": 1.0, "kbThr": 1.0, "ktThr": 1.0, + "nf0": 3, } ) @@ -168,8 +169,8 @@ def skip_pdfs(theory): if __name__ == "__main__": - # obj = BenchmarkVFNS() - obj = BenchmarkFFNS() + obj = BenchmarkVFNS() + # obj = BenchmarkFFNS() obj.benchmark_plain(2) # obj.benchmark_sv(1) diff --git a/src/eko/thresholds.py b/src/eko/thresholds.py index 776715e15..7f6d84bb2 100644 --- a/src/eko/thresholds.py +++ b/src/eko/thresholds.py @@ -176,9 +176,11 @@ def from_dict(cls, theory_card, prefix="k", max_nf_name="MaxNfPdf"): max_nf = theory_card[max_nf_name] # preset ref scale q2_ref = pow(theory_card["Q0"], 2) + nf_ref = theory_card["nf0"] return cls( np.power(masses, 2), q2_ref, + nf_ref, thresholds_ratios=np.power(thresholds_ratios, 2), max_nf=max_nf, ) diff --git a/tests/benchmark_evol_to_unity.py b/tests/benchmark_evol_to_unity.py index 1777477d3..a5710a7b7 100644 --- a/tests/benchmark_evol_to_unity.py +++ b/tests/benchmark_evol_to_unity.py @@ -21,6 +21,7 @@ class TestBackwardForward: "Qref": np.sqrt(2), "nfref": None, "Q0": np.sqrt(2), + "nf0": 4, "IC": 1, "IB": 1, "mc": 1.0, diff --git a/tests/test_ev_op_grid.py b/tests/test_ev_op_grid.py index ec59c3200..7fda94de9 100644 --- a/tests/test_ev_op_grid.py +++ b/tests/test_ev_op_grid.py @@ -25,6 +25,7 @@ def _get_setup(self, use_FFNS): "Qref": np.sqrt(2), "nfref": None, "Q0": np.sqrt(100), + "nf0": 3, "FNS": "FFNS", "NfFF": 3, "IC": 1, diff --git a/tests/test_ev_operator.py b/tests/test_ev_operator.py index bc053447d..ec47635d2 100644 --- a/tests/test_ev_operator.py +++ b/tests/test_ev_operator.py @@ -151,6 +151,7 @@ def test_compute(self, monkeypatch): "Qref": np.sqrt(2), "nfref": None, "Q0": np.sqrt(2), + "nf0": 3, "FNS": "FFNS", "NfFF": 3, "IC": 0, diff --git a/tests/test_ome.py b/tests/test_ome.py index 9505d793f..8da5d2a87 100644 --- a/tests/test_ome.py +++ b/tests/test_ome.py @@ -198,6 +198,7 @@ class TestOperatorMatrixElement: "Qref": np.sqrt(2), "nfref": None, "Q0": np.sqrt(2), + "nf0": 3, "NfFF": 3, "IC": 1, "IB": 0, diff --git a/tests/test_runner.py b/tests/test_runner.py index 8a9065898..4023f6478 100644 --- a/tests/test_runner.py +++ b/tests/test_runner.py @@ -12,6 +12,7 @@ "Qref": np.sqrt(2), "nfref": None, "Q0": np.sqrt(2), + "nf0": 4, "FNS": "FFNS", "NfFF": 3, "ModEv": "EXA", diff --git a/tests/test_thresholds.py b/tests/test_thresholds.py index 9a50edf6b..e2044ce9b 100644 --- a/tests/test_thresholds.py +++ b/tests/test_thresholds.py @@ -86,6 +86,7 @@ def test_from_dict(self): "kbThr": 2.0, "ktThr": np.inf, "Q0": 1.0, + "nf0": 4, "MaxNfPdf": 6, } ) From 4f963e889d13468a1e8eabbc8290799659975e88 Mon Sep 17 00:00:00 2001 From: Alessandro Candido Date: Sun, 14 Nov 2021 18:37:02 +0100 Subject: [PATCH 2/5] Update codecov.yml --- .github/codecov.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/codecov.yml b/.github/codecov.yml index 9ce1ad839..1b299b390 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -38,3 +38,6 @@ comment: #- master #- "feature/*" #- "release/*" + +github_checks: + annotations: false From e11e4c48cc0558ffbfb4aa9323a83478b9c3dc49 Mon Sep 17 00:00:00 2001 From: Alessandro Candido Date: Fri, 10 Dec 2021 17:50:25 +0100 Subject: [PATCH 3/5] Do not rely on external name while loading tar. Closes #81 --- src/eko/output.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/eko/output.py b/src/eko/output.py index ba7bc620f..6e2a04f6e 100644 --- a/src/eko/output.py +++ b/src/eko/output.py @@ -498,11 +498,12 @@ def load_tar(cls, tarname): # metadata = cls(**{str(k): v for k, v in self.items() if k != "Q2grid"}) # metadata["Q2grid"] = list(self["Q2grid"].keys()) - yamlname = tmpdir / tarpath.stem / "metadata.yaml" + innerdir = list(tmpdir.glob("*"))[0] + yamlname = innerdir / "metadata.yaml" metadata = cls.load_yaml_from_file(yamlname, skip_q2_grid=True) grids = {} - for fp in (tmpdir / tarpath.stem).glob("*.npy.lz4"): + for fp in innerdir.glob("*.npy.lz4"): with lz4.frame.open(fp, "rb") as fd: stream = io.BytesIO(fd.read()) stream.seek(0) From c657c047c2eb43c7fa6bb99ec3ced3349dabc4e9 Mon Sep 17 00:00:00 2001 From: Felix Hekhorn Date: Mon, 13 Dec 2021 11:44:10 +0100 Subject: [PATCH 4/5] Test renaming fix #81 --- tests/test_output.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/test_output.py b/tests/test_output.py index dae98974f..7892daa66 100644 --- a/tests/test_output.py +++ b/tests/test_output.py @@ -2,6 +2,7 @@ import copy import io import pathlib +import shutil import tempfile from unittest import mock @@ -123,6 +124,26 @@ def test_io(self): with pytest.raises(ValueError, match="wrong suffix"): o1.load_tar(fn) + def test_rename_issue81(self): + # https://github.com/N3PDF/eko/issues/81 + d = self.fake_output() + # create object + o1 = output.Output(d) + + with tempfile.TemporaryDirectory() as folder: + # dump + p = pathlib.Path(folder) + fp1 = p / "test1.tar" + fp2 = p / "test2.tar" + o1.dump_tar(fp1) + # rename + shutil.move(fp1, fp2) + # reload + o4 = output.Output.load_tar(fp2) + np.testing.assert_almost_equal( + o4["interpolation_xgrid"], d["interpolation_xgrid"] + ) + def test_io_bin(self): d = self.fake_output() # create object From 057ff5e0411cc207054804a1bf9c6b423b87686a Mon Sep 17 00:00:00 2001 From: Felix Hekhorn Date: Mon, 13 Dec 2021 17:30:49 +0100 Subject: [PATCH 5/5] Bump version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 599f7e778..f978d319c 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ # write version on the fly - inspired by numpy MAJOR = 0 MINOR = 8 -MICRO = 1 +MICRO = 2 repo_path = pathlib.Path(__file__).absolute().parent