diff --git a/src/ridgeplot/_figure_factory.py b/src/ridgeplot/_figure_factory.py index dbe94bbe..482f645d 100644 --- a/src/ridgeplot/_figure_factory.py +++ b/src/ridgeplot/_figure_factory.py @@ -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: diff --git a/tests/unit/test_figure_factory.py b/tests/unit/test_figure_factory.py index 54841114..4072b3b6 100644 --- a/tests/unit/test_figure_factory.py +++ b/tests/unit/test_figure_factory.py @@ -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: