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

Skip to content

Commit c27265a

Browse files
committed
Switch array-like (M, N) to (M, N) array-like.
Also use "array" instead of "array-like" for return types if appropriate. Some instances were left unchanged as they may need more editing anyways.
1 parent b93f563 commit c27265a

File tree

19 files changed

+63
-83
lines changed

19 files changed

+63
-83
lines changed

doc/devel/documenting_mpl.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -462,18 +462,19 @@ Use ``array-like`` for homogeneous numeric sequences, which could
462462
typically be a numpy.array. Dimensionality may be specified using ``2D``,
463463
``3D``, ``n-dimensional``. If you need to have variables denoting the
464464
sizes of the dimensions, use capital letters in brackets
465-
(``array-like (M, N)``). When referring to them in the text they are easier
466-
read and no special formatting is needed.
465+
(``(M, N) array-like``). When referring to them in the text they are easier
466+
read and no special formatting is needed. Use ``array`` instead of
467+
``array-like`` for return types if the returned object is indeed a numpy array.
467468

468469
``float`` is the implicit default dtype for array-likes. For other dtypes
469470
use ``array-like of int``.
470471

471472
Some possible uses::
472473

473474
2D array-like
474-
array-like (N)
475-
array-like (M, N)
476-
array-like (M, N, 3)
475+
(N,) array-like
476+
(M, N) array-like
477+
(M, N, 3) array-like
477478
array-like of int
478479

479480
Non-numeric homogeneous sequences are described as lists, e.g.::

examples/lines_bars_and_markers/hat_graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def hat_graph(ax, xlabels, values, group_labels):
2222
The Axes to plot into.
2323
xlabels : list of str
2424
The category names to be displayed on the x-axis.
25-
values : array-like (M, N)
25+
values : (M, N) array-like
2626
The data values.
2727
Rows are the groups (len(group_labels) == M).
2828
Columns are the categories (len(xlabels) == N).

