Skip to content

Commit

Permalink
check for error raising
Browse files Browse the repository at this point in the history
  • Loading branch information
scarlehoff committed May 2, 2024
1 parent 24d74af commit 2fab8d8
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tests/test_evolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 2fab8d8

Please sign in to comment.