Skip to content

Commit

Permalink
feat: turn warnings about missing post-processed histograms into info…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
alexander-held authored Sep 19, 2023
1 parent a0638e1 commit 2b7c091
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
)
Expand Down
7 changes: 3 additions & 4 deletions src/cabinetry/histo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
10 changes: 4 additions & 6 deletions tests/test_histo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2b7c091

Please sign in to comment.