From ef26286683a0a4585efbe23818579983f329565f Mon Sep 17 00:00:00 2001 From: jacoterh <54140851+jacoterh@users.noreply.github.com> Date: Tue, 26 Nov 2024 10:50:03 +0000 Subject: [PATCH 01/15] making order part of dataset entry --- src/smefit/analyze/pca.py | 1 - src/smefit/chi2.py | 1 - src/smefit/loader.py | 9 ++++----- src/smefit/optimize/analytic.py | 1 - src/smefit/optimize/mc.py | 1 - src/smefit/optimize/ultranest.py | 1 - src/smefit/prefit/__init__.py | 1 - src/smefit/projections/__init__.py | 2 -- tests/test_fisher.py | 1 - tests/test_loader.py | 2 -- tests/test_pca.py | 1 - 11 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/smefit/analyze/pca.py b/src/smefit/analyze/pca.py index bda167c1..b93fdfb1 100644 --- a/src/smefit/analyze/pca.py +++ b/src/smefit/analyze/pca.py @@ -48,7 +48,6 @@ def from_dict(cls, config): config["data_path"], config["datasets"], config["coefficients"], - config["order"], config["use_quad"], config["use_theory_covmat"], config["use_t0"], diff --git a/src/smefit/chi2.py b/src/smefit/chi2.py index 87df6d2a..e0d610ff 100644 --- a/src/smefit/chi2.py +++ b/src/smefit/chi2.py @@ -85,7 +85,6 @@ def __init__(self, run_card, n_replica): run_card["data_path"], run_card["datasets"], run_card["coefficients"], - run_card["order"], run_card["use_quad"], run_card["use_theory_covmat"], False, diff --git a/src/smefit/loader.py b/src/smefit/loader.py index 92daef7b..0fe06c71 100644 --- a/src/smefit/loader.py +++ b/src/smefit/loader.py @@ -485,7 +485,6 @@ def load_datasets( commondata_path, datasets, operators_to_keep, - order, use_quad, use_theory_covmat, use_t0, @@ -507,8 +506,6 @@ def load_datasets( list of datasets to be loaded operators_to_keep: list list of operators for which corrections are loaded - order: "LO", "NLO" - EFT perturbative order use_quad: bool if True loads also |HO| corrections use_theory_covmat: bool @@ -544,11 +541,13 @@ def load_datasets( else: Loader.theory_path = pathlib.Path(commondata_path) - for sset in np.unique(datasets): + datasets_ordered = np.unique(list(datasets.keys())) + + for sset in datasets_ordered: dataset = Loader( sset, operators_to_keep, - order, + datasets[sset]["order"], use_quad, use_theory_covmat, use_multiplicative_prescription, diff --git a/src/smefit/optimize/analytic.py b/src/smefit/optimize/analytic.py index 6aa2ce53..a12433b0 100644 --- a/src/smefit/optimize/analytic.py +++ b/src/smefit/optimize/analytic.py @@ -82,7 +82,6 @@ def from_dict(cls, config): config["data_path"], config["datasets"], config["coefficients"], - config["order"], False, config["use_theory_covmat"], config["use_t0"], diff --git a/src/smefit/optimize/mc.py b/src/smefit/optimize/mc.py index 18aa4878..f7f88b2d 100644 --- a/src/smefit/optimize/mc.py +++ b/src/smefit/optimize/mc.py @@ -121,7 +121,6 @@ def from_dict(cls, config): config["data_path"], config["datasets"], config["coefficients"], - config["order"], config["use_quad"], config["use_theory_covmat"], config["use_t0"], diff --git a/src/smefit/optimize/ultranest.py b/src/smefit/optimize/ultranest.py index 2f05c547..d0a85335 100644 --- a/src/smefit/optimize/ultranest.py +++ b/src/smefit/optimize/ultranest.py @@ -166,7 +166,6 @@ def from_dict(cls, config): config["data_path"], config["datasets"], operators_to_keep, - config["order"], config["use_quad"], config["use_theory_covmat"], config["use_t0"], diff --git a/src/smefit/prefit/__init__.py b/src/smefit/prefit/__init__.py index 3372430c..9251c3b7 100644 --- a/src/smefit/prefit/__init__.py +++ b/src/smefit/prefit/__init__.py @@ -19,7 +19,6 @@ def __init__(self, config): config["data_path"], config["datasets"], config["coefficients"], - config["order"], config["use_quad"], config["use_theory_covmat"], config["use_t0"], diff --git a/src/smefit/projections/__init__.py b/src/smefit/projections/__init__.py index 0e10c9f1..9d240645 100644 --- a/src/smefit/projections/__init__.py +++ b/src/smefit/projections/__init__.py @@ -35,7 +35,6 @@ def __init__( self.dataset_names = dataset_names self.projections_path = projections_path self.coefficients = coefficients - self.order = order self.use_quad = use_quad self.use_theory_covmat = use_theory_covmat self.rot_to_fit_basis = rot_to_fit_basis @@ -47,7 +46,6 @@ def __init__( self.commondata_path, self.dataset_names, self.coefficients, - self.order, self.use_quad, self.use_theory_covmat, self.use_t0, diff --git a/tests/test_fisher.py b/tests/test_fisher.py index dded1795..3363a37b 100644 --- a/tests/test_fisher.py +++ b/tests/test_fisher.py @@ -73,7 +73,6 @@ def test_fisher(): commondata_path, datasets=["data_test5"], operators_to_keep=operators_to_keep, - order="NLO", use_quad=use_quad, use_theory_covmat=True, use_t0=False, diff --git a/tests/test_loader.py b/tests/test_loader.py index 0e3c9149..94a02317 100644 --- a/tests/test_loader.py +++ b/tests/test_loader.py @@ -80,7 +80,6 @@ def test_load_datasets(): commondata_path, datasets=datasets, operators_to_keep=operators_to_keep, - order=order, use_quad=use_quad, use_theory_covmat=True, use_t0=False, @@ -154,7 +153,6 @@ def test_operator_correction_sorted(): commondata_path, datasets=["data_test1"], operators_to_keep=operators_to_keep, - order=order, use_quad=True, use_theory_covmat=True, use_t0=False, diff --git a/tests/test_pca.py b/tests/test_pca.py index af973708..1f01bc11 100644 --- a/tests/test_pca.py +++ b/tests/test_pca.py @@ -19,7 +19,6 @@ commondata_path, datasets=["data_test5"], operators_to_keep=operators_to_keep, - order="NLO", use_quad=True, use_theory_covmat=True, use_t0=False, From 215de08c866e95af54bb705bb5d40d626eefce06 Mon Sep 17 00:00:00 2001 From: jacoterh <54140851+jacoterh@users.noreply.github.com> Date: Tue, 26 Nov 2024 11:34:41 +0000 Subject: [PATCH 02/15] updating tests --- src/smefit/fit_manager.py | 1 - tests/fake_results/fake_results.yaml | 3 +-- tests/test_fisher.py | 5 ++--- tests/test_loader.py | 7 +++++-- tests/test_optimize.py | 16 +++++++++------- tests/test_pca.py | 5 ++--- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/smefit/fit_manager.py b/src/smefit/fit_manager.py index 594f88d3..e46359f5 100644 --- a/src/smefit/fit_manager.py +++ b/src/smefit/fit_manager.py @@ -117,7 +117,6 @@ def load_datasets(self): self.config["data_path"], self.config["datasets"], self.config["coefficients"], - self.config["order"], self.config["use_quad"], self.config["use_theory_covmat"], False, # t0 is not used here because in the report we look at the experimental chi2 diff --git a/tests/fake_results/fake_results.yaml b/tests/fake_results/fake_results.yaml index a5c400b3..fb3e369f 100644 --- a/tests/fake_results/fake_results.yaml +++ b/tests/fake_results/fake_results.yaml @@ -10,14 +10,13 @@ data_path: ./tests/fake_data theory_path: ./tests/fake_data use_quad: False -order: NLO use_theory_covmat: True # Datasets to include datasets: - - data_test5 + data_test5: {"order": "NLO"} # Coefficients to fit coefficients: diff --git a/tests/test_fisher.py b/tests/test_fisher.py index 3363a37b..43ef3056 100644 --- a/tests/test_fisher.py +++ b/tests/test_fisher.py @@ -71,7 +71,7 @@ def test_fisher(): operators_to_keep = np.array(["Op1", "Op2", "Op3"]) dataset = load_datasets( commondata_path, - datasets=["data_test5"], + datasets={"data_test5": {"order": "NLO"}}, operators_to_keep=operators_to_keep, use_quad=use_quad, use_theory_covmat=True, @@ -85,9 +85,8 @@ def test_fisher(): "result_path": None, "result_ID": None, "data_path": commondata_path, - "datasets": ["data_test5"], + "datasets": {"data_test5": {"order": "NLO"}}, "coefficients": coefficients_dict, - "order": "NLO", "use_theory_covmat": True, "theory_path": commondata_path, "use_multiplicative_prescription": True, diff --git a/tests/test_loader.py b/tests/test_loader.py index 94a02317..8b491ad1 100644 --- a/tests/test_loader.py +++ b/tests/test_loader.py @@ -72,10 +72,13 @@ def test_load_datasets(): operators_to_keep = np.array(["Op1", "Op2", "Op4"]) - datasets = ["data_test1", "data_test2"] for use_quad in [True, False]: for order in ["LO", "NLO"]: + datasets = { + "data_test1": {"order": f"{order}"}, + "data_test2": {"order": f"{order}"}, + } loaded_tuple = load_datasets( commondata_path, datasets=datasets, @@ -151,7 +154,7 @@ def test_operator_correction_sorted(): for order in ["LO", "NLO"]: loaded_tuple = load_datasets( commondata_path, - datasets=["data_test1"], + datasets={"data_test1": {"order": f"{order}"}}, operators_to_keep=operators_to_keep, use_quad=True, use_theory_covmat=True, diff --git a/tests/test_optimize.py b/tests/test_optimize.py index a5b5f91f..2e0616d8 100644 --- a/tests/test_optimize.py +++ b/tests/test_optimize.py @@ -170,14 +170,13 @@ path_abs = pathlib.Path(__file__).parent.resolve() -datasets_no_corr = ["data_test1", "data_test2"] +datasets_no_corr = {"data_test1": {"order": "LO"}, "data_test2": {"order": "LO"}} config_no_corr = {} config_no_corr["data_path"] = commondata_path config_no_corr["coefficients"] = coeffs_dict config_no_corr["result_path"] = commondata_path config_no_corr["result_ID"] = "test" config_no_corr["datasets"] = datasets_no_corr -config_no_corr["order"] = "LO" config_no_corr["use_quad"] = True config_no_corr["use_theory_covmat"] = True config_no_corr["use_t0"] = False @@ -270,14 +269,13 @@ chi2_corr_t0_ext = chi2_corr_t0 + chi2_ext -datasets_corr = ["data_test3", "data_test4"] +datasets_corr = {"data_test3": {"order": "LO"}, "data_test4": {"order": "LO"}} config_corr = {} config_corr["data_path"] = commondata_path config_corr["coefficients"] = coeffs_dict config_corr["result_path"] = commondata_path config_corr["result_ID"] = "test" config_corr["datasets"] = datasets_corr -config_corr["order"] = "LO" config_corr["use_quad"] = True config_corr["use_theory_covmat"] = True config_corr["theory_path"] = commondata_path @@ -316,7 +314,8 @@ class TestOptimize_NS: def test_init(self): assert self.test_opt.results_path == commondata_path / "test" np.testing.assert_equal( - self.test_opt.loaded_datasets.ExpNames, datasets_no_corr + self.test_opt.loaded_datasets.ExpNames, + np.unique(list(datasets_no_corr.keys())), ) np.testing.assert_equal( self.test_opt.coefficients.name, ["Op1", "Op2", "Op3", "Op4"] @@ -388,7 +387,8 @@ class TestOptimize_MC: def test_init(self): assert self.test_opt.results_path == commondata_path / "test" np.testing.assert_equal( - self.test_opt.loaded_datasets.ExpNames, datasets_no_corr + self.test_opt.loaded_datasets.ExpNames, + np.unique(list(datasets_no_corr.keys())), ) np.testing.assert_equal( self.test_opt.coefficients.name, ["Op1", "Op2", "Op3", "Op4"] @@ -487,9 +487,11 @@ def test_from_dict(self): opt.analytic.ALOptimizer.from_dict(config_quad) def test_init(self): + assert self.test_opt.results_path == commondata_path / "test" np.testing.assert_equal( - self.test_opt.loaded_datasets.ExpNames, datasets_no_corr + self.test_opt.loaded_datasets.ExpNames, + np.unique(list(datasets_no_corr.keys())), ) np.testing.assert_equal( self.test_opt.coefficients.name, ["Op1", "Op2", "Op3", "Op4"] diff --git a/tests/test_pca.py b/tests/test_pca.py index 1f01bc11..c050a1b6 100644 --- a/tests/test_pca.py +++ b/tests/test_pca.py @@ -17,7 +17,7 @@ dataset = load_datasets( commondata_path, - datasets=["data_test5"], + datasets={"data_test5": {"order": "NLO"}}, operators_to_keep=operators_to_keep, use_quad=True, use_theory_covmat=True, @@ -175,9 +175,8 @@ def test_pca_id(self): pca_coeffs = CoefficientManager.from_dict(pca_coeffs_dict) rotated_datasets = load_datasets( commondata_path, - datasets=["data_test5"], + datasets={"data_test5": {"order": "NLO"}}, operators_to_keep=["PC00", "PC01", "PC02", "Op3"], - order="NLO", use_quad=True, use_theory_covmat=True, use_t0=False, From 8ab83b0f3c12910225b00a1c59804388b420918e Mon Sep 17 00:00:00 2001 From: jacoterh <54140851+jacoterh@users.noreply.github.com> Date: Tue, 26 Nov 2024 11:39:38 +0000 Subject: [PATCH 03/15] codefactor suggestions --- src/smefit/loader.py | 4 +--- src/smefit/projections/__init__.py | 3 --- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/smefit/loader.py b/src/smefit/loader.py index 0fe06c71..ac56a5cf 100644 --- a/src/smefit/loader.py +++ b/src/smefit/loader.py @@ -541,9 +541,7 @@ def load_datasets( else: Loader.theory_path = pathlib.Path(commondata_path) - datasets_ordered = np.unique(list(datasets.keys())) - - for sset in datasets_ordered: + for sset in np.unique(list(datasets.keys())): dataset = Loader( sset, operators_to_keep, diff --git a/src/smefit/projections/__init__.py b/src/smefit/projections/__init__.py index 9d240645..6ed82b19 100644 --- a/src/smefit/projections/__init__.py +++ b/src/smefit/projections/__init__.py @@ -22,7 +22,6 @@ def __init__( dataset_names, projections_path, coefficients, - order, use_quad, use_theory_covmat, rot_to_fit_basis, @@ -83,7 +82,6 @@ def from_config(cls, projection_card): dataset_names = projection_config["datasets"] coefficients = projection_config.get("coefficients", []) - order = projection_config.get("order", "LO") use_quad = projection_config.get("use_quad", False) use_theory_covmat = projection_config.get("use_theory_covmat", True) rot_to_fit_basis = projection_config.get("rot_to_fit_basis", None) @@ -99,7 +97,6 @@ def from_config(cls, projection_card): dataset_names, projections_path, coefficients, - order, use_quad, use_theory_covmat, rot_to_fit_basis, From 3fddae581dfe2914e8212204e910f6d2ec6154ab Mon Sep 17 00:00:00 2001 From: jacoterh <54140851+jacoterh@users.noreply.github.com> Date: Wed, 27 Nov 2024 10:28:34 +0000 Subject: [PATCH 04/15] adding assert statement to check for dict --- src/smefit/analyze/summary.py | 1 - src/smefit/loader.py | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/smefit/analyze/summary.py b/src/smefit/analyze/summary.py index 6ddefcd0..e10ec053 100644 --- a/src/smefit/analyze/summary.py +++ b/src/smefit/analyze/summary.py @@ -69,7 +69,6 @@ def fit_settings(self): summary_dict["EFT order"] = ( "Qudratic" if fit.config["use_quad"] else "Linear" ) - summary_dict["pQCD"] = fit.config["order"] summary_dict["Replicas"] = fit.n_replica label = fit.label.replace(r"\ ", "").replace(r"\rm", "") summaries[label] = summary_dict diff --git a/src/smefit/loader.py b/src/smefit/loader.py index ac56a5cf..88fb7459 100644 --- a/src/smefit/loader.py +++ b/src/smefit/loader.py @@ -502,8 +502,8 @@ def load_datasets( ---------- commondata_path : str, pathlib.Path path to commondata folder, commondata excluded - datasets : list - list of datasets to be loaded + datasets : dict + Dict of datasets to be loaded operators_to_keep: list list of operators for which corrections are loaded use_quad: bool @@ -541,11 +541,21 @@ def load_datasets( else: Loader.theory_path = pathlib.Path(commondata_path) - for sset in np.unique(list(datasets.keys())): + # assert that datasets is a dictionary + assert isinstance(datasets, dict), ( + "The datasets in the runcard must be a nested dictionary with entries of the form dataset: {" + "order" + ": " + "" + "}" + ) + + # load datasets and predictions for each dataset. Assume LO by default. + for sset, sset_details in datasets.items(): dataset = Loader( sset, operators_to_keep, - datasets[sset]["order"], + sset_details.get("order", "LO"), use_quad, use_theory_covmat, use_multiplicative_prescription, From f23f0dbb4fa6159b9038b5aafa6ef7dbe0f76ad5 Mon Sep 17 00:00:00 2001 From: jacoterh <54140851+jacoterh@users.noreply.github.com> Date: Wed, 27 Nov 2024 11:48:44 +0000 Subject: [PATCH 05/15] updating structure of dataset entry in runcard --- docs/source/fitting_code/running.md | 31 ++++++++++++++--------------- src/smefit/loader.py | 18 ++++++----------- tests/test_optimize.py | 6 +++--- 3 files changed, 24 insertions(+), 31 deletions(-) diff --git a/docs/source/fitting_code/running.md b/docs/source/fitting_code/running.md index 58ee34ae..df61df3f 100644 --- a/docs/source/fitting_code/running.md +++ b/docs/source/fitting_code/running.md @@ -41,13 +41,11 @@ theory_path: ``` ### Theory specifications -The perturbative order of the QCD theory prediction (LO or NLO) should be specified using ``order``. -``use_quad`` should be set to ``True`` for a fit with quadratic corrections, ``use_t0`` controls the use +The order in the EFT expansion should be specified by setting ``use_quad`` to either ``True`` or ``False`` to include quadratic or only linear corrections respectively. The option ``use_t0`` controls the use of the ``t0`` prescription and ``use_theory_covmat`` specifies whether or not to use the theory covariance matrix -which can be specified in the theory files. +which can be specified in the theory files. The perturbative order of the theory prediction can be specified per dataset, see [here](./running.html#datasets-to-consider-and-coefficients-to-fit) for more details. ```yaml -order: NLO use_quad: False use_t0: False use_theory_covmat: True @@ -89,22 +87,23 @@ n_samples: 1000 # number of the required samples of the posterior distribution ### Datasets to consider and coefficients to fit The datasets and Wilson coefficients to be included in the analysis must be listed under ``datasets`` -and ``coefficients`` respectively. +and ``coefficients`` respectively. For each dataset, the perturbative order of the theory prediction can be specified +provided it appears in the corresponding theory file. If not specified, the default order is ``LO``. ```yaml datasets: - - ATLAS_tt_8TeV_ljets_Mtt - - ATLAS_tt_8TeV_dilep_Mtt - - CMS_tt_8TeV_ljets_Ytt - - CMS_tt2D_8TeV_dilep_MttYtt - - CMS_tt_13TeV_ljets_2015_Mtt - - CMS_tt_13TeV_dilep_2015_Mtt - - CMS_tt_13TeV_ljets_2016_Mtt - - CMS_tt_13TeV_dilep_2016_Mtt - - ATLAS_tt_13TeV_ljets_2016_Mtt - - ATLAS_CMS_tt_AC_8TeV - - ATLAS_tt_AC_13TeV + - ATLAS_tt_8TeV_ljets_Mtt # assumes LO + - ATLAS_tt_8TeV_dilep_Mtt: {"order": "NLO_QCD"} + - CMS_tt_8TeV_ljets_Ytt: {"order": "NLO_QCD"} + - CMS_tt2D_8TeV_dilep_MttYtt: {"order": "NLO_QCD"} + - CMS_tt_13TeV_ljets_2015_Mtt: {"order": "NLO_QCD"} + - CMS_tt_13TeV_dilep_2015_Mtt: {"order": "NLO_QCD"} + - CMS_tt_13TeV_ljets_2016_Mtt: {"order": "NLO_QCD"} + - CMS_tt_13TeV_dilep_2016_Mtt: {"order": "NLO_QCD"} + - ATLAS_tt_13TeV_ljets_2016_Mtt: {"order": "NLO_QCD"} + - ATLAS_CMS_tt_AC_8TeV: {"order": "NLO_QCD"} + - ATLAS_tt_AC_13TeV: {"order": "NLO_QCD"} ... ... diff --git a/src/smefit/loader.py b/src/smefit/loader.py index 88fb7459..671e59dd 100644 --- a/src/smefit/loader.py +++ b/src/smefit/loader.py @@ -541,21 +541,15 @@ def load_datasets( else: Loader.theory_path = pathlib.Path(commondata_path) - # assert that datasets is a dictionary - assert isinstance(datasets, dict), ( - "The datasets in the runcard must be a nested dictionary with entries of the form dataset: {" - "order" - ": " - "" - "}" - ) + for sset in datasets: + if not isinstance(sset, dict): + sset = {sset: {"order": "LO"}} + dataset_name = list(sset.keys())[0] - # load datasets and predictions for each dataset. Assume LO by default. - for sset, sset_details in datasets.items(): dataset = Loader( - sset, + dataset_name, operators_to_keep, - sset_details.get("order", "LO"), + sset[dataset_name]["order"], use_quad, use_theory_covmat, use_multiplicative_prescription, diff --git a/tests/test_optimize.py b/tests/test_optimize.py index 2e0616d8..1abbcaae 100644 --- a/tests/test_optimize.py +++ b/tests/test_optimize.py @@ -315,7 +315,7 @@ def test_init(self): assert self.test_opt.results_path == commondata_path / "test" np.testing.assert_equal( self.test_opt.loaded_datasets.ExpNames, - np.unique(list(datasets_no_corr.keys())), + sorted(list(datasets_no_corr.keys())), ) np.testing.assert_equal( self.test_opt.coefficients.name, ["Op1", "Op2", "Op3", "Op4"] @@ -388,7 +388,7 @@ def test_init(self): assert self.test_opt.results_path == commondata_path / "test" np.testing.assert_equal( self.test_opt.loaded_datasets.ExpNames, - np.unique(list(datasets_no_corr.keys())), + sorted(list(datasets_no_corr.keys())), ) np.testing.assert_equal( self.test_opt.coefficients.name, ["Op1", "Op2", "Op3", "Op4"] @@ -491,7 +491,7 @@ def test_init(self): assert self.test_opt.results_path == commondata_path / "test" np.testing.assert_equal( self.test_opt.loaded_datasets.ExpNames, - np.unique(list(datasets_no_corr.keys())), + sorted(list(datasets_no_corr.keys())), ) np.testing.assert_equal( self.test_opt.coefficients.name, ["Op1", "Op2", "Op3", "Op4"] From aa52b49686346e5377dd7b2e3f47b745148dba8c Mon Sep 17 00:00:00 2001 From: jacoterh <54140851+jacoterh@users.noreply.github.com> Date: Wed, 27 Nov 2024 14:21:56 +0000 Subject: [PATCH 06/15] updating tests to new dataset format --- docs/source/fitting_code/running.md | 2 +- src/smefit/loader.py | 4 +++- tests/fake_results/fake_results.yaml | 2 +- tests/test_fisher.py | 4 ++-- tests/test_loader.py | 11 ++++++----- tests/test_optimize.py | 12 +++++++----- tests/test_pca.py | 4 ++-- 7 files changed, 22 insertions(+), 17 deletions(-) diff --git a/docs/source/fitting_code/running.md b/docs/source/fitting_code/running.md index df61df3f..b84210cc 100644 --- a/docs/source/fitting_code/running.md +++ b/docs/source/fitting_code/running.md @@ -43,7 +43,7 @@ theory_path: ### Theory specifications The order in the EFT expansion should be specified by setting ``use_quad`` to either ``True`` or ``False`` to include quadratic or only linear corrections respectively. The option ``use_t0`` controls the use of the ``t0`` prescription and ``use_theory_covmat`` specifies whether or not to use the theory covariance matrix -which can be specified in the theory files. The perturbative order of the theory prediction can be specified per dataset, see [here](./running.html#datasets-to-consider-and-coefficients-to-fit) for more details. +which can be specified in the theory files. The perturbative order of the theory prediction can be specified per dataset, see [here](./example.html#datasets-to-consider-and-coefficients-to-fit) for more details. ```yaml use_quad: False diff --git a/src/smefit/loader.py b/src/smefit/loader.py index 671e59dd..50383c23 100644 --- a/src/smefit/loader.py +++ b/src/smefit/loader.py @@ -542,6 +542,8 @@ def load_datasets( Loader.theory_path = pathlib.Path(commondata_path) for sset in datasets: + + # set theory accuracy to LO if not specified if not isinstance(sset, dict): sset = {sset: {"order": "LO"}} dataset_name = list(sset.keys())[0] @@ -555,7 +557,7 @@ def load_datasets( use_multiplicative_prescription, rot_to_fit_basis, ) - exp_name.append(sset) + exp_name.append(dataset_name) n_data_exp.append(dataset.n_data) lumi_exp.append(dataset.lumi) exp_data.extend(dataset.central_values) diff --git a/tests/fake_results/fake_results.yaml b/tests/fake_results/fake_results.yaml index fb3e369f..457dc305 100644 --- a/tests/fake_results/fake_results.yaml +++ b/tests/fake_results/fake_results.yaml @@ -16,7 +16,7 @@ use_theory_covmat: True # Datasets to include datasets: - data_test5: {"order": "NLO"} + - data_test5: {"order": "NLO"} # Coefficients to fit coefficients: diff --git a/tests/test_fisher.py b/tests/test_fisher.py index 43ef3056..4e7f8a78 100644 --- a/tests/test_fisher.py +++ b/tests/test_fisher.py @@ -71,7 +71,7 @@ def test_fisher(): operators_to_keep = np.array(["Op1", "Op2", "Op3"]) dataset = load_datasets( commondata_path, - datasets={"data_test5": {"order": "NLO"}}, + datasets=[{"data_test5": {"order": "NLO"}}], operators_to_keep=operators_to_keep, use_quad=use_quad, use_theory_covmat=True, @@ -85,7 +85,7 @@ def test_fisher(): "result_path": None, "result_ID": None, "data_path": commondata_path, - "datasets": {"data_test5": {"order": "NLO"}}, + "datasets": [{"data_test5": {"order": "NLO"}}], "coefficients": coefficients_dict, "use_theory_covmat": True, "theory_path": commondata_path, diff --git a/tests/test_loader.py b/tests/test_loader.py index 8b491ad1..fab5bb0c 100644 --- a/tests/test_loader.py +++ b/tests/test_loader.py @@ -75,10 +75,10 @@ def test_load_datasets(): for use_quad in [True, False]: for order in ["LO", "NLO"]: - datasets = { - "data_test1": {"order": f"{order}"}, - "data_test2": {"order": f"{order}"}, - } + datasets = [ + {"data_test1": {"order": f"{order}"}}, + {"data_test2": {"order": f"{order}"}}, + ] loaded_tuple = load_datasets( commondata_path, datasets=datasets, @@ -119,6 +119,7 @@ def test_load_datasets(): np.testing.assert_equal(loaded_tuple.OperatorsNames, operators_to_keep) np.testing.assert_equal(loaded_tuple.ExpNames, ["data_test1", "data_test2"]) np.testing.assert_equal(loaded_tuple.NdataExp, [2, 4]) + np.testing.assert_equal(loaded_tuple.LinearCorrections, lin_corr) if use_quad: @@ -154,7 +155,7 @@ def test_operator_correction_sorted(): for order in ["LO", "NLO"]: loaded_tuple = load_datasets( commondata_path, - datasets={"data_test1": {"order": f"{order}"}}, + datasets=[{"data_test1": {"order": f"{order}"}}], operators_to_keep=operators_to_keep, use_quad=True, use_theory_covmat=True, diff --git a/tests/test_optimize.py b/tests/test_optimize.py index 1abbcaae..231b15a4 100644 --- a/tests/test_optimize.py +++ b/tests/test_optimize.py @@ -170,7 +170,7 @@ path_abs = pathlib.Path(__file__).parent.resolve() -datasets_no_corr = {"data_test1": {"order": "LO"}, "data_test2": {"order": "LO"}} +datasets_no_corr = [{"data_test1": {"order": "LO"}}, {"data_test2": {"order": "LO"}}] config_no_corr = {} config_no_corr["data_path"] = commondata_path config_no_corr["coefficients"] = coeffs_dict @@ -269,7 +269,7 @@ chi2_corr_t0_ext = chi2_corr_t0 + chi2_ext -datasets_corr = {"data_test3": {"order": "LO"}, "data_test4": {"order": "LO"}} +datasets_corr = [{"data_test3": {"order": "LO"}}, {"data_test4": {"order": "LO"}}] config_corr = {} config_corr["data_path"] = commondata_path config_corr["coefficients"] = coeffs_dict @@ -313,10 +313,12 @@ class TestOptimize_NS: def test_init(self): assert self.test_opt.results_path == commondata_path / "test" + np.testing.assert_equal( self.test_opt.loaded_datasets.ExpNames, - sorted(list(datasets_no_corr.keys())), + [list(item.keys())[0] for item in datasets_no_corr], ) + np.testing.assert_equal( self.test_opt.coefficients.name, ["Op1", "Op2", "Op3", "Op4"] ) @@ -388,7 +390,7 @@ def test_init(self): assert self.test_opt.results_path == commondata_path / "test" np.testing.assert_equal( self.test_opt.loaded_datasets.ExpNames, - sorted(list(datasets_no_corr.keys())), + [list(item.keys())[0] for item in datasets_no_corr], ) np.testing.assert_equal( self.test_opt.coefficients.name, ["Op1", "Op2", "Op3", "Op4"] @@ -491,7 +493,7 @@ def test_init(self): assert self.test_opt.results_path == commondata_path / "test" np.testing.assert_equal( self.test_opt.loaded_datasets.ExpNames, - sorted(list(datasets_no_corr.keys())), + [list(item.keys())[0] for item in datasets_no_corr], ) np.testing.assert_equal( self.test_opt.coefficients.name, ["Op1", "Op2", "Op3", "Op4"] diff --git a/tests/test_pca.py b/tests/test_pca.py index c050a1b6..956d3dca 100644 --- a/tests/test_pca.py +++ b/tests/test_pca.py @@ -17,7 +17,7 @@ dataset = load_datasets( commondata_path, - datasets={"data_test5": {"order": "NLO"}}, + datasets=[{"data_test5": {"order": "NLO"}}], operators_to_keep=operators_to_keep, use_quad=True, use_theory_covmat=True, @@ -175,7 +175,7 @@ def test_pca_id(self): pca_coeffs = CoefficientManager.from_dict(pca_coeffs_dict) rotated_datasets = load_datasets( commondata_path, - datasets={"data_test5": {"order": "NLO"}}, + datasets=[{"data_test5": {"order": "NLO"}}], operators_to_keep=["PC00", "PC01", "PC02", "Op3"], use_quad=True, use_theory_covmat=True, From e6308b065542c7ad908bc5417b5856aa47459b76 Mon Sep 17 00:00:00 2001 From: jacoterh <54140851+jacoterh@users.noreply.github.com> Date: Wed, 27 Nov 2024 14:28:09 +0000 Subject: [PATCH 07/15] codefactor suggestions --- src/smefit/loader.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/smefit/loader.py b/src/smefit/loader.py index 50383c23..5d7ced96 100644 --- a/src/smefit/loader.py +++ b/src/smefit/loader.py @@ -502,8 +502,8 @@ def load_datasets( ---------- commondata_path : str, pathlib.Path path to commondata folder, commondata excluded - datasets : dict - Dict of datasets to be loaded + datasets : List + List of datasets to be loaded operators_to_keep: list list of operators for which corrections are loaded use_quad: bool @@ -536,22 +536,18 @@ def load_datasets( th_cov = [] Loader.commondata_path = pathlib.Path(commondata_path) - if theory_path is not None: - Loader.theory_path = pathlib.Path(theory_path) - else: - Loader.theory_path = pathlib.Path(commondata_path) + Loader.theory_path = pathlib.Path(theory_path or commondata_path) for sset in datasets: # set theory accuracy to LO if not specified - if not isinstance(sset, dict): - sset = {sset: {"order": "LO"}} + sset_full = {sset: {"order": "LO"}} if not isinstance(sset, dict) else sset dataset_name = list(sset.keys())[0] dataset = Loader( dataset_name, operators_to_keep, - sset[dataset_name]["order"], + sset_full[dataset_name]["order"], use_quad, use_theory_covmat, use_multiplicative_prescription, From 13fe21faaa414aacdb4dd1663dded3c7cba5b204 Mon Sep 17 00:00:00 2001 From: jacoterh <54140851+jacoterh@users.noreply.github.com> Date: Wed, 27 Nov 2024 15:12:07 +0000 Subject: [PATCH 08/15] small fix in variable name --- src/smefit/loader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/smefit/loader.py b/src/smefit/loader.py index 5d7ced96..9829506b 100644 --- a/src/smefit/loader.py +++ b/src/smefit/loader.py @@ -542,7 +542,7 @@ def load_datasets( # set theory accuracy to LO if not specified sset_full = {sset: {"order": "LO"}} if not isinstance(sset, dict) else sset - dataset_name = list(sset.keys())[0] + dataset_name = list(sset_full.keys())[0] dataset = Loader( dataset_name, From 769418b067b69a7a4fe5f763b9b424f09258e118 Mon Sep 17 00:00:00 2001 From: jacoterh <54140851+jacoterh@users.noreply.github.com> Date: Wed, 27 Nov 2024 15:33:25 +0000 Subject: [PATCH 09/15] updating rge to new dataset format --- src/smefit/rge.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/smefit/rge.py b/src/smefit/rge.py index c86babd9..04b1feaf 100644 --- a/src/smefit/rge.py +++ b/src/smefit/rge.py @@ -377,11 +377,15 @@ def load_scales(datasets, theory_path, default_scale=1e3): list of scales for the datasets """ scales = [] - for dataset in np.unique(datasets): + for dataset in datasets: + + # dataset can be either a string or a dictionary, extract name based on this + dataset_name = list(dataset.keys())[0] if isinstance(dataset, dict) else dataset + Loader.theory_path = pathlib.Path(theory_path) # dummy call just to get the scales _, _, _, _, dataset_scales = Loader.load_theory( - dataset, + dataset_name, operators_to_keep={}, order="LO", use_quad=False, From 1851cbd73f6bc657135bde0dd576adbe61963ca0 Mon Sep 17 00:00:00 2001 From: jacoterh <54140851+jacoterh@users.noreply.github.com> Date: Wed, 27 Nov 2024 23:07:11 +0000 Subject: [PATCH 10/15] making all dataset entries of same type --- docs/source/fitting_code/running.md | 40 ++++++++++++++++++---------- src/smefit/analyze/pca.py | 1 + src/smefit/chi2.py | 1 + src/smefit/fit_manager.py | 1 + src/smefit/loader.py | 10 +++---- src/smefit/optimize/analytic.py | 1 + src/smefit/optimize/mc.py | 1 + src/smefit/optimize/ultranest.py | 1 + src/smefit/prefit/__init__.py | 1 + src/smefit/projections/__init__.py | 15 +++++++---- src/smefit/rge.py | 5 +--- tests/fake_results/fake_results.yaml | 3 ++- tests/test_fisher.py | 4 +-- tests/test_loader.py | 6 ++--- tests/test_optimize.py | 16 +++++++---- tests/test_pca.py | 4 +-- 16 files changed, 69 insertions(+), 41 deletions(-) diff --git a/docs/source/fitting_code/running.md b/docs/source/fitting_code/running.md index b84210cc..c99195f8 100644 --- a/docs/source/fitting_code/running.md +++ b/docs/source/fitting_code/running.md @@ -41,11 +41,14 @@ theory_path: ``` ### Theory specifications +The default perturbative order of the theory prediction is set by the key ``default_order``. Orders may also be specified +per datset, see [here](./example.html#datasets-to-consider-and-coefficients-to-fit) for more details. The order in the EFT expansion should be specified by setting ``use_quad`` to either ``True`` or ``False`` to include quadratic or only linear corrections respectively. The option ``use_t0`` controls the use of the ``t0`` prescription and ``use_theory_covmat`` specifies whether or not to use the theory covariance matrix -which can be specified in the theory files. The perturbative order of the theory prediction can be specified per dataset, see [here](./example.html#datasets-to-consider-and-coefficients-to-fit) for more details. +which can be specified in the theory files. ```yaml +default_order: LO use_quad: False use_t0: False use_theory_covmat: True @@ -87,23 +90,32 @@ n_samples: 1000 # number of the required samples of the posterior distribution ### Datasets to consider and coefficients to fit The datasets and Wilson coefficients to be included in the analysis must be listed under ``datasets`` -and ``coefficients`` respectively. For each dataset, the perturbative order of the theory prediction can be specified -provided it appears in the corresponding theory file. If not specified, the default order is ``LO``. +and ``coefficients`` respectively. The default order for each dataset is taken from ``default_order``. However, it is +possible to specify specific orders per dataset. To do this, add the key ``order`` to the dataset entry as follows. ```yaml datasets: - - ATLAS_tt_8TeV_ljets_Mtt # assumes LO - - ATLAS_tt_8TeV_dilep_Mtt: {"order": "NLO_QCD"} - - CMS_tt_8TeV_ljets_Ytt: {"order": "NLO_QCD"} - - CMS_tt2D_8TeV_dilep_MttYtt: {"order": "NLO_QCD"} - - CMS_tt_13TeV_ljets_2015_Mtt: {"order": "NLO_QCD"} - - CMS_tt_13TeV_dilep_2015_Mtt: {"order": "NLO_QCD"} - - CMS_tt_13TeV_ljets_2016_Mtt: {"order": "NLO_QCD"} - - CMS_tt_13TeV_dilep_2016_Mtt: {"order": "NLO_QCD"} - - ATLAS_tt_13TeV_ljets_2016_Mtt: {"order": "NLO_QCD"} - - ATLAS_CMS_tt_AC_8TeV: {"order": "NLO_QCD"} - - ATLAS_tt_AC_13TeV: {"order": "NLO_QCD"} + - name: ATLAS_tt_8TeV_ljets_Mtt + - name: ATLAS_tt_8TeV_dilep_Mtt + order: NLO_QCD + - name: CMS_tt_8TeV_ljets_Ytt + order: NLO_QCD + - name: CMS_tt2D_8TeV_dilep_MttYtt + order: NLO_QCD + - name: CMS_tt_13TeV_ljets_2015_Mtt + order: NLO_QCD + - name: CMS_tt_13TeV_dilep_2015_Mtt + order: NLO_QCD + - name: CMS_tt_13TeV_ljets_2016_Mtt + order: NLO_QCD + - name: CMS_tt_13TeV_dilep_2016_Mtt + order: NLO_QCD + - name: ATLAS_tt_13TeV_ljets_2016_Mtt + order: NLO_QCD + - name: ATLAS_CMS_tt_AC_8TeV + order: NLO_QCD + - name: ATLAS_tt_AC_13TeV ... ... diff --git a/src/smefit/analyze/pca.py b/src/smefit/analyze/pca.py index b93fdfb1..c10d5d8b 100644 --- a/src/smefit/analyze/pca.py +++ b/src/smefit/analyze/pca.py @@ -52,6 +52,7 @@ def from_dict(cls, config): config["use_theory_covmat"], config["use_t0"], config.get("use_multiplicative_prescription", False), + config.get("default_order", "LO"), config.get("theory_path", None), config.get("rot_to_fit_basis", None), config.get("uv_couplings", False), diff --git a/src/smefit/chi2.py b/src/smefit/chi2.py index e0d610ff..e12b3b25 100644 --- a/src/smefit/chi2.py +++ b/src/smefit/chi2.py @@ -89,6 +89,7 @@ def __init__(self, run_card, n_replica): run_card["use_theory_covmat"], False, self.use_multiplicative_prescription, + run_card.get("default_order", "LO"), run_card.get("theory_path", None), run_card.get("rot_to_fit_basis", None), run_card.get("uv_couplings", False), diff --git a/src/smefit/fit_manager.py b/src/smefit/fit_manager.py index e46359f5..49853f17 100644 --- a/src/smefit/fit_manager.py +++ b/src/smefit/fit_manager.py @@ -121,6 +121,7 @@ def load_datasets(self): self.config["use_theory_covmat"], False, # t0 is not used here because in the report we look at the experimental chi2 self.config.get("use_multiplicative_prescription", False), + self.config.get("default_order", "LO"), self.config.get("theory_path", None), self.config.get("rot_to_fit_basis", None), self.config.get("uv_couplings", False), diff --git a/src/smefit/loader.py b/src/smefit/loader.py index 9829506b..55d759e4 100644 --- a/src/smefit/loader.py +++ b/src/smefit/loader.py @@ -489,6 +489,7 @@ def load_datasets( use_theory_covmat, use_t0, use_multiplicative_prescription, + default_order="LO", theory_path=None, rot_to_fit_basis=None, has_uv_couplings=False, @@ -506,6 +507,8 @@ def load_datasets( List of datasets to be loaded operators_to_keep: list list of operators for which corrections are loaded + order: str + Default perturbative order of the theory predictions use_quad: bool if True loads also |HO| corrections use_theory_covmat: bool @@ -539,15 +542,12 @@ def load_datasets( Loader.theory_path = pathlib.Path(theory_path or commondata_path) for sset in datasets: - - # set theory accuracy to LO if not specified - sset_full = {sset: {"order": "LO"}} if not isinstance(sset, dict) else sset - dataset_name = list(sset_full.keys())[0] + dataset_name = sset.get("name") dataset = Loader( dataset_name, operators_to_keep, - sset_full[dataset_name]["order"], + sset.get("order", default_order), use_quad, use_theory_covmat, use_multiplicative_prescription, diff --git a/src/smefit/optimize/analytic.py b/src/smefit/optimize/analytic.py index a12433b0..fb0bfebc 100644 --- a/src/smefit/optimize/analytic.py +++ b/src/smefit/optimize/analytic.py @@ -86,6 +86,7 @@ def from_dict(cls, config): config["use_theory_covmat"], config["use_t0"], False, + config.get("default_order", "LO"), config.get("theory_path", None), config.get("rot_to_fit_basis", None), config.get("uv_couplings", False), diff --git a/src/smefit/optimize/mc.py b/src/smefit/optimize/mc.py index f7f88b2d..67a65bae 100644 --- a/src/smefit/optimize/mc.py +++ b/src/smefit/optimize/mc.py @@ -125,6 +125,7 @@ def from_dict(cls, config): config["use_theory_covmat"], config["use_t0"], config.get("use_multiplicative_prescription", False), + config.get("default_order", "LO"), config.get("theory_path", None), config.get("rot_to_fit_basis", None), config.get("uv_couplings", False), diff --git a/src/smefit/optimize/ultranest.py b/src/smefit/optimize/ultranest.py index d0a85335..f307c568 100644 --- a/src/smefit/optimize/ultranest.py +++ b/src/smefit/optimize/ultranest.py @@ -170,6 +170,7 @@ def from_dict(cls, config): config["use_theory_covmat"], config["use_t0"], config.get("use_multiplicative_prescription", False), + config.get("default_order", "LO"), config.get("theory_path", None), config.get("rot_to_fit_basis", None), config.get("uv_couplings", False), diff --git a/src/smefit/prefit/__init__.py b/src/smefit/prefit/__init__.py index 9251c3b7..47f067fd 100644 --- a/src/smefit/prefit/__init__.py +++ b/src/smefit/prefit/__init__.py @@ -23,6 +23,7 @@ def __init__(self, config): config["use_theory_covmat"], config["use_t0"], False, + config.get("default_order", "LO"), config.get("theory_path", None), config.get("rot_to_fit_basis", None), config.get("uv_couplings", False), diff --git a/src/smefit/projections/__init__.py b/src/smefit/projections/__init__.py index 6ed82b19..209fb30c 100644 --- a/src/smefit/projections/__init__.py +++ b/src/smefit/projections/__init__.py @@ -19,9 +19,10 @@ def __init__( self, commondata_path, theory_path, - dataset_names, + datasets, projections_path, coefficients, + default_order, use_quad, use_theory_covmat, rot_to_fit_basis, @@ -31,9 +32,10 @@ def __init__( ): self.commondata_path = commondata_path self.theory_path = theory_path - self.dataset_names = dataset_names + self.datasets = datasets self.projections_path = projections_path self.coefficients = coefficients + self.default_order = default_order self.use_quad = use_quad self.use_theory_covmat = use_theory_covmat self.rot_to_fit_basis = rot_to_fit_basis @@ -43,12 +45,13 @@ def __init__( self.datasets = load_datasets( self.commondata_path, - self.dataset_names, + self.datasets, self.coefficients, self.use_quad, self.use_theory_covmat, self.use_t0, False, + self.default_order, theory_path=self.theory_path, ) @@ -79,9 +82,10 @@ def from_config(cls, projection_card): projections_path = pathlib.Path( projection_config["projections_path"] ).absolute() - dataset_names = projection_config["datasets"] + datasets = projection_config["datasets"] coefficients = projection_config.get("coefficients", []) + default_order = projection_config.get("default_order", "LO") use_quad = projection_config.get("use_quad", False) use_theory_covmat = projection_config.get("use_theory_covmat", True) rot_to_fit_basis = projection_config.get("rot_to_fit_basis", None) @@ -94,9 +98,10 @@ def from_config(cls, projection_card): return cls( commondata_path, theory_path, - dataset_names, + datasets, projections_path, coefficients, + default_order, use_quad, use_theory_covmat, rot_to_fit_basis, diff --git a/src/smefit/rge.py b/src/smefit/rge.py index 04b1feaf..f7cfa26f 100644 --- a/src/smefit/rge.py +++ b/src/smefit/rge.py @@ -379,13 +379,10 @@ def load_scales(datasets, theory_path, default_scale=1e3): scales = [] for dataset in datasets: - # dataset can be either a string or a dictionary, extract name based on this - dataset_name = list(dataset.keys())[0] if isinstance(dataset, dict) else dataset - Loader.theory_path = pathlib.Path(theory_path) # dummy call just to get the scales _, _, _, _, dataset_scales = Loader.load_theory( - dataset_name, + dataset.get("name"), operators_to_keep={}, order="LO", use_quad=False, diff --git a/tests/fake_results/fake_results.yaml b/tests/fake_results/fake_results.yaml index 457dc305..2fd1ff0e 100644 --- a/tests/fake_results/fake_results.yaml +++ b/tests/fake_results/fake_results.yaml @@ -16,7 +16,8 @@ use_theory_covmat: True # Datasets to include datasets: - - data_test5: {"order": "NLO"} + - name: data_test5 + order: "NLO" # Coefficients to fit coefficients: diff --git a/tests/test_fisher.py b/tests/test_fisher.py index 4e7f8a78..56694b15 100644 --- a/tests/test_fisher.py +++ b/tests/test_fisher.py @@ -71,7 +71,7 @@ def test_fisher(): operators_to_keep = np.array(["Op1", "Op2", "Op3"]) dataset = load_datasets( commondata_path, - datasets=[{"data_test5": {"order": "NLO"}}], + datasets=[{"name": "data_test5", "order": "NLO"}], operators_to_keep=operators_to_keep, use_quad=use_quad, use_theory_covmat=True, @@ -85,7 +85,7 @@ def test_fisher(): "result_path": None, "result_ID": None, "data_path": commondata_path, - "datasets": [{"data_test5": {"order": "NLO"}}], + "datasets": [{"name": "data_test5", "order": "NLO"}], "coefficients": coefficients_dict, "use_theory_covmat": True, "theory_path": commondata_path, diff --git a/tests/test_loader.py b/tests/test_loader.py index fab5bb0c..f5d7c167 100644 --- a/tests/test_loader.py +++ b/tests/test_loader.py @@ -76,8 +76,8 @@ def test_load_datasets(): for use_quad in [True, False]: for order in ["LO", "NLO"]: datasets = [ - {"data_test1": {"order": f"{order}"}}, - {"data_test2": {"order": f"{order}"}}, + {"name": "data_test1", "order": f"{order}"}, + {"name": "data_test2", "order": f"{order}"}, ] loaded_tuple = load_datasets( commondata_path, @@ -155,7 +155,7 @@ def test_operator_correction_sorted(): for order in ["LO", "NLO"]: loaded_tuple = load_datasets( commondata_path, - datasets=[{"data_test1": {"order": f"{order}"}}], + datasets=[{"name": "data_test1", "order": f"{order}"}], operators_to_keep=operators_to_keep, use_quad=True, use_theory_covmat=True, diff --git a/tests/test_optimize.py b/tests/test_optimize.py index 231b15a4..b5022455 100644 --- a/tests/test_optimize.py +++ b/tests/test_optimize.py @@ -170,7 +170,10 @@ path_abs = pathlib.Path(__file__).parent.resolve() -datasets_no_corr = [{"data_test1": {"order": "LO"}}, {"data_test2": {"order": "LO"}}] +datasets_no_corr = [ + {"name": "data_test1", "order": "LO"}, + {"name": "data_test2", "order": "LO"}, +] config_no_corr = {} config_no_corr["data_path"] = commondata_path config_no_corr["coefficients"] = coeffs_dict @@ -269,7 +272,10 @@ chi2_corr_t0_ext = chi2_corr_t0 + chi2_ext -datasets_corr = [{"data_test3": {"order": "LO"}}, {"data_test4": {"order": "LO"}}] +datasets_corr = [ + {"name": "data_test3", "order": "LO"}, + {"name": "data_test4", "order": "LO"}, +] config_corr = {} config_corr["data_path"] = commondata_path config_corr["coefficients"] = coeffs_dict @@ -316,7 +322,7 @@ def test_init(self): np.testing.assert_equal( self.test_opt.loaded_datasets.ExpNames, - [list(item.keys())[0] for item in datasets_no_corr], + [dataset.get("name") for dataset in datasets_no_corr], ) np.testing.assert_equal( @@ -390,7 +396,7 @@ def test_init(self): assert self.test_opt.results_path == commondata_path / "test" np.testing.assert_equal( self.test_opt.loaded_datasets.ExpNames, - [list(item.keys())[0] for item in datasets_no_corr], + [dataset.get("name") for dataset in datasets_no_corr], ) np.testing.assert_equal( self.test_opt.coefficients.name, ["Op1", "Op2", "Op3", "Op4"] @@ -493,7 +499,7 @@ def test_init(self): assert self.test_opt.results_path == commondata_path / "test" np.testing.assert_equal( self.test_opt.loaded_datasets.ExpNames, - [list(item.keys())[0] for item in datasets_no_corr], + [dataset.get("name") for dataset in datasets_no_corr], ) np.testing.assert_equal( self.test_opt.coefficients.name, ["Op1", "Op2", "Op3", "Op4"] diff --git a/tests/test_pca.py b/tests/test_pca.py index 956d3dca..169bc568 100644 --- a/tests/test_pca.py +++ b/tests/test_pca.py @@ -17,7 +17,7 @@ dataset = load_datasets( commondata_path, - datasets=[{"data_test5": {"order": "NLO"}}], + datasets=[{"name": "data_test5", "order": "NLO"}], operators_to_keep=operators_to_keep, use_quad=True, use_theory_covmat=True, @@ -175,7 +175,7 @@ def test_pca_id(self): pca_coeffs = CoefficientManager.from_dict(pca_coeffs_dict) rotated_datasets = load_datasets( commondata_path, - datasets=[{"data_test5": {"order": "NLO"}}], + datasets=[{"name": "data_test5", "order": "NLO"}], operators_to_keep=["PC00", "PC01", "PC02", "Op3"], use_quad=True, use_theory_covmat=True, From f40c7683aaeb61759ce67784467c0a53f1e594da Mon Sep 17 00:00:00 2001 From: Luca Mantani Date: Thu, 28 Nov 2024 22:57:59 +0100 Subject: [PATCH 11/15] Fixed bug introduced by mistake --- src/smefit/loader.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/smefit/loader.py b/src/smefit/loader.py index aec0d8b7..ea4549ed 100644 --- a/src/smefit/loader.py +++ b/src/smefit/loader.py @@ -604,12 +604,10 @@ def load_datasets( Loader.commondata_path = pathlib.Path(commondata_path) Loader.theory_path = pathlib.Path(theory_path or commondata_path) + _logger.info(f"Applying cutoff scale: {cutoff_scale} GeV.") for sset in datasets: dataset_name = sset.get("name") - _logger.info(f"Applying cutoff scale: {cutoff_scale} GeV.") - for sset in np.unique(datasets): - dataset = Loader( dataset_name, operators_to_keep, From 020f609db26d25bf6dd858f2cdabaa9d640b0d8b Mon Sep 17 00:00:00 2001 From: Luca Mantani Date: Thu, 28 Nov 2024 23:02:50 +0100 Subject: [PATCH 12/15] Remove too-many-statements --- .pylintrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.pylintrc b/.pylintrc index ef3ba76d..0ae1ec5d 100644 --- a/.pylintrc +++ b/.pylintrc @@ -130,7 +130,8 @@ disable= global-statement, too-many-public-method, too-many-ancestors, - too-many-positional-arguments + too-many-positional-arguments, + too-many-statements # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option From f8c40c41245fbed9c093d325a2515dc10c21d3de Mon Sep 17 00:00:00 2001 From: Luca Mantani Date: Thu, 28 Nov 2024 23:07:11 +0100 Subject: [PATCH 13/15] docstring typo --- src/smefit/loader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/smefit/loader.py b/src/smefit/loader.py index ea4549ed..96bb380d 100644 --- a/src/smefit/loader.py +++ b/src/smefit/loader.py @@ -568,7 +568,7 @@ def load_datasets( List of datasets to be loaded operators_to_keep: list list of operators for which corrections are loaded - order: str + default_order: str Default perturbative order of the theory predictions use_quad: bool if True loads also |HO| corrections From ea2ddbcbfcf37b0394b7529fa95fe96d25fcaaf2 Mon Sep 17 00:00:00 2001 From: Luca Mantani Date: Thu, 28 Nov 2024 23:23:50 +0100 Subject: [PATCH 14/15] Adapted logging --- src/smefit/rge.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/smefit/rge.py b/src/smefit/rge.py index f36ee835..ee9b87bd 100644 --- a/src/smefit/rge.py +++ b/src/smefit/rge.py @@ -398,7 +398,7 @@ def load_scales(datasets, theory_path, default_scale=1e3, cutoff_scale=None): else: scales.extend([default_scale] * len(dataset_scales)) - _logger.info(f"Loaded scales for dataset {dataset}: {dataset_scales}") + _logger.info(f"Loaded scales for dataset {dataset['name']}: {dataset_scales}") if cutoff_scale is not None: scales = [scale for scale in scales if scale < cutoff_scale] From 85e9bde98979959b02cca38cab17c414a5a11178 Mon Sep 17 00:00:00 2001 From: Jaco ter Hoeve <54140851+jacoterh@users.noreply.github.com> Date: Fri, 29 Nov 2024 10:19:40 +0000 Subject: [PATCH 15/15] Update src/smefit/loader.py Co-authored-by: Giacomo Magni <39065935+giacomomagni@users.noreply.github.com> --- src/smefit/loader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/smefit/loader.py b/src/smefit/loader.py index 96bb380d..05b66804 100644 --- a/src/smefit/loader.py +++ b/src/smefit/loader.py @@ -564,7 +564,7 @@ def load_datasets( ---------- commondata_path : str, pathlib.Path path to commondata folder, commondata excluded - datasets : List + datasets : list List of datasets to be loaded operators_to_keep: list list of operators for which corrections are loaded