Skip to content

Commit

Permalink
Merge pull request #309 from NNPDF/fix_ckm_nnpdf_compatibility
Browse files Browse the repository at this point in the history
Fix CKM as list
  • Loading branch information
giacomomagni authored Nov 8, 2024
2 parents 7847f6d + 193c0c6 commit c106184
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/yadism/coefficient_functions/coupling_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,8 @@ def from_dict(cls, theory, observables):
ckm_matrix = theory["CKM"]
if isinstance(ckm_matrix, str):
ckm_matrix = CKM2Matrix.from_str(ckm_matrix)
elif isinstance(ckm_matrix, list):
ckm_matrix = CKM2Matrix(np.array(ckm_matrix) ** 2)
theory_config = {
"MZ2": theory.get("MZ", 91.1876)
** 2, # TODO remove defaults to the PDG2020 value
Expand Down Expand Up @@ -477,6 +479,10 @@ def __repr__(self):
"""Return string representation."""
return "CKM(" + str(self.m).replace("\n", "") + ")"

def __eq__(self, other) -> bool:
"""Equal method."""
return (self.m == other.m).all()

def __getitem__(self, key):
"""Allow pid and strings as key.
Expand Down
18 changes: 18 additions & 0 deletions tests/yadism/cf/test_coupling_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,24 @@ def test_from_dict(self):
coupl_const = coupl.CouplingConstants.from_dict(th_d, obs_d)
assert coupl_const.theory_config["MW2"] == MW**2

new_th_ckm = dict(
SIN2TW=sin2tw,
MZ=MZ,
CKM=[
0.97428,
0.22530,
0.003470,
0.22520,
0.97345,
0.041000,
0.00862,
0.04030,
0.999152,
],
)
new_coupl_const = coupl.CouplingConstants.from_dict(new_th_ckm, obs_d)
assert coupl_const.theory_config["CKM"] == new_coupl_const.theory_config["CKM"]

# Unknown projectile
obs_d["ProjectileDIS"] = 0
with pytest.raises(ValueError, match="Unknown projectile"):
Expand Down

0 comments on commit c106184

Please sign in to comment.