Skip to content

Commit

Permalink
style: construct complicated messages before raise statement
Browse files Browse the repository at this point in the history
  • Loading branch information
dvp committed Jul 19, 2024
1 parent d5a3d25 commit 7344dff
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/mckit_meshes/utils/rebin.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,16 +320,18 @@ def shrink_1d(
return bins, a

if low < bins[0] or bins[-1] < low:
raise ValueError(
msg = (
f"Low shrink edge is beyond the bins range: {low:g}"
f" is not in [{bins[0]:g}..{bins[-1]:g}]",
)
raise ValueError(msg)

if high < bins[0] or bins[-1] < high:
raise ValueError(
msg = (
f"High shrink edge is beyond the bins range: {high:g}"
f" is not in [{bins[1]:g}..{bins[-1]:g}]",
f" is not in [{bins[1]:g}..{bins[-1]:g}]"
)
raise ValueError(msg)

left_idx, right_idx = np.digitize([low, high], bins) - 1

Expand Down

0 comments on commit 7344dff

Please sign in to comment.