Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing the grouping and the thcovmat flag #1588

Merged
merged 4 commits into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 5 additions & 2 deletions n3fit/src/n3fit/scripts/n3fit_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,13 @@ def from_yaml(cls, o, *args, **kwargs):
N3FIT_FIXED_CONFIG['actions_'].extend((training_action, validation_action))
#Theorycovmat flags and defaults
N3FIT_FIXED_CONFIG['theory_covmat_flag'] = False
N3FIT_FIXED_CONFIG['use_thcovmat_in_fitting'] = False
N3FIT_FIXED_CONFIG['use_thcovmat_in_sampling'] = False
if (thconfig:=file_content.get('theorycovmatconfig')) is not None:
N3FIT_FIXED_CONFIG['theory_covmat_flag'] = True
N3FIT_FIXED_CONFIG['use_thcovmat_in_fitting'] = thconfig.get('use_thcovmat_in_fitting', True)
N3FIT_FIXED_CONFIG['use_thcovmat_in_sampling'] = thconfig.get('use_thcovmat_in_sampling', True)
N3FIT_FIXED_CONFIG['use_thcovmat_in_sampling'] = thconfig.get('use_thcovmat_in_sampling', True)
if N3FIT_FIXED_CONFIG['use_thcovmat_in_sampling'] or N3FIT_FIXED_CONFIG['use_thcovmat_in_fitting']:
N3FIT_FIXED_CONFIG['theory_covmat_flag'] = True
N3FIT_FIXED_CONFIG['use_user_uncertainties'] = thconfig.get('use_user_uncertainties', False)
N3FIT_FIXED_CONFIG['use_scalevar_uncertainties'] = thconfig.get('use_scalevar_uncertainties', True)
#Sampling flags
Expand Down
16 changes: 4 additions & 12 deletions validphys2/src/validphys/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1584,11 +1584,12 @@ def load_default_data_grouping(self, spec):
# somebody will want to add to this at some point e.g for th. uncertainties
allowed = {
"standard_report": "experiment",
"thcovmat_fit": "ALL"
}
return allowed[spec]

def produce_processed_data_grouping(
self, data_grouping=None, data_grouping_recorded_spec_=None
self, use_thcovmat_in_fitting, use_thcovmat_in_sampling, data_grouping=None, data_grouping_recorded_spec_=None
):
"""Process the data_grouping key from the runcard, or lockfile. If
`data_grouping_recorded_spec_` is present then its value is taken, and
Expand All @@ -1602,6 +1603,8 @@ def produce_processed_data_grouping(
if data_grouping is None:
# fallback to old default behaviour, but still record to lockfile
data_grouping = self.parse_data_grouping("standard_report")
if use_thcovmat_in_fitting or use_thcovmat_in_sampling:
data_grouping = self.parse_data_grouping("thcovmat_fit")
andreab1997 marked this conversation as resolved.
Show resolved Hide resolved
if data_grouping_recorded_spec_ is not None:
return data_grouping_recorded_spec_[data_grouping]
return self.load_default_data_grouping(data_grouping)
Expand Down Expand Up @@ -1653,17 +1656,6 @@ def produce_group_dataset_inputs_by_metadata(
for name, group in res.items()
]

def produce_group_dataset_inputs_by_fitting_group(
self, data_input, theory_covmat_flag
):
"""
Groups datasets all together in a group called ALL if the theory covariance matrix
is used in the fit, otherwise it groups them by experiment.
"""
if theory_covmat_flag:
return self.produce_group_dataset_inputs_by_metadata(data_input, "ALL")
return self.produce_group_dataset_inputs_by_metadata(data_input, "experiment")

def produce_fivetheories(self, point_prescription):
if point_prescription == "5bar point":
return "bar"
Expand Down
2 changes: 1 addition & 1 deletion validphys2/src/validphys/n3fit_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def fitting_data_dict(
return dict_out


exps_fitting_data_dict = collect("fitting_data_dict", ("group_dataset_inputs_by_fitting_group",))
exps_fitting_data_dict = collect("fitting_data_dict", ("group_dataset_inputs_by_metadata",))


def replica_nnseed_fitting_data_dict(replica, exps_fitting_data_dict, replica_nnseed):
Expand Down