From 2b7c09198e319118706df1133d8c76242388f289 Mon Sep 17 00:00:00 2001 From: Alexander Held <45009355+alexander-held@users.noreply.github.com> Date: Tue, 19 Sep 2023 08:41:36 -0500 Subject: [PATCH] feat: turn warnings about missing post-processed histograms into info messages (#436) * lower warning-level messages when histogram post-processing is not used to info-level messages * temporarily restrict more typeguard versions to avoid typing_extensions conflict due to TensorFlow --- setup.py | 2 +- src/cabinetry/histo.py | 7 +++---- tests/test_histo.py | 10 ++++------ 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/setup.py b/setup.py index 47882015..fc7609ea 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ "mypy", "types-tabulate", "types-PyYAML", - "typeguard>=4.0.0,!=4.0.1,!=4.1.0,!=4.1.1", # cabinetry#391, cabinetry#428 + "typeguard>=4.0.0,!=4.0.1,!=4.1.*", # cabinetry#391, cabinetry#428 "black", ] ) diff --git a/src/cabinetry/histo.py b/src/cabinetry/histo.py index 578591e5..5a6d1329 100644 --- a/src/cabinetry/histo.py +++ b/src/cabinetry/histo.py @@ -79,11 +79,10 @@ def from_path( if modified: histo_path_modified = histo_path.parent / (histo_path.name + "_modified") if not histo_path_modified.with_suffix(".npz").exists(): - log.warning( - f"the modified histogram {histo_path_modified.with_suffix('.npz')} " - "does not exist" + log.info( + f"no modified histogram {histo_path_modified.with_suffix('.npz')} " + "found, loading un-modified histogram" ) - log.warning("loading the un-modified histogram instead!") else: histo_path = histo_path_modified histogram_npz = np.load(histo_path.with_suffix(".npz")) diff --git a/tests/test_histo.py b/tests/test_histo.py index a1e607fc..71a5ea17 100644 --- a/tests/test_histo.py +++ b/tests/test_histo.py @@ -122,13 +122,11 @@ def test_Histogram_from_path(tmp_path, caplog, example_histograms, histogram_hel # try loading a modified one, without success since it does not exist h_from_path_modified = histo.Histogram.from_path(tmp_path, modified=True) - expected_warning = ( - f"the modified histogram {str(tmp_path)}_modified.npz does not exist" + expected_info = ( + f"no modified histogram {str(tmp_path)}_modified.npz found, " + "loading un-modified histogram" ) - assert expected_warning in [rec.message for rec in caplog.records] - assert "loading the un-modified histogram instead!" in [ - rec.message for rec in caplog.records - ] + assert expected_info in [rec.message for rec in caplog.records] caplog.clear() # successfully load a modified histogram