-
Notifications
You must be signed in to change notification settings - Fork 0
Remove need for _template.yaml #223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
evagroenendijk
wants to merge
33
commits into
main
Choose a base branch
from
remove_template
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 23 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
dd2cb06
Introduction of template.py to contain constants and xgrid
evagroenendijk 51eb28b
Introduction of template.py to contain constants and xgrid
evagroenendijk 756be45
Removal of need of _template.yaml
evagroenendijk ed25c7d
Remove test that checks q0 from theory card & _template.py
evagroenendijk b0350dc
Remove unnecessary stuff from template.py
evagroenendijk 44d784a
Resolve conflicts with master
evagroenendijk 22d9ac2
Forgot to add template.py
evagroenendijk 5f7394b
Remove eko version from template.py
evagroenendijk 7c973d2
changes needed for merge with main
evagroenendijk f560b91
change ev_op_iterations
evagroenendijk 5b931b6
Adjusted function in cli and changed last thing in evolve.py
evagroenendijk a2973ab
Merge branch 'remove_template' of github.com:NNPDF/pineko into remove…
evagroenendijk 53b193b
Change ValueError of evolution method
evagroenendijk d8332f9
Adjust evolve benchmark
evagroenendijk 4c9ee46
Change ValueError into warning
evagroenendijk 7b06030
Change error into warning and remove unnecessary import
evagroenendijk b714df0
Add missing keys to template
evagroenendijk 8e23b88
fix formatting of scripts and change debug settings to false
evagroenendijk 3664fa2
Last changes to pass last test, had forgotten some keys in template.py
evagroenendijk 89304e2
new regression data
evagroenendijk 4e0fde0
Removed _template from & added extra keys to CLI & evolution method f…
evagroenendijk 37242b3
Set inversion method to expanded for truncated and exact for iterate-…
evagroenendijk 7a3167c
Remove time_like and polarized keys from operator card
evagroenendijk b7ba5e1
Add early exit if ModEv or IterEv are not set in theory card
evagroenendijk 9240191
Remove NEEDED_FILES
evagroenendijk ad4ceda
Fix mistake in scaffold.py
evagroenendijk 979e5b6
Merge branch 'main' into remove_template
evagroenendijk 4dd2298
Changes from pre-commit
evagroenendijk 9fc1570
Apply suggestion from @felixhekhorn
felixhekhorn 5fc8b6b
Add cli options to fonll commands
evagroenendijk d45f340
Merge branch 'remove_template' of github.com:NNPDF/pineko into remove…
evagroenendijk 515c806
Remove ipd and iil from fonll ekos command
evagroenendijk dd06d83
Remove some unnecessary keys
evagroenendijk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -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, opcard_template, version | ||||||||
|
|
||||||||
| logger = logging.getLogger(__name__) | ||||||||
|
|
||||||||
|
|
@@ -94,22 +94,31 @@ 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, | ||||||||
| ipd=4, | ||||||||
| iil=True, | ||||||||
| int_cores=1, | ||||||||
| ): | ||||||||
| """Generate operator card for a grid. | ||||||||
|
|
||||||||
| Parameters | ||||||||
| ---------- | ||||||||
| 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 | ||||||||
| theory card for the run | ||||||||
| ipd: | ||||||||
| interpolation polynomial degree, taken from cli. | ||||||||
| Set to default value | ||||||||
| iil: | ||||||||
| interpolation is log, taken from cli. | ||||||||
| Set to default value | ||||||||
| int_cores: | ||||||||
| number of integration cores, taken | ||||||||
| from cli. Set to default value | ||||||||
|
|
||||||||
| Returns | ||||||||
| ------- | ||||||||
|
|
@@ -124,11 +133,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, ipd, iil, int_cores) | ||||||||
|
|
||||||||
|
|
||||||||
| def dump_card( | ||||||||
|
|
@@ -166,23 +171,29 @@ def dump_card( | |||||||
|
|
||||||||
| def write_operator_card( | ||||||||
| pineappl_grid: pineappl.grid.Grid, | ||||||||
| default_card: dict, | ||||||||
| card_path: Union[str, os.PathLike], | ||||||||
| tcard: dict, | ||||||||
| ipd, | ||||||||
| iil, | ||||||||
| int_cores | ||||||||
| ): | ||||||||
| """Generate operator card for this grid. | ||||||||
|
|
||||||||
| Parameters | ||||||||
| ---------- | ||||||||
| pineappl_grid : pineappl.grid.Grid | ||||||||
| grid to evolve | ||||||||
| default_card : dict | ||||||||
| base operator card | ||||||||
| card_path : str or os.PathLike | ||||||||
| target path | ||||||||
| tcard: dict | ||||||||
| theory card for the run, since some information in EKO is now required | ||||||||
| in operator card, but before was in the theory card | ||||||||
| ipd: | ||||||||
| interpolation polynomial degree, taken from cli | ||||||||
| iil: | ||||||||
| interpolation is log, taken from cli | ||||||||
| int_cores: | ||||||||
| number of integration cores, taken from cli | ||||||||
|
|
||||||||
| Returns | ||||||||
| ------- | ||||||||
|
|
@@ -204,18 +215,28 @@ 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["configs"]["ev_op_max_order"] = opcard_template.CONSTANTS["configs"]["ev_op_max_order"] | ||||||||
| operators_card["debug"] = opcard_template.CONSTANTS["debug"] | ||||||||
| operators_card["init"] = (tcard["Q0"], tcard["nf0"]) | ||||||||
| if default_card.get("init") is not None and default_card["init"] != [ | ||||||||
| # setting the parameters from the cli | ||||||||
| operators_card["configs"]["interpolation_polynomial_degree"] = ipd | ||||||||
| operators_card["configs"]["interpolation_is_log"] = iil | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Let's still write cards, which can be executed out of the box (without pineko being present to add stuff) |
||||||||
| operators_card["configs"]["n_integration_cores"] = int_cores | ||||||||
| if opcard_template.CONSTANTS["init"] is not None and opcard_template.CONSTANTS["init"] != ( | ||||||||
| tcard["Q0"], | ||||||||
| tcard["nf0"], | ||||||||
| ]: | ||||||||
| raise ValueError("Template declares a value of Q0, nf0 different from theory") | ||||||||
| ): | ||||||||
| raise logger.warning( | ||||||||
| f"Warning! Q0 and nf0 from your theory are different " | ||||||||
| f"than default settings ({tcard['Q0']}, {tcard['nf0']} vs " | ||||||||
| f"{opcard_template.CONSTANTS['init']}). Check if this is really what you want!" | ||||||||
| ) | ||||||||
|
|
||||||||
| q2_grid = (xif * xif * muf2_grid).tolist() | ||||||||
| # If we are producing nFONLL FKs we need to look to NfFF... | ||||||||
|
|
@@ -232,44 +253,32 @@ 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"] = opcard_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 | ||||||||
| operators_card["eko_version"] = metadata.version("eko") | ||||||||
|
|
||||||||
| # Choose the evolution method according to the theory if the key is included | ||||||||
| if "ModEv" in tcard: | ||||||||
|
evagroenendijk marked this conversation as resolved.
Outdated
|
||||||||
| opconf = operators_card["configs"] | ||||||||
| if tcard["ModEv"] == "TRN": | ||||||||
| opconf["evolution_method"] = "truncated" | ||||||||
| opconf["ev_op_iterations"] = 1 | ||||||||
| operators_card["configs"]["evolution_method"] = "truncated" | ||||||||
| operators_card["configs"]["ev_op_iterations"] = 1 | ||||||||
| operators_card["configs"]["inversion_method"] = "expanded" | ||||||||
|
evagroenendijk marked this conversation as resolved.
Outdated
|
||||||||
| elif tcard["ModEv"] == "EXA": | ||||||||
| opconf["evolution_method"] = "iterate-exact" | ||||||||
| operators_card["configs"]["evolution_method"] = "iterate-exact" | ||||||||
| operators_card["configs"]["inversion_method"] = "exact" | ||||||||
| if "IterEv" in tcard: | ||||||||
| opconf["ev_op_iterations"] = tcard["IterEv"] | ||||||||
| elif "ev_op_iterations" not in default_card["configs"]: | ||||||||
| operators_card["configs"]["ev_op_iterations"] = tcard["IterEv"] | ||||||||
| else: | ||||||||
| raise ValueError( | ||||||||
| "EXA used but IterEv not found in the theory card and not ev_op_iterations set in the template" | ||||||||
| "EXA used but IterEv not found in the theory card" | ||||||||
| ) | ||||||||
|
|
||||||||
| # If the evolution method is defined in the template and it is different, fail | ||||||||
| template_method = default_card["configs"].get("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']})" | ||||||||
| ) | ||||||||
|
|
||||||||
| # 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") | ||||||||
| if template_iter is not None and int(template_iter) != int( | ||||||||
| opconf["ev_op_iterations"] | ||||||||
| ): | ||||||||
| raise ValueError( | ||||||||
| f"The number of iteration in the theory and template is different, ({template_iter} vs {opconf['ev_op_iterations']})" | ||||||||
| ) | ||||||||
| else: | ||||||||
| raise ValueError( | ||||||||
| "Evolution method not set in theory card" | ||||||||
| ) | ||||||||
|
|
||||||||
| # Some safety checks | ||||||||
| if ( | ||||||||
|
|
@@ -286,7 +295,6 @@ def write_operator_card( | |||||||
|
|
||||||||
| for conv in convolutions: | ||||||||
| dump_card(card_path, operators_card, conv) | ||||||||
|
|
||||||||
| return operators_card["xgrid"], q2_grid | ||||||||
|
|
||||||||
|
|
||||||||
|
|
||||||||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.