-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into generate_kfactors
- Loading branch information
Showing
30 changed files
with
1,633 additions
and
342 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import pytest | ||
import yaml | ||
|
||
import pineko | ||
|
||
|
||
@pytest.mark.parametrize("theoryid,is_mixed", [(400, False), (208, True)]) | ||
def benchmark_produce_fonll_tcards( | ||
tmp_path, test_files, test_configs, theoryid, is_mixed | ||
): | ||
tcard = pineko.theory_card.load(theoryid) | ||
tcard_paths_list = pineko.fonll.dump_tcards(tcard, tmp_path, theoryid) | ||
# Check they are correct | ||
theorycards = [] | ||
for path in tcard_paths_list: | ||
with open(path, encoding="UTF-8") as f: | ||
theorycards.append(yaml.safe_load(f)) | ||
base_pto = pineko.fonll.FNS_BASE_PTO[tcard["FNS"]] | ||
for num_fonll_tcard, cfg in zip( | ||
theorycards, | ||
pineko.fonll.FNS_CONFIG, | ||
): | ||
po = int(base_pto) + (cfg.delta_pto if is_mixed else 0) | ||
assert num_fonll_tcard["FNS"] == cfg.scheme | ||
assert num_fonll_tcard["NfFF"] == int(cfg.nf) | ||
assert num_fonll_tcard["PTO"] == po - 1 if is_mixed and cfg.asy else po | ||
assert num_fonll_tcard["FONLLParts"] == cfg.parts |
This file contains 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
"""pineko = PineAPPL + EKO.""" | ||
|
||
from .cli import command | ||
from .version import __version__ |
This file contains 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 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 |
---|---|---|
@@ -1,3 +1,14 @@ | ||
"""CLI entry point.""" | ||
from . import check, compare, convolute, gen_sv, kfactor, opcard, scaffold, theory_ | ||
|
||
from . import ( | ||
check, | ||
compare, | ||
convolute, | ||
fonll, | ||
gen_sv, | ||
kfactor, | ||
opcard, | ||
scaffold, | ||
theory_, | ||
) | ||
from ._base import command |
This file contains 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
"""CLI entry point to check compatibility.""" | ||
|
||
from dataclasses import dataclass | ||
from enum import Enum | ||
|
||
|
This file contains 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
"""CLI entry point to comparison grid vs. FK Table.""" | ||
|
||
import click | ||
import pineappl | ||
import rich | ||
|
This file contains 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
"""CLI entry point to convolution.""" | ||
|
||
import click | ||
import eko | ||
import pineappl | ||
|
This file contains 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 |
---|---|---|
@@ -0,0 +1,151 @@ | ||
"""CLI entry point to FONLL.""" | ||
|
||
import pathlib | ||
|
||
import click | ||
import rich | ||
|
||
from .. import configs, fonll, parser, theory_card | ||
from ._base import command | ||
|
||
config_setting = click.option( | ||
"-c", | ||
"--configs", | ||
"cfg", | ||
default=None, | ||
type=click.Path(resolve_path=True, path_type=pathlib.Path), | ||
help="Explicitly specify config file (it has to be a valid TOML file).", | ||
) | ||
|
||
|
||
class TheoryCardError(Exception): | ||
"""Raised when asked for FONLL theory cards with an original tcard as input that is not asking for FONLL.""" | ||
|
||
|
||
class InconsistentInputsError(Exception): | ||
"""Raised if the inputs are not consistent with FONLL.""" | ||
|
||
|
||
def cfgpath(name, grid): | ||
"""Path of the fktable in 'name' called 'grid' if it exists, else None.""" | ||
path = configs.configs["paths"]["fktables"] / name / grid | ||
return path if path.exists() else None | ||
|
||
|
||
def grids_names(yaml_file): | ||
"""Return the list of the grids in the yaml file.""" | ||
yaml_content = parser._load_yaml(yaml_file) | ||
# Turn the operands and the members into paths (and check all of them exist) | ||
ret = [] | ||
for operand in yaml_content["operands"]: | ||
for member in operand: | ||
ret.append(f"{member}.{parser.EXT}") | ||
return ret | ||
|
||
|
||
@command.command("combine_fonll") | ||
@click.argument("theoryID", type=int) | ||
@click.argument("dataset", type=str) | ||
@click.option("--FFNS3", type=int, help="theoryID containing the ffns3 fktable") | ||
@click.option("--FFN03", type=int, help="theoryID containing the ffn03 fktable") | ||
@click.option("--FFNS4til", type=int, help="theoryID containing the ffns4til fktable") | ||
@click.option("--FFNS4bar", type=int, help="theoryID containing the ffns4bar fktable") | ||
@click.option("--FFN04", type=int, help="theoryID containing the ffn04 fktable") | ||
@click.option("--FFNS5til", type=int, help="theoryID containing the ffns5til fktable") | ||
@click.option("--FFNS5bar", type=int, help="theoryID containing the ffns5bar fktable") | ||
@click.option("--overwrite", is_flag=True, help="Allow files to be overwritten") | ||
@config_setting | ||
def subcommand( | ||
theoryid, | ||
dataset, | ||
ffns3, | ||
ffn03, | ||
ffns4til, | ||
ffns4bar, | ||
ffn04, | ||
ffns5til, | ||
ffns5bar, | ||
overwrite, | ||
cfg, | ||
): | ||
"""Combine the different FKs needed to produce the FONLL prescription.""" | ||
path = configs.detect(cfg) | ||
base_configs = configs.load(path) | ||
configs.configs = configs.defaults(base_configs) | ||
if cfg is not None: | ||
print(f"Configurations loaded from '{path}'") | ||
|
||
# Checks | ||
|
||
if not ffns3 or not ffn03: | ||
raise InconsistentInputsError("ffns3 and/or ffn03 is not provided.") | ||
|
||
if ffns4til is None or ffns4bar is None: | ||
raise InconsistentInputsError( | ||
"At least one of ffns4til and ffns4bar should be provided." | ||
) | ||
|
||
# Do we consider two masses, i.e. mc and mb | ||
if any([ffns5til, ffns5bar, ffn04]): | ||
if (ffns5til is None and ffns5bar is None) or ffn04 is None: | ||
raise InconsistentInputsError( | ||
"To include nf5 contributions, ffn04 and at least one between ffns5til and ffns5bar are mandatory" | ||
) | ||
|
||
# Get theory info | ||
tcard = theory_card.load(theoryid) | ||
if tcard["DAMP"] == 1: | ||
if not "DAMPPOWERc" in tcard or not "DAMPPOWERb" in tcard: | ||
raise InconsistentInputsError( | ||
"If DAMP is set, set also DAMPPOWERb and DAMPPOWERc" | ||
) | ||
else: | ||
tcard["DAMPPOWERb"] = 0 | ||
tcard["DAMPPOWERc"] = 0 | ||
# Getting the paths to the grids | ||
grids_name = grids_names(configs.configs["paths"]["ymldb"] / f"{dataset}.yaml") | ||
for grid in grids_name: | ||
# Checking if it already exists | ||
new_fk_path = configs.configs["paths"]["fktables"] / str(theoryid) / grid | ||
if new_fk_path.exists(): | ||
if not overwrite: | ||
rich.print( | ||
f"[green]Success:[/] skipping existing FK Table {new_fk_path}" | ||
) | ||
return | ||
fonll.produce_combined_fk( | ||
*( | ||
cfgpath(str(name), grid) | ||
for name in ( | ||
ffns3, | ||
ffn03, | ||
ffns4til, | ||
ffns4bar, | ||
ffn04, | ||
ffns5til, | ||
ffns5bar, | ||
) | ||
), | ||
theoryid, | ||
damp=(tcard["DAMP"], tcard["DAMPPOWERc"], tcard["DAMPPOWERb"]), | ||
cfg=cfg, | ||
) | ||
if new_fk_path.exists(): | ||
rich.print(f"[green]Success:[/] Wrote FK table to {new_fk_path}") | ||
else: | ||
rich.print(f"[red]Failure:[/]") | ||
|
||
|
||
@command.command("fonll_tcards") | ||
@click.argument("theoryID", type=int) | ||
@config_setting | ||
def fonll_tcards(theoryid, cfg): | ||
"""Produce the FONLL tcards starting from the original tcard given by the theoryID.""" | ||
path = configs.detect(cfg) | ||
base_configs = configs.load(path) | ||
configs.configs = configs.defaults(base_configs) | ||
tcard = theory_card.load(theoryid) | ||
tcard_parent_path = theory_card.path(theoryid).parent | ||
if "FONLL" not in tcard["FNS"]: | ||
raise TheoryCardError("The theorycard does not correspond to an FONLL scheme.") | ||
fonll.dump_tcards(tcard, tcard_parent_path, theoryid) |
This file contains 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
"""CLI entry point to the operator card generation.""" | ||
|
||
import pathlib | ||
|
||
import click | ||
|
Oops, something went wrong.