Skip to content

Commit

Permalink
add a evolven3fit check action to look for the eko at setupfit time
Browse files Browse the repository at this point in the history
  • Loading branch information
scarlehoff committed May 23, 2024
1 parent d4a0a99 commit 81df2f5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
12 changes: 12 additions & 0 deletions n3fit/src/n3fit/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from n3fit.hyper_optimization import penalties as penalties_module
from n3fit.hyper_optimization.rewards import IMPLEMENTED_LOSSES, IMPLEMENTED_STATS
from reportengine.checks import CheckError, make_argcheck
from validphys.loader import FallbackLoader
from validphys.pdfbases import check_basis

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -485,3 +486,14 @@ def check_polarized_configs(fitting, fitbasis, positivity_bound):
)
if fitting.get("sum_rules", True) and fitting.get("sum_rules") != "TSR":
raise CheckError("The 'sum_rules' key needs to be 'TSR' for polarised PDF fits.")


@make_argcheck
def check_eko_exists(theoryid):
"""Check that an eko for this theory exists.
Since there might still be theories without an associated eko,
this function raises a logger' error instead of an Exception."""
try:
_ = FallbackLoader().check_eko(theoryid.id)
except FileNotFoundError:
log.error(f"No eko found for {theoryid}")
5 changes: 5 additions & 0 deletions n3fit/src/n3fit/n3fit_checks_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,8 @@ def n3fit_checks_action(
double_precision=False,
):
return


@n3fit.checks.check_eko_exists
def evolven3fit_checks_action(theoryid):
return
9 changes: 8 additions & 1 deletion n3fit/src/n3fit/scripts/vp_setupfit.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@
from validphys.app import App
from validphys.config import Config, ConfigError, Environment, EnvironmentError_

SETUPFIT_FIXED_CONFIG = dict(actions_=['datacuts check_t0pdfset', 'theory check_positivity'])
SETUPFIT_FIXED_CONFIG = dict(
actions_=[
'datacuts check_t0pdfset',
'theory check_positivity',
'theory evolven3fit_checks_action',
]
)

SETUPFIT_PROVIDERS = [
'n3fit.n3fit_checks_provider',
Expand Down Expand Up @@ -159,6 +165,7 @@ def from_yaml(cls, o, *args, **kwargs):
SETUPFIT_FIXED_CONFIG['actions_'].append('positivity_bound check_unpolarized_bc')
for k, v in SETUPFIT_DEFAULTS.items():
file_content.setdefault(k, v)

file_content.update(SETUPFIT_FIXED_CONFIG)
return cls(file_content, *args, **kwargs)

Expand Down

0 comments on commit 81df2f5

Please sign in to comment.