Skip to content

Commit

Permalink
Merge branch 'master' into tmc-pol
Browse files Browse the repository at this point in the history
  • Loading branch information
Radonirinaunimi committed Oct 17, 2023
2 parents ea76b54 + 508c4fe commit d8c2731
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 205 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ci:
autofix_prs: false
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -27,7 +27,7 @@ repos:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/asottile/pyupgrade
rev: v3.10.1
rev: v3.15.0
hooks:
- id: pyupgrade
- repo: https://github.com/hadialqattan/pycln
Expand Down
296 changes: 93 additions & 203 deletions poetry.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/yadbox/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def dump_pineappl_to_file(output, filename, obsname):
grid.set_key_value("x3_label_tex", "$y$")
grid.set_key_value("x3_unit", "")
grid.set_key_value("y_label", obsname)
grid.set_key_value("polarized", str(obsname.startswith("g")))

# dump file
grid.optimize()
Expand Down
2 changes: 2 additions & 0 deletions src/yadism/esf/exs.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ def xs_coeffs(kind, y, x=None, Q2=None, params=None):
ym = 0
yp = 1.0
yL = y**2 / (2 * (y**2 / 2 + (1 - y) - (mn * x * y) ** 2 / Q2))
elif kind == "F1":
return np.array([1 / (2 * x), -1 / (2 * x), 0])
elif kind == "XSFPFCC":
INV_GEV_TO_PB = GEV_CM2_CONV / 100.0 # pb
norm = (INV_GEV_TO_PB * params["GF"] ** 2) / (2.0 * np.pi)
Expand Down
1 change: 1 addition & 0 deletions src/yadism/observable_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"XSNUTEVCC",
"XSNUTEVNU",
"FW",
"F1",
"XSFPFCC",
]
kinds = sfs + xs + [fake_kind]
Expand Down
17 changes: 17 additions & 0 deletions tests/yadbox/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,20 @@ def test_pineappl_xs(tmp_path: pathlib.Path):
np.testing.assert_allclose(g.bin_left(0), np.array([10.0]))
np.testing.assert_allclose(g.bin_left(1), np.array([0.1]))
np.testing.assert_allclose(g.bin_left(2), np.array([0.3]))


def test_pineappl_pol(tmp_path: pathlib.Path):
pl = tmp_path / "polarized.pineappl.lz4"
oo = copy.deepcopy(obs_card)
oo["observables"] = {
"g1_light": [{"x": 0.1, "Q2": 10.0}],
"F2_total": [{"x": 0.2, "Q2": 20.0}],
}
out = run_yadism(theory_card, oo)
dump_pineappl_to_file(out, pl, "g1_light")
g = pineappl.grid.Grid.read(pl)
assert g.key_values()["polarized"] == "True"

dump_pineappl_to_file(out, pl, "F2_total")
f = pineappl.grid.Grid.read(pl)
assert f.key_values()["polarized"] == "False"
11 changes: 11 additions & 0 deletions tests/yadism/esf/test_exs.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ def test_xs_coeffs():
assert fw[0] == 1.0
assert fw[2] == 0.0

f1 = xs_coeffs(
"F1",
x=0.5,
Q2=1.0,
y=0.0,
params=dict(projectilePID=1, M2target=0.0, M2W=1.0),
)
assert f1[0] == 1.0
assert f1[1] == -1.0
assert f1[2] == 0.0

xsfpfcc = xs_coeffs(
"XSFPFCC",
x=0.5,
Expand Down

0 comments on commit d8c2731

Please sign in to comment.