From 5826af38d8e7e258fbf1f9b8b0424222c3ba9589 Mon Sep 17 00:00:00 2001 From: Zahari Kassabov Date: Wed, 9 Nov 2022 13:25:51 +0000 Subject: [PATCH 1/2] Remove additional t0 flags The work on covariance matrices added new flags to control to t0 setting, namely `use_t0_sampling` and `use_t0_fitting`. These were undocumented, and caused bugs in validphys since t0pdfset could be set by either of them. Remove both flags and mandate that the fitting covmat always uses t0 while the sampling covmat never uses it. This removes some footguns and its backwards compatible. It has the minor disadvantage that the fitting covmat implicitly requires use_t0=True, which is redundant, but it only really matters in n3fit and we set the flag there anyway. --- n3fit/src/n3fit/scripts/n3fit_exec.py | 2 -- validphys2/src/validphys/config.py | 45 +++++++-------------------- 2 files changed, 12 insertions(+), 35 deletions(-) diff --git a/n3fit/src/n3fit/scripts/n3fit_exec.py b/n3fit/src/n3fit/scripts/n3fit_exec.py index 264acb4eee..b62142bfb1 100755 --- a/n3fit/src/n3fit/scripts/n3fit_exec.py +++ b/n3fit/src/n3fit/scripts/n3fit_exec.py @@ -158,10 +158,8 @@ def from_yaml(cls, o, *args, **kwargs): N3FIT_FIXED_CONFIG['use_scalevar_uncertainties'] = thconfig.get('use_scalevar_uncertainties', True) #Sampling flags if (sam_t0:=file_content.get('sampling')) is not None: - N3FIT_FIXED_CONFIG['use_t0_sampling'] = sam_t0.get('use_t0', False) N3FIT_FIXED_CONFIG['separate_multiplicative'] = sam_t0.get('separate_multiplicative', True) #Fitting flag - N3FIT_FIXED_CONFIG['use_t0_fitting'] = file_content.get('fitting').get('use_t0', True) file_content.update(N3FIT_FIXED_CONFIG) return cls(file_content, *args, **kwargs) diff --git a/validphys2/src/validphys/config.py b/validphys2/src/validphys/config.py index 099e3e105f..853c282dd4 100644 --- a/validphys2/src/validphys/config.py +++ b/validphys2/src/validphys/config.py @@ -713,7 +713,6 @@ def produce_dataset_inputs_fitting_covmat( self, theory_covmat_flag=False, use_thcovmat_in_fitting=False, - use_t0_fitting=True, ): """ Produces the correct covmat to be used in fitting_data_dict according @@ -723,16 +722,9 @@ def produce_dataset_inputs_fitting_covmat( """ from validphys import covmats - if use_t0_fitting: - if theory_covmat_flag and use_thcovmat_in_fitting: - return covmats.dataset_inputs_t0_total_covmat - else: - return covmats.dataset_inputs_t0_exp_covmat - else: - if theory_covmat_flag and use_thcovmat_in_fitting: - return covmats.dataset_inputs_total_covmat - else: - return covmats.dataset_inputs_exp_covmat + if theory_covmat_flag and use_thcovmat_in_fitting: + return covmats.dataset_inputs_t0_total_covmat + return covmats.dataset_inputs_t0_exp_covmat @configparser.explicit_node def produce_dataset_inputs_sampling_covmat( @@ -740,7 +732,6 @@ def produce_dataset_inputs_sampling_covmat( sep_mult, theory_covmat_flag=False, use_thcovmat_in_sampling=False, - use_t0_sampling=False, ): """ Produces the correct covmat to be used in make_replica according @@ -750,28 +741,16 @@ def produce_dataset_inputs_sampling_covmat( """ from validphys import covmats - if use_t0_sampling: - if theory_covmat_flag and use_thcovmat_in_sampling: - if sep_mult: - return covmats.dataset_inputs_t0_total_covmat_separate - else: - return covmats.dataset_inputs_t0_total_covmat + if theory_covmat_flag and use_thcovmat_in_sampling: + if sep_mult: + return covmats.dataset_inputs_total_covmat_separate else: - if sep_mult: - return covmats.dataset_inputs_t0_exp_covmat_separate - else: - return covmats.dataset_inputs_t0_exp_covmat + return covmats.dataset_inputs_total_covmat else: - if theory_covmat_flag and use_thcovmat_in_sampling: - if sep_mult: - return covmats.dataset_inputs_total_covmat_separate - else: - return covmats.dataset_inputs_total_covmat + if sep_mult: + return covmats.dataset_inputs_exp_covmat_separate else: - if sep_mult: - return covmats.dataset_inputs_exp_covmat_separate - else: - return covmats.dataset_inputs_exp_covmat + return covmats.dataset_inputs_exp_covmat def produce_loaded_theory_covmat( self, @@ -1051,12 +1030,12 @@ def parse_use_t0(self, do_use_t0: bool): # TODO: Find a good name for this def produce_t0set( - self, t0pdfset=None, use_t0_sampling=False, use_t0_fitting=True, + self, t0pdfset=None, use_t0=False, ): """Return the t0set if use_t0 is True and None otherwise. Raises an error if t0 is requested but no t0set is given. """ - if use_t0_sampling or use_t0_fitting: + if use_t0: if not t0pdfset: raise ConfigError("Setting use_t0 requires specifying a valid t0pdfset") return t0pdfset From 98818809baa33471c34e33c4b6048a64eb276a4e Mon Sep 17 00:00:00 2001 From: Zahari Kassabov Date: Mon, 14 Nov 2022 14:25:12 +0000 Subject: [PATCH 2/2] Remove additional t0 configutation from runcards This partly reverts 9a1e9f63a0da1eb56a426ced43ae2b6bcbe4f677 --- doc/sphinx/source/tutorials/thcov_tutorial.rst | 5 ----- n3fit/runcards/examples/Basic_feature_scaling.yml | 2 +- n3fit/runcards/examples/Basic_hyperopt.yml | 2 -- n3fit/runcards/examples/Basic_runcard.yml | 2 -- n3fit/runcards/examples/Basic_runcard_parallel.yml | 1 - n3fit/runcards/examples/DIS_diagonal_l2reg_example.yml | 2 -- n3fit/runcards/examples/Fit_with_theory_covmat.yml | 3 --- n3fit/runcards/examples/developing.yml | 2 -- 8 files changed, 1 insertion(+), 18 deletions(-) diff --git a/doc/sphinx/source/tutorials/thcov_tutorial.rst b/doc/sphinx/source/tutorials/thcov_tutorial.rst index 1a6a6ceb5f..9b654efe57 100644 --- a/doc/sphinx/source/tutorials/thcov_tutorial.rst +++ b/doc/sphinx/source/tutorials/thcov_tutorial.rst @@ -164,11 +164,6 @@ It can be found `here