diff --git a/lib/matplotlib/gridspec.py b/lib/matplotlib/gridspec.py index 5aa425b0a66a..577a50b4db1c 100644 --- a/lib/matplotlib/gridspec.py +++ b/lib/matplotlib/gridspec.py @@ -45,9 +45,11 @@ def __init__(self, nrows, ncols, height_ratios=None, width_ratios=None): If not given, all rows will have the same height. """ if not isinstance(nrows, Integral) or nrows <= 0: - raise ValueError(f"Number of rows must be > 0, not {nrows}") + raise ValueError( + f"Number of rows must be a positive integer, not {nrows}") if not isinstance(ncols, Integral) or ncols <= 0: - raise ValueError(f"Number of columns must be > 0, not {ncols}") + raise ValueError( + f"Number of columns must be a positive integer, not {ncols}") self._nrows, self._ncols = nrows, ncols self.set_height_ratios(height_ratios) self.set_width_ratios(width_ratios) diff --git a/lib/matplotlib/tests/test_figure.py b/lib/matplotlib/tests/test_figure.py index bb1623509df9..ce46e4f1eed9 100644 --- a/lib/matplotlib/tests/test_figure.py +++ b/lib/matplotlib/tests/test_figure.py @@ -182,9 +182,11 @@ def test_gca(): def test_add_subplot_invalid(): fig = plt.figure() - with pytest.raises(ValueError, match='Number of columns must be > 0'): + with pytest.raises(ValueError, + match='Number of columns must be a positive integer'): fig.add_subplot(2, 0, 1) - with pytest.raises(ValueError, match='Number of rows must be > 0'): + with pytest.raises(ValueError, + match='Number of rows must be a positive integer'): fig.add_subplot(0, 2, 1) with pytest.raises(ValueError, match='num must be 1 <= num <= 4'): fig.add_subplot(2, 2, 0) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy