Skip to content

Commit

Permalink
Raise explicit ValueError for empty densities argument
Browse files Browse the repository at this point in the history
  • Loading branch information
tpvasconcelos committed Apr 19, 2024
1 parent 302423c commit cf69c73
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/ridgeplot/_figure_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ def get_xy_extrema(densities: Densities) -> tuple[Numeric, Numeric, Numeric, Num
... )
(-2, 4, 0, 4)
"""
if len(densities) == 0:
raise ValueError("The densities array should not be empty.")
x_flat: list[Numeric] = []
y_flat: list[Numeric] = []
for row in densities:
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_figure_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TestGetXYExtrema:

def test_raise_for_empty_sequence(self) -> None:
# Fails for empty sequence
with pytest.raises(ValueError, match="arg is an empty sequence"):
with pytest.raises(ValueError, match="The densities array should not be empty"):
get_xy_extrema(densities=[])

def test_raise_for_non_2d_array(self) -> None:
Expand Down

0 comments on commit cf69c73

Please sign in to comment.