From d9c9c5540d7ecf51716971b24a6a42f0ae65e5d4 Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Wed, 23 Dec 2015 22:50:12 +0100 Subject: [PATCH 1/2] Correct regex in filterwarnings The method name has changed, also enable an assert which should have been enabled earlier --- lib/matplotlib/tests/test_subplots.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tests/test_subplots.py b/lib/matplotlib/tests/test_subplots.py index 5af1716821bc..9f4da8724a09 100644 --- a/lib/matplotlib/tests/test_subplots.py +++ b/lib/matplotlib/tests/test_subplots.py @@ -110,11 +110,10 @@ def test_exceptions(): # the pount of this test is to ensure that this raises. with warnings.catch_warnings(): warnings.filterwarnings('ignore', - message='.*sharex\ argument\ to\ subplots', + message='.*sharex\ argument\ to\ add_subplots', category=UserWarning) assert_raises(ValueError, plt.subplots, 2, 2, -1) - # uncomment this for 1.5 - # assert_raises(ValueError, plt.subplots, 2, 2, 0) + assert_raises(ValueError, plt.subplots, 2, 2, 0) assert_raises(ValueError, plt.subplots, 2, 2, 5) From 6979fe5f14fca11960223eaec1f66b7b8e2944ac Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Wed, 23 Dec 2015 23:02:54 +0100 Subject: [PATCH 2/2] Change error message to reflect the name of the method --- lib/matplotlib/figure.py | 4 ++-- lib/matplotlib/tests/test_subplots.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 439785d9fd30..9e8c2402523a 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -1097,8 +1097,8 @@ def subplots(self, nrows=1, ncols=1, sharex=False, sharey=False, # instead treated as a bool for sharex. if isinstance(sharex, int): warnings.warn( - "sharex argument to add_subplots() was an integer. " - "Did you intend to use add_subplot() (without 's')?") + "sharex argument to subplots() was an integer. " + "Did you intend to use subplot() (without 's')?") raise ValueError("sharex [%s] must be one of %s" % (sharex, share_values)) diff --git a/lib/matplotlib/tests/test_subplots.py b/lib/matplotlib/tests/test_subplots.py index 9f4da8724a09..d588f7b4b13b 100644 --- a/lib/matplotlib/tests/test_subplots.py +++ b/lib/matplotlib/tests/test_subplots.py @@ -110,7 +110,7 @@ def test_exceptions(): # the pount of this test is to ensure that this raises. with warnings.catch_warnings(): warnings.filterwarnings('ignore', - message='.*sharex\ argument\ to\ add_subplots', + message='.*sharex\ argument\ to\ subplots', category=UserWarning) assert_raises(ValueError, plt.subplots, 2, 2, -1) assert_raises(ValueError, plt.subplots, 2, 2, 0)