Skip to content

Commit 9ac473c

Browse files
committed
Update for new thcovmat construction + refactor + docstrings
1 parent df3e322 commit 9ac473c

File tree

3 files changed

+892
-394
lines changed

3 files changed

+892
-394
lines changed

validphys2/src/validphys/config.py

Lines changed: 27 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,28 +1160,6 @@ def produce_loaded_user_covmat_path(self, user_covmat_path: str = ""):
11601160
fileloc = l.check_vp_output_file(user_covmat_path)
11611161
return fileloc
11621162

1163-
@configparser.explicit_node
1164-
def produce_covmat_custom(self, use_ht_uncertainties: bool = False):
1165-
if use_ht_uncertainties:
1166-
from validphys.theorycovariance.construction import thcov_ht
1167-
1168-
return thcov_ht
1169-
else:
1170-
from validphys.theorycovariance.construction import covs_pt_prescrip
1171-
1172-
return covs_pt_prescrip
1173-
1174-
@configparser.explicit_node
1175-
def produce_combine_custom(self, use_ht_uncertainties: bool = False):
1176-
if use_ht_uncertainties:
1177-
from validphys.theorycovariance.construction import combine_by_type_ht
1178-
1179-
return combine_by_type_ht
1180-
else:
1181-
from validphys.theorycovariance.construction import combine_by_type
1182-
1183-
return combine_by_type
1184-
11851163
@configparser.explicit_node
11861164
def produce_nnfit_theory_covmat(
11871165
self, point_prescriptions: list = None, user_covmat_path: str = None
@@ -1208,31 +1186,8 @@ def produce_nnfit_theory_covmat(
12081186
from validphys.theorycovariance.construction import user_covmat_fitting
12091187

12101188
f = user_covmat_fitting
1211-
elif use_ht_uncertainties:
1212-
# NOTE: this covmat is the same as for scale variations, which will result in a clash of
1213-
# table names if we wish to use them simultaneously
1214-
if use_user_uncertainties:
1215-
from validphys.theorycovariance.construction import total_theory_covmat_fitting
1216-
1217-
f = total_theory_covmat_fitting
1218-
else:
1219-
from validphys.theorycovariance.construction import theory_covmat_custom_fitting
1220-
1221-
f = theory_covmat_custom_fitting
12221189

1223-
@functools.wraps(f)
1224-
def res(*args, **kwargs):
1225-
return f(*args, **kwargs)
1226-
1227-
# Set this to get the same filename regardless of the action.
1228-
res.__name__ = "theory_covmat"
1229-
return res
1230-
1231-
@configparser.explicit_node
1232-
def produce_combine_by_type_custom(self, use_ht_uncertainties: bool = False):
1233-
if use_ht_uncertainties:
1234-
return validphys.theorycovariance.construction.combine_by_type_ht
1235-
return validphys.theorycovariance.construction.combine_by_type
1190+
return f
12361191

12371192
def produce_fitthcovmat(
12381193
self, use_thcovmat_if_present: bool = False, fit: (str, type(None)) = None
@@ -1710,6 +1665,8 @@ def produce_theoryids(self, t0id, point_prescription):
17101665
prescription. The options for the latter are defined in pointprescriptions.yaml.
17111666
This hard codes the theories needed for each prescription to avoid user error."""
17121667
th = t0id.id
1668+
if point_prescription == 'power corrections':
1669+
return NSList([t0id], nskey="theoryid")
17131670

17141671
lsv = yaml_safe.load(read_text(validphys.scalevariations, "scalevariationtheoryids.yaml"))
17151672

@@ -1812,6 +1769,30 @@ def produce_total_phi_data(self, fitthcovmat):
18121769
return validphys.results.total_phi_data_from_experiments
18131770
return validphys.results.dataset_inputs_phi_data
18141771

1772+
# @configparser.explicit_node
1773+
def produce_power_corr_dict(self, pc_parameters=None):
1774+
"""The parameters for the power corrections are given as a list.
1775+
This function converts this list into a dictionary with the keys
1776+
being the names of the types of power corrections (e.g. `H2p`, `H2d`,...).
1777+
"""
1778+
if pc_parameters is None:
1779+
return None
1780+
1781+
pc_parameters_by_type = {}
1782+
# Loop over the parameterization for the power corrections in the runcard
1783+
for par in pc_parameters:
1784+
# Check that the length of shifts matches the length of nodes.
1785+
if len(par['yshift']) != len(par['nodes']):
1786+
raise ValueError(
1787+
f"The length of nodes does not match that of the list in {par['ht']}."
1788+
f"Check the runcard. Got {len(par['yshift'])} != {len(par['nodes'])}"
1789+
)
1790+
1791+
# Store parameters for each power correction
1792+
pc_parameters_by_type[par['ht']] = {'yshift': par['yshift'], 'nodes': par['nodes']}
1793+
1794+
return pc_parameters_by_type
1795+
18151796

18161797
class Config(report.Config, CoreConfig):
18171798
"""The effective configuration parser class."""

0 commit comments

Comments
 (0)