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

feat: turn warnings about missing post-processed histograms into info messages #436

Merged
merged 3 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
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