lib/matplotlib/axes/_axes.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3622,7 +3622,7 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
36223622
95% confidence intervals. Values between 1000 and 10000 are
36233623
recommended.
36243624
3625-
usermedians : array-like, optional
3625+
usermedians : 1D array-like, optional
36263626
A 1D array-like of length ``len(x)``. Each entry that is not
36273627
`None` forces the value of the median for the corresponding
36283628
dataset. For entries that are `None`, the medians are computed
@@ -5747,8 +5747,8 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
57475747
57485748
Parameters
57495749
----------
5750-
C : array-like
5751-
A scalar 2D array. The values will be color-mapped.
5750+
C : 2D array-like
5751+
The color-mapped values.
57525752
57535753
X, Y : array-like, optional
57545754
The coordinates of the corners of quadrilaterals of a pcolormesh::
@@ -5991,8 +5991,8 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
59915991
59925992
Parameters
59935993
----------
5994-
C : array-like
5995-
A scalar 2D array. The values will be color-mapped.
5994+
C : 2D array-like
5995+
The color-mapped values.
59965996
59975997
X, Y : array-like, optional
59985998
The coordinates of the corners of quadrilaterals of a pcolormesh::
@@ -6227,7 +6227,7 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
62276227
62286228
Parameters
62296229
----------
6230-
C : array-like(M, N)
6230+
C : array-like
62316231
The image data. Supported array shapes are:
62326232
62336233
- (M, N): an image with scalar data. The data is visualized
@@ -7748,7 +7748,7 @@ def spy(self, Z, precision=0, marker=None, markersize=None,
77487748
77497749
Parameters
77507750
----------
7751-
Z : array-like (M, N)
7751+
Z : (M, N) array-like
77527752
The array to be plotted.
77537753
77547754
precision : float or 'present', default: 0
@@ -7872,7 +7872,7 @@ def matshow(self, Z, **kwargs):
78727872
78737873
Parameters
78747874
----------
7875-
Z : array-like(M, N)
7875+
Z : (M, N) array-like
78767876
The matrix to be displayed.
78777877
78787878
Returns

lib/matplotlib/backend_bases.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -297,16 +297,12 @@ def draw_gouraud_triangle(self, gc, points, colors, transform):
297297
----------
298298
gc : `.GraphicsContextBase`
299299
The graphics context.
300-
301-
points : array-like, shape=(3, 2)
300+
points : (3, 2) array-like
302301
Array of (x, y) points for the triangle.
303-
304-
colors : array-like, shape=(3, 4)
302+
colors : (3, 4) array-like
305303
RGBA colors for each point of the triangle.
306-
307304
transform : `matplotlib.transforms.Transform`
308305
An affine transform to apply to the points.
309-
310306
"""
311307
raise NotImplementedError
312308

@@ -317,12 +313,10 @@ def draw_gouraud_triangles(self, gc, triangles_array, colors_array,
317313
318314
Parameters
319315
----------
320-
points : array-like, shape=(N, 3, 2)
316+
points : (N, 3, 2) array-like
321317
Array of *N* (x, y) points for the triangles.
322-
323-
colors : array-like, shape=(N, 3, 4)
318+
colors : (N, 3, 4) array-like
324319
Array of *N* RGBA colors for each point of the triangles.
325-
326320
transform : `matplotlib.transforms.Transform`
327321
An affine transform to apply to the points.
328322
"""
@@ -502,7 +496,7 @@ def draw_image(self, gc, x, y, im, transform=None):
502496
The distance in physical units (i.e., dots or pixels) from the
503497
bottom side of the canvas.
504498
505-
im : array-like, shape=(N, M, 4), dtype=np.uint8
499+
im : (N, M, 4) array-like of np.uint8
506500
An array of RGBA pixels.
507501
508502
transform : `matplotlib.transforms.Affine2DBase`

lib/matplotlib/bezier.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,12 @@ def __call__(self, t):
204204
205205
Parameters
206206
----------
207-
t : float (k,) array_like
207+
t : (k,) array-like
208208
Points at which to evaluate the curve.
209209
210210
Returns
211211
-------
212-
float (k, d) array_like
212+
(k, d) array
213213
Value of the curve for each point in *t*.
214214
"""
215215
t = np.asarray(t)
@@ -246,7 +246,7 @@ def polynomial_coefficients(self):
246246
247247
Returns
248248
-------
249-
float, (n+1, d) array_like
249+
(n+1, d) array
250250
Coefficients after expanding in polynomial basis, where :math:`n`
251251
is the degree of the bezier curve and :math:`d` its dimension.
252252
These are the numbers (:math:`C_j`) such that the curve can be
@@ -282,10 +282,10 @@ def axis_aligned_extrema(self):
282282
283283
Returns
284284
-------
285-
dims : int, array_like
285+
dims : array of int
286286
Index :math:`i` of the partial derivative which is zero at each
287287
interior extrema.
288-
dzeros : float, array_like
288+
dzeros : array of float
289289
Of same size as dims. The :math:`t` such that :math:`d/dx_i B(t) =
290290
0`
291291
"""
@@ -313,7 +313,7 @@ def split_bezier_intersecting_with_closedpath(
313313
314314
Parameters
315315
----------
316-
bezier : array-like(N, 2)
316+
bezier : (N, 2) array-like
317317
Control points of the Bezier segment. See `.BezierSegment`.
318318
inside_closedpath : callable
319319
A function returning True if a given point (x, y) is inside the

lib/matplotlib/collections.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ def set_offsets(self, offsets):
537537
538538
Parameters
539539
----------
540-
offsets : array-like (N, 2) or (2,)
540+
offsets : (N, 2) or (2,) array-like
541541
"""
542542
offsets = np.asanyarray(offsets, float)
543543
if offsets.shape == (2,): # Broadcast (2,) -> (1, 2) but nothing else.
@@ -1714,15 +1714,11 @@ def __init__(self, widths, heights, angles, units='points', **kwargs):
17141714
----------
17151715
widths : array-like
17161716
The lengths of the first axes (e.g., major axis lengths).
1717-
17181717
heights : array-like
17191718
The lengths of second axes.
1720-
17211719
angles : array-like
17221720
The angles of the first axes, degrees CCW from the x-axis.
1723-
17241721
units : {'points', 'inches', 'dots', 'width', 'height', 'x', 'y', 'xy'}
1725-
17261722
The units in which majors and minors are given; 'width' and
17271723
'height' refer to the dimensions of the axes, while 'x' and 'y'
17281724
refer to the *offsets* data units. 'xy' differs from all others in

lib/matplotlib/colors.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -440,12 +440,12 @@ def _create_lookup_table(N, data, gamma=1.0):
440440
N : int
441441
The number of elements of the created lookup table; at least 1.
442442
443-
data : Mx3 array-like or callable
443+
data : (M, 3) array-like or callable
444444
Defines the mapping :math:`f`.
445445
446-
If a Mx3 array-like, the rows define values (x, y0, y1). The x values
447-
must start with x=0, end with x=1, and all x values be in increasing
448-
order.
446+
If a (M, 3) array-like, the rows define values (x, y0, y1). The x
447+
values must start with x=0, end with x=1, and all x values be in
448+
increasing order.
449449
450450
A value between :math:`x_i` and :math:`x_{i+1}` is mapped to the range
451451
:math:`y^1_{i-1} \ldots y^0_i` by linear interpolation.
@@ -581,7 +581,7 @@ def __call__(self, X, alpha=None, bytes=False):
581581
return the RGBA values ``X*100`` percent along the Colormap line.
582582
For integers, X should be in the interval ``[0, Colormap.N)`` to
583583
return RGBA values *indexed* from the Colormap with index ``X``.
584-
alpha : float, array-like, None
584+
alpha : float or array-like or None
585585
Alpha must be a scalar between 0 and 1, a sequence of such
586586
floats with shape matching X, or None.
587587
bytes : bool
@@ -1959,9 +1959,8 @@ def hillshade(self, elevation, vert_exag=1, dx=1, dy=1, fraction=1.):
19591959
19601960
Parameters
19611961
----------
1962-
elevation : array-like
1963-
A 2D array (or equivalent) of the height values used to generate an
1964-
illumination map
1962+
elevation : 2D array-like
1963+
The height values used to generate an illumination map
19651964
vert_exag : number, optional
19661965
The amount to exaggerate the elevation values by when calculating
19671966
illumination. This can be used either to correct for differences in
@@ -2057,9 +2056,8 @@ def shade(self, data, cmap, norm=None, blend_mode='overlay', vmin=None,
20572056
20582057
Parameters
20592058
----------
2060-
data : array-like
2061-
A 2D array (or equivalent) of the height values used to generate a
2062-
shaded map.
2059+
data : 2D array-like
2060+
The height values used to generate a shaded map.
20632061
cmap : `~matplotlib.colors.Colormap`
20642062
The colormap used to color the *data* array. Note that this must be
20652063
a `~matplotlib.colors.Colormap` instance. For example, rather than

lib/matplotlib/contour.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1539,7 +1539,7 @@ def _initialize_x_y(self, z):
15391539
If not given, they are assumed to be integer indices, i.e.
15401540
``X = range(M)``, ``Y = range(N)``.
15411541
1542-
Z : array-like(N, M)
1542+
Z : (M, N) array-like
15431543
The height values over which the contour is drawn.
15441544
15451545
levels : int or array-like, optional

lib/matplotlib/path.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,11 @@ def __init__(self, vertices, codes=None, _interpolation_steps=1,
102102
103103
Parameters
104104
----------
105-
vertices : array-like
106-
The ``(N, 2)`` float array, masked array or sequence of pairs
107-
representing the vertices of the path.
108-
109-
If *vertices* contains masked values, they will be converted
110-
to NaNs which are then handled correctly by the Agg
111-
PathIterator and other consumers of path data, such as
112-
:meth:`iter_segments`.
105+
vertices : (N, 2) array-like
106+
The path vertices, as an array, masked array or sequence of pairs.
107+
Masked values, if any, will be converted to NaNs, which are then
108+
handled correctly by the Agg PathIterator and other consumers of
109+
path data, such as :meth:`iter_segments`.
113110
codes : array-like or None, optional
114111
n-length array integers representing the codes of the path.
115112
If not None, codes must be the same length as vertices.

lib/matplotlib/pyplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2368,7 +2368,7 @@ def matshow(A, fignum=None, **kwargs):
23682368
23692369
Parameters
23702370
----------
2371-
A : array-like(M, N)
2371+
A : 2D array-like
23722372
The matrix to be displayed.
23732373
23742374
fignum : None or int or False

lib/matplotlib/stackplot.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
http://stackoverflow.com/questions/2225995/how-can-i-create-stacked-line-graph-with-matplotlib
55
66
(http://stackoverflow.com/users/66549/doug)
7-
87
"""
8+
99
import numpy as np
1010

1111
from matplotlib import _api
@@ -21,10 +21,9 @@ def stackplot(axes, x, *args,
2121
2222
Parameters
2323
----------
24-
x : array-like (N)
25-
26-
y : 2D array (M, N) or sequence of array-like (N)
24+
x : (N,) array-like
2725
26+
y : (M, N) array-like
2827
The data is assumed to be unstacked. Each of the following
2928
calls is legal::
3029

lib/matplotlib/tri/triangulation.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ class Triangulation:
99
1010
Parameters
1111
----------
12-
x, y : array-like of shape (npoints)
12+
x, y : (npoints,) array-like
1313
Coordinates of grid points.
14-
triangles : int array-like of shape (ntri, 3), optional
14+
triangles : (ntri, 3) array-like of int, optional
1515
For each triangle, the indices of the three points that make
1616
up the triangle, ordered in an anticlockwise manner. If not
1717
specified, the Delaunay triangulation is calculated.
18-
mask : bool array-like of shape (ntri), optional
18+
mask : (ntri,) array-like of bool, optional
1919
Which triangles are masked out.
2020
2121
Attributes
2222
----------
23-
triangles : int array-like of shape (ntri, 3)
23+
triangles : (ntri, 3) array of int
2424
For each triangle, the indices of the three points that make
2525
up the triangle, ordered in an anticlockwise manner. If you want to
2626
take the *mask* into account, use `get_masked_triangles` instead.
27-
mask : bool array of shape (ntri, 3)
27+
mask : (ntri, 3) array of bool
2828
Masked out triangles.
2929
is_delaunay : bool
3030
Whether the Triangulation is a calculated Delaunay

lib/matplotlib/tri/tricontour.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,15 @@ def _contour_args(self, args, kwargs):
153153
x, y : array-like, optional
154154
The coordinates of the values in *Z*.
155155
156-
triangles : int array-like of shape (ntri, 3), optional
156+
triangles : (ntri, 3) array-like of int, optional
157157
For each triangle, the indices of the three points that make up the
158158
triangle, ordered in an anticlockwise manner. If not specified, the
159159
Delaunay triangulation is calculated.
160160
161-
mask : bool array-like of shape (ntri), optional
161+
mask : (ntri,) array-like of bool, optional
162162
Which triangles are masked out.
163163
164-
Z : array-like(N, M)
164+
Z : 2D array-like
165165
The height values over which the contour is drawn.
166166
167167
levels : int or array-like, optional

lib/matplotlib/tri/triinterpolate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ class LinearTriInterpolator(TriInterpolator):
242242
----------
243243
triangulation : `~matplotlib.tri.Triangulation`
244244
The triangulation to interpolate over.
245-
z : array-like of shape (npoints,)
245+
z : (npoints,) array-like
246246
Array of values, defined at grid points, to interpolate between.
247247
trifinder : `~matplotlib.tri.TriFinder`, optional
248248
If this is not specified, the Triangulation's default TriFinder will
@@ -305,7 +305,7 @@ class CubicTriInterpolator(TriInterpolator):
305305
----------
306306
triangulation : `~matplotlib.tri.Triangulation`
307307
The triangulation to interpolate over.
308-
z : array-like of shape (npoints,)
308+
z : (npoints,) array-like
309309
Array of values, defined at grid points, to interpolate between.
310310
kind : {'min_E', 'geom', 'user'}, optional
311311
Choice of the smoothing algorithm, in order to compute

lib/matplotlib/tri/trirefine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def refine_field(self, z, triinterpolator=None, subdiv=3):
136136
137137
Parameters
138138
----------
139-
z : array-like of length ``n_points``
139+
z : (npoints,) array-like
140140
Values of the field to refine, defined at the nodes of the
141141
encapsulated triangulation. (``n_points`` is the number of points
142142
in the initial triangulation)

lib/matplotlib/tri/tritools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def get_flat_tri_mask(self, min_circle_ratio=0.01, rescale=True):
143143
144144
Returns
145145
-------
146-
bool array-like
146+
array of bool
147147
Mask to apply to encapsulated triangulation.
148148
All the initially masked triangles remain masked in the
149149
*new_mask*.

0 commit comments

Comments
 (0)