Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 93142c6

Browse files
committed
TST: update message
1 parent 0c315f2 commit 93142c6

File tree

3 files changed

+6
-17
lines changed

3 files changed

+6
-17
lines changed

lib/matplotlib/figure.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,27 +1265,16 @@ def add_subplot(self, *args, **kwargs):
12651265
12661266
Parameters
12671267
----------
1268-
<<<<<<< HEAD
1269-
*args : int, (int, int, *index*), or `.SubplotSpec`, default: (1, 1, 1)
1270-
=======
1271-
*args, int, (int, int, *index*), or `SubplotSpec`, default: (1, 1, 1)
1272-
>>>>>>> FIX: allow start-stop subplot
1268+
*args : int, (int, int, *index*), or `SubplotSpec`, default: (1, 1, 1)
12731269
The position of the subplot described by one of
12741270
12751271
- Three integers (*nrows*, *ncols*, *index*). The subplot will
12761272
take the *index* position on a grid with *nrows* rows and
12771273
*ncols* columns. *index* starts at 1 in the upper left corner
1278-
<<<<<<< HEAD
1279-
and increases to the right. *index* can also be a two-tuple
1280-
specifying the (*first*, *last*) indices (1-based, and including
1281-
*last*) of the subplot, e.g., ``fig.add_subplot(3, 1, (1, 2))``
1282-
makes a subplot that spans the upper 2/3 of the figure.
1283-
=======
12841274
and increases to the right. *index* can also be a two-tuple
12851275
specifying the (*start*, *stop*) indices of the subplot, i.e.,
12861276
``fig.add_subplot(3, 1, (1, 2))`` makes a subplot that spans the
12871277
upper 2/3 of the figure.
1288-
>>>>>>> FIX: allow start-stop subplot
12891278
- A 3-digit integer. The digits are interpreted as if given
12901279
separately as three single-digit integers, i.e.
12911280
``fig.add_subplot(235)`` is the same as

lib/matplotlib/gridspec.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -690,8 +690,7 @@ def _from_subplot_args(figure, args):
690690
f"Single argument to subplot must be a three-digit "
691691
f"integer, not {arg}") from None
692692
# num - 1 for converting from MATLAB to python indexing
693-
ii = num
694-
jj = num
693+
i = j = num
695694
elif len(args) == 3:
696695
rows, cols, num = args
697696
if not (isinstance(rows, Integral) and isinstance(cols, Integral)):
@@ -704,14 +703,15 @@ def _from_subplot_args(figure, args):
704703
i, j = map(int, num)
705704
else:
706705
i, j = num
707-
# return gs[i-1:j]
708706
else:
709707
if not isinstance(num, Integral):
710708
cbook.warn_deprecated("3.3", message=message)
711709
num = int(num)
712710
if num < 1 or num > rows*cols:
713711
raise ValueError(
714712
f"num must be 1 <= num <= {rows*cols}, not {num}")
713+
else:
714+
i = j = num
715715
else:
716716
raise TypeError(f"subplot() takes 1 or 3 positional arguments but "
717717
f"{len(args)} were given")

lib/matplotlib/tests/test_figure.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ def test_add_subplot_invalid():
190190
with pytest.raises(ValueError, match='num must be 1 <= num <= 4'):
191191
fig.add_subplot(2, 2, 5)
192192

193-
with pytest.raises(ValueError, match='must be a three-digit integer'):
193+
with pytest.raises(ValueError, match='Integer subplot specification must'):
194194
fig.add_subplot(42)
195-
with pytest.raises(ValueError, match='must be a three-digit integer'):
195+
with pytest.raises(ValueError, match='Integer subplot specification must'):
196196
fig.add_subplot(1000)
197197

198198
with pytest.raises(TypeError, match='takes 1 or 3 positional arguments '

0 commit comments

Comments
 (0)