Skip to content

Commit

Permalink
PEP8ify some variable names.
Browse files Browse the repository at this point in the history
nrows/ncols is already used as parameter names in subplots() so
standardizing on them seems good enough.

Note that the docstring of SubplotBase was previously incorrect:
one didn't need `numRows <= numCols <= plotNum < 10`, just that all
three be single-digit.
  • Loading branch information
anntzer committed Sep 7, 2019
1 parent 74e9dc7 commit c93c46e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 26 deletions.
13 changes: 6 additions & 7 deletions lib/matplotlib/axes/_axes.py
Expand Up @@ -5634,12 +5634,11 @@ def _pcolorargs(funcname, *args, allmatch=False):

if len(args) == 1:
C = np.asanyarray(args[0])
numRows, numCols = C.shape
nrows, ncols = C.shape
if allmatch:
X, Y = np.meshgrid(np.arange(numCols), np.arange(numRows))
X, Y = np.meshgrid(np.arange(ncols), np.arange(nrows))
else:
X, Y = np.meshgrid(np.arange(numCols + 1),
np.arange(numRows + 1))
X, Y = np.meshgrid(np.arange(ncols + 1), np.arange(nrows + 1))
C = cbook.safe_masked_invalid(C)
return X, Y, C

Expand All @@ -5659,7 +5658,7 @@ def _pcolorargs(funcname, *args, allmatch=False):
X = X.data # strip mask as downstream doesn't like it...
if isinstance(Y, np.ma.core.MaskedArray):
Y = Y.data
numRows, numCols = C.shape
nrows, ncols = C.shape
else:
raise TypeError(
'Illegal arguments to %s; see help(%s)' % (funcname, funcname))
Expand All @@ -5677,12 +5676,12 @@ def _pcolorargs(funcname, *args, allmatch=False):
'Incompatible X, Y inputs to %s; see help(%s)' % (
funcname, funcname))
if allmatch:
if (Nx, Ny) != (numCols, numRows):
if (Nx, Ny) != (ncols, nrows):
raise TypeError('Dimensions of C %s are incompatible with'
' X (%d) and/or Y (%d); see help(%s)' % (
C.shape, Nx, Ny, funcname))
else:
if not (numCols in (Nx, Nx - 1) and numRows in (Ny, Ny - 1)):
if not (ncols in (Nx, Nx - 1) and nrows in (Ny, Ny - 1)):
raise TypeError('Dimensions of C %s are incompatible with'
' X (%d) and/or Y (%d); see help(%s)' % (
C.shape, Nx, Ny, funcname))
Expand Down
23 changes: 13 additions & 10 deletions lib/matplotlib/axes/_subplots.py
Expand Up @@ -17,16 +17,19 @@ class SubplotBase:

def __init__(self, fig, *args, **kwargs):
"""
*fig* is a :class:`matplotlib.figure.Figure` instance.
*args* is the tuple (*numRows*, *numCols*, *plotNum*), where
the array of subplots in the figure has dimensions *numRows*,
*numCols*, and where *plotNum* is the number of the subplot
being created. *plotNum* starts at 1 in the upper left
corner and increases to the right.
If *numRows* <= *numCols* <= *plotNum* < 10, *args* can be the
decimal integer *numRows* * 100 + *numCols* * 10 + *plotNum*.
Parameters
----------
fig : `matplotlib.figure.Figure`
*args : tuple (*nrows*, *ncols*, *index*) or int
The array of subplots in the figure has dimensions ``(nrows,
ncols)``, and *index* is the index of the subplot being created.
*index* starts at 1 in the upper left corner and increases to the
right.
If *nrows*, *ncols*, and *index* are all single digit numbers, then
*args* can be passed as a single 3-digit number (e.g. 234 for
(2, 3, 4)).
"""

self.figure = fig
Expand Down
20 changes: 11 additions & 9 deletions lib/mpl_toolkits/axes_grid1/axes_divider.py
Expand Up @@ -350,15 +350,17 @@ def __init__(self, fig, *args, horizontal=None, vertical=None,
"""
Parameters
----------
fig : :class:`matplotlib.figure.Figure`
*args : tuple (*numRows*, *numCols*, *plotNum*)
The array of subplots in the figure has dimensions *numRows*,
*numCols*, and *plotNum* is the number of the subplot
being created. *plotNum* starts at 1 in the upper left
corner and increases to the right.
If *numRows* <= *numCols* <= *plotNum* < 10, *args* can be the
decimal integer *numRows* * 100 + *numCols* * 10 + *plotNum*.
fig : `matplotlib.figure.Figure`
*args : tuple (*nrows*, *ncols*, *index*) or int
The array of subplots in the figure has dimensions ``(nrows,
ncols)``, and *index* is the index of the subplot being created.
*index* starts at 1 in the upper left corner and increases to the
right.
If *nrows*, *ncols*, and *index* are all single digit numbers, then
*args* can be passed as a single 3-digit number (e.g. 234 for
(2, 3, 4)).
"""

self.figure = fig
Expand Down

0 comments on commit c93c46e

Please sign in to comment.