Skip to content

Commit

Permalink
unit test for values out of range in Histogram
Browse files Browse the repository at this point in the history
  • Loading branch information
RenataKrupczak committed Oct 9, 2024
1 parent 8efcd4d commit 3fa1b4e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/test_Histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ def test_add_value_single_number_to_multiple_histograms():
[[0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0]]
),
)

def test_add_value_out_of_range():
# Test adding values out of the range for the histograms
hist = Histogram((0, 10, 10))
values_out = [10, -1, 12.5]
for value in values_out:
with pytest.warns(UserWarning, match=f"Value {value} is out of histogram range."):
hist.add_value(value)
# Check if the histogram data remains unchanged
assert hist.histograms_[-1].sum() == 0


def test_remove_bin_out_of_range():
Expand Down

0 comments on commit 3fa1b4e

Please sign in to comment.