diff --git a/validphys2/src/validphys/eff_exponents.py b/validphys2/src/validphys/eff_exponents.py index 37ed5afed2..7587045978 100644 --- a/validphys2/src/validphys/eff_exponents.py +++ b/validphys2/src/validphys/eff_exponents.py @@ -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 @@ -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'] @@ -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 diff --git a/validphys2/src/validphys/tests/test_effexponents.py b/validphys2/src/validphys/tests/test_effexponents.py new file mode 100644 index 0000000000..4703a2aa91 --- /dev/null +++ b/validphys2/src/validphys/tests/test_effexponents.py @@ -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