Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 7 additions & 5 deletions validphys2/src/validphys/eff_exponents.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,9 @@ def effective_exponents_table_internal(
'effective_exponents_table_internal', ('fitpdfandbasis',))
fmt = lambda a: float(significant_digits(a, 4))

def next_effective_exponents_yaml(fit: FitSpec, effective_exponents_table):
next_fit_eff_exps_table = collect("next_effective_exponents_table", ("fitpdfandbasis",))

def next_effective_exponents_yaml(fit: FitSpec, next_fit_eff_exps_table):
"""-Returns a table in yaml format called NextEffExps.yaml
-Prints the yaml table in the report
using `effective_exponents_table` this provider outputs the yaml runcard to run
Expand All @@ -412,8 +414,8 @@ def next_effective_exponents_yaml(fit: FitSpec, effective_exponents_table):

"""

df_effexps = effective_exponents_table[0]
#Reading from the filter
df_effexps = next_fit_eff_exps_table[0]
# Use round trip loader rather than safe_load in fit.as_input()
with open(fit.path/'filter.yml', 'r') as f:
filtermap = yaml.load(f, yaml.RoundTripLoader)
previous_exponents = filtermap['fitting']['basis']
Expand All @@ -425,8 +427,8 @@ def next_effective_exponents_yaml(fit: FitSpec, effective_exponents_table):
runcard_flavours = basis.to_known_elements(
[ref_fl['fl'] for ref_fl in previous_exponents]).tolist()
for fl in flavours:
alphas = df_effexps.loc[(f'${fl}$', r'$\alpha$'), ['next Min', 'next Max']].values
betas = df_effexps.loc[(f'${fl}$', r'$\beta$'), ['next Min', 'next Max']].values
alphas = df_effexps.loc[(f'${fl}$', r'$\alpha$')].values
betas = df_effexps.loc[(f'${fl}$', r'$\beta$')].values
previous_exponents[runcard_flavours.index(fl)]['smallx'] = [fmt(alpha) for alpha in alphas]
previous_exponents[runcard_flavours.index(fl)]['largex'] = [fmt(beta) for beta in betas]
#iterate t0
Expand Down
20 changes: 20 additions & 0 deletions validphys2/src/validphys/tests/test_effexponents.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import pytest

from validphys.api import API
from validphys.loader import FallbackLoader as Loader

from reportengine.compat import yaml


def test_next_runcard():
l = Loader()
ite1_fit = l.check_fit("191015-mw-001")
# The runcard of a 2nd iteration fit I ran manually
ite2_runcard = l.check_fit("191015-mw-001_ite2_for_testing").as_input()
ite2_runcard.pop("pdf") # Removing the PDF key, it's an artefact of as_input

predicted_ite2_runcard = yaml.safe_load(
API.next_effective_exponents_yaml(fit="191015-mw-001")
)
# Check that the actual ite2 runcard matches what vp thinks it should be
assert predicted_ite2_runcard == ite2_runcard