Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
dd2cb06
Introduction of template.py to contain constants and xgrid
evagroenendijk May 23, 2025
51eb28b
Introduction of template.py to contain constants and xgrid
evagroenendijk May 23, 2025
756be45
Removal of need of _template.yaml
evagroenendijk Jun 19, 2025
ed25c7d
Remove test that checks q0 from theory card & _template.py
evagroenendijk Jun 19, 2025
b0350dc
Remove unnecessary stuff from template.py
evagroenendijk Jun 19, 2025
44d784a
Resolve conflicts with master
evagroenendijk Jun 20, 2025
22d9ac2
Forgot to add template.py
evagroenendijk Jun 20, 2025
5f7394b
Remove eko version from template.py
evagroenendijk Apr 14, 2026
7c973d2
changes needed for merge with main
evagroenendijk Apr 23, 2026
f560b91
change ev_op_iterations
evagroenendijk Apr 23, 2026
5b931b6
Adjusted function in cli and changed last thing in evolve.py
evagroenendijk Apr 23, 2026
a2973ab
Merge branch 'remove_template' of github.com:NNPDF/pineko into remove…
evagroenendijk Apr 23, 2026
53b193b
Change ValueError of evolution method
evagroenendijk Apr 23, 2026
d8332f9
Adjust evolve benchmark
evagroenendijk Apr 27, 2026
4c9ee46
Change ValueError into warning
evagroenendijk May 5, 2026
7b06030
Change error into warning and remove unnecessary import
evagroenendijk May 5, 2026
b714df0
Add missing keys to template
evagroenendijk May 18, 2026
8e23b88
fix formatting of scripts and change debug settings to false
evagroenendijk May 18, 2026
3664fa2
Last changes to pass last test, had forgotten some keys in template.py
evagroenendijk May 19, 2026
89304e2
new regression data
evagroenendijk May 19, 2026
4e0fde0
Removed _template from & added extra keys to CLI & evolution method f…
evagroenendijk May 21, 2026
37242b3
Set inversion method to expanded for truncated and exact for iterate-…
evagroenendijk May 21, 2026
7a3167c
Remove time_like and polarized keys from operator card
evagroenendijk May 21, 2026
b7ba5e1
Add early exit if ModEv or IterEv are not set in theory card
evagroenendijk May 25, 2026
9240191
Remove NEEDED_FILES
evagroenendijk May 25, 2026
ad4ceda
Fix mistake in scaffold.py
evagroenendijk May 25, 2026
979e5b6
Merge branch 'main' into remove_template
evagroenendijk May 25, 2026
4dd2298
Changes from pre-commit
evagroenendijk May 25, 2026
9fc1570
Apply suggestion from @felixhekhorn
felixhekhorn May 26, 2026
5fc8b6b
Add cli options to fonll commands
evagroenendijk May 27, 2026
d45f340
Merge branch 'remove_template' of github.com:NNPDF/pineko into remove…
evagroenendijk May 27, 2026
515c806
Remove ipd and iil from fonll ekos command
evagroenendijk May 28, 2026
dd06d83
Remove some unnecessary keys
evagroenendijk May 29, 2026
406fe39
Apply suggestion from @felixhekhorn to let n_cores be set to default …
evagroenendijk Jun 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 13 additions & 21 deletions src/pineko/evolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from eko.matchings import Atlas, nf_default
from eko.quantities import heavy_quarks

from . import check, comparator, version
from . import check, comparator, version, template

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -76,7 +76,6 @@ def get_convolution_suffix(convolution: pineappl.convolutions.Conv) -> str:

