diff --git a/src/pineko/evolve.py b/src/pineko/evolve.py index b40c6cc3..39f65e6a 100644 --- a/src/pineko/evolve.py +++ b/src/pineko/evolve.py @@ -173,7 +173,10 @@ def write_operator_card(pineappl_grid, default_card, card_path, tcard): opconf["ev_op_iterations"] = 1 elif tcard["ModEv"] == "EXA": opconf["evolution_method"] = "iterate-exact" - opconf["ev_op_iterations"] = tcard["IterEv"] + if "IterEv" in tcard: + opconf["ev_op_iterations"] = tcard["IterEv"] + elif "IterEv" not in default_card["configs"]: + raise ValueError("IterEv not found in both the theory and the template") # If the information was also in the template _and it is different_, warn for key in ["evolution_method", "ev_op_iterations"]: diff --git a/tests/test_evolve.py b/tests/test_evolve.py index 51621062..1815654d 100644 --- a/tests/test_evolve.py +++ b/tests/test_evolve.py @@ -50,22 +50,22 @@ def test_write_operator_card_q0(tmp_path): """Checks https://github.com/NNPDF/pineko/issues/146""" p = tmp_path / "q0.yaml" g = FakePine() - # 1. defaults t = copy.deepcopy(default_card) o = copy.deepcopy(example.raw_operator()) + # 1. Same Q0 and mu0, all ok + t["Q0"] = 5.0 + o["mu0"] = 5.0 _xs, _mu2s = pineko.evolve.write_operator_card(g, o, p, t) with open(p, encoding="utf8") as f: oo = yaml.safe_load(f) np.testing.assert_allclose(oo["mu0"], t["Q0"]) - # 2. overwriting from theory side - t["Q0"] = 10.0 + # 2. Q0 only in theory, all ok + o.pop("mu0") _xs, _mu2s = pineko.evolve.write_operator_card(g, o, p, t) with open(p, encoding="utf8") as f: oo = yaml.safe_load(f) np.testing.assert_allclose(oo["mu0"], t["Q0"]) - # 3. op template is ignored + # 3. op is different, raises error o["mu0"] = 11.0 - _xs, _mu2s = pineko.evolve.write_operator_card(g, o, p, t) - with open(p, encoding="utf8") as f: - oo = yaml.safe_load(f) - np.testing.assert_allclose(oo["mu0"], t["Q0"]) + with pytest.raises(ValueError): + _xs, _mu2s = pineko.evolve.write_operator_card(g, o, p, t)