def write_operator_card_from_file(
pineappl_path: os.PathLike,
default_card_path: os.PathLike,
card_path: os.PathLike,
tcard: dict,
):
Expand All @@ -86,8 +85,6 @@ def write_operator_card_from_file(
----------
pineappl_path : str or os.PathLike
path to grid to evolve
default_card : str or os.PathLike
base operator card
card_path : str or os.PathLike
target path
tcard: dict
Expand All @@ -106,12 +103,7 @@ def write_operator_card_from_file(
raise FileNotFoundError(pineappl_path)
pineappl_grid = pineappl.grid.Grid.read(pineappl_path)
pineappl_grid.optimize()
default_card = yaml.safe_load(
pathlib.Path(default_card_path).read_text(encoding="utf-8")
)

return write_operator_card(pineappl_grid, default_card, card_path, tcard)

return write_operator_card(pineappl_grid, card_path, tcard)

def dump_card(
card_path: Union[str, os.PathLike],
Expand Down Expand Up @@ -148,7 +140,6 @@ def dump_card(

def write_operator_card(
pineappl_grid: pineappl.grid.Grid,
default_card: dict,
card_path: Union[str, os.PathLike],
tcard: dict,
):
Expand All @@ -158,8 +149,6 @@ def write_operator_card(
----------
pineappl_grid : pineappl.grid.Grid
grid to evolve
default_card : dict
base operator card
card_path : str or os.PathLike
target path
tcard: dict
Expand All @@ -186,18 +175,19 @@ def write_operator_card(
# ... to get the x and muF grids for the eko
evol_info = pineappl_grid.evolve_info(order_mask)
muf2_grid = evol_info.fac1
operators_card = copy.deepcopy(default_card)
operators_card = {}
operators_card["configs"] = {}
sv_method = sv_scheme(tcard)
xif = 1.0 if sv_method is not None else tcard["XIF"]
# update scale variation method
operators_card["configs"]["scvar_method"] = sv_method
operators_card["configs"]["scvar_method"] = sv_scheme(tcard)

operators_card["init"] = (tcard["Q0"], tcard["nf0"])
if default_card.get("init") is not None and default_card["init"] != [
if template.CONSTANTS["init"] is not None and template.CONSTANTS["init"] != (
tcard["Q0"],
tcard["nf0"],
]:
raise ValueError("Template declares a value of Q0, nf0 different from theory")
):
raise ValueError("Q0, nf0 from theory different than default")

q2_grid = (xif * xif * muf2_grid).tolist()
masses = np.array([tcard["mc"], tcard["mb"], tcard["mt"]]) ** 2
Expand All @@ -221,6 +211,8 @@ def write_operator_card(
x_grid = np.append(x_grid, 1.0)
operators_card["configs"]["interpolation_polynomial_degree"] = 1
operators_card["xgrid"] = x_grid.tolist()
else:
operators_card["xgrid"] = template.xgrid

# Add the version of eko and pineko to the operator card
# using importlib.metadata.version to get the correct tag in editable mode
Expand All @@ -242,17 +234,17 @@ def write_operator_card(
)

# If the evolution method is defined in the template and it is different, fail
template_method = default_card["configs"].get("evolution_method")
template_method = template.CONSTANTS["configs"]["evolution_method"]
if (
template_method is not None
and template_method != opconf["evolution_method"]
):
raise ValueError(
f"The template and the theory have different evolution method ({template_method} vs {opconf['key']})"
f"Your theory has a different evolution method than the default({template_method} vs {opconf['key']})"
)

# If the change is on the number of iterations, take the template value but warn the user
template_iter = default_card["configs"].get("ev_op_iterations")
template_iter = template.CONSTANTS["configs"]["ev_op_iterations"]
if template_iter is not None and template_method != opconf["ev_op_iterations"]:
opconf["ev_op_iterations"] = template_iter
logger.warning(
Expand Down
71 changes: 71 additions & 0 deletions src/pineko/template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
"""Default settings and interpolation xgrid (previously in _template.yaml)."""
import yaml
from eko.interpolation import XGrid

# Define the interpolation x-grid as previously defined as 'xgrid' in _template.yaml
xgrid = (
[1.9999999999999954e-07,
3.034304765867952e-07,
4.6035014748963906e-07,
6.984208530700364e-07,
1.0596094959101024e-06,
1.607585498470808e-06,
2.438943292891682e-06,
3.7002272069854957e-06,
5.613757716930151e-06,
8.516806677573355e-06,
1.292101569074731e-05,
1.9602505002391748e-05,
2.97384953722449e-05,
4.511438394964044e-05,
6.843744918967896e-05,
0.00010381172986576898,
0.00015745605600841445,
0.00023878782918561914,
0.00036205449638139736,
0.0005487795323670796,
0.0008314068836488144,
0.0012586797144272762,
0.0019034634022867384,
0.0028738675812817515,
0.004328500638820811,
0.006496206194633799,
0.009699159574043398,
0.014375068581090129,
0.02108918668378717,
0.030521584007828916,
0.04341491741702269,
0.060480028754447364,
0.08228122126204893,
0.10914375746330703,
0.14112080644440345,
0.17802566042569432,
0.2195041265003886,
0.2651137041582823,
0.31438740076927585,
0.3668753186482242,
0.4221667753589648,
0.4798989029610255,
0.5397572337880445,
0.601472197967335,
0.6648139482473823,
0.7295868442414312,
0.7956242522922756,
0.8627839323906108,
0.9309440808717544,
1]
)

CONSTANTS = {
"configs": {
"ev_op_iterations": 1,
Comment thread
evagroenendijk marked this conversation as resolved.
Outdated
"evolution_method": "iterate-exact",
"inversion_method": "expanded",
"polarized": False,
"scvar_method": "null",
"time_like": False
},
"init": (1.65, 4),
"eko_version": "0.14.2",
Comment thread
evagroenendijk marked this conversation as resolved.
Outdated
}

2 changes: 0 additions & 2 deletions src/pineko/theory.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,6 @@ def opcard(self, name, grid, tcard):
return
_x_grid, q2_grid = evolve.write_operator_card_from_file(
grid,
self.operator_cards_path
/ configs.configs["paths"]["operator_card_template_name"],
opcard_path,
tcard,
)
Expand Down
23 changes: 0 additions & 23 deletions tests/test_evolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,3 @@ def metadata(self):
return {"convolution_particle_1": 2212, "convolution_particle_2": 11}


def test_write_operator_card_q0(tmp_path):
"""Checks https://github.com/NNPDF/pineko/issues/146"""
p = tmp_path / "q0.yaml"
g = FakePine()
t = copy.deepcopy(default_card)
o = copy.deepcopy(example.raw_operator())
# 1. Same Q0 and init, all ok
t["Q0"] = 5.0
o["init"] = [5.0, 4]
_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["init"][0], t["Q0"])
# 2. Q0 only in theory, all ok
o.pop("init")
_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["init"][0], t["Q0"])
# 3. op is different, raises error
o["init"] = [11.0, 3]
with pytest.raises(ValueError):
_xs, _mu2s = pineko.evolve.write_operator_card(g, o, p, t)