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

Skip to content

Commit e0c59ee

Browse files
authored
Merge pull request #25125 from anntzer/ua
Use "array" instead of "numpy array" except when emphasis is needed.
2 parents 29dcb5c + 2b54261 commit e0c59ee

File tree

12 files changed

+70
-90
lines changed

12 files changed

+70
-90
lines changed

lib/matplotlib/axis.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,13 +1511,13 @@ def get_ticklocs(self, *, minor=False):
15111511
15121512
Returns
15131513
-------
1514-
numpy array of tick locations
1514+
array of tick locations
15151515
"""
15161516
return self.get_minorticklocs() if minor else self.get_majorticklocs()
15171517

15181518
def get_ticks_direction(self, minor=False):
15191519
"""
1520-
Get the tick directions as a numpy array
1520+
Return an array of this Axis' tick directions.
15211521
15221522
Parameters
15231523
----------
@@ -1527,7 +1527,7 @@ def get_ticks_direction(self, minor=False):
15271527
15281528
Returns
15291529
-------
1530-
numpy array of tick directions
1530+
array of tick directions
15311531
"""
15321532
if minor:
15331533
return np.array(

lib/matplotlib/backend_bases.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,6 @@ def points_to_pixels(self, points):
695695
Parameters
696696
----------
697697
points : float or array-like
698-
a float or a numpy array of float
699698
700699
Returns
701700
-------

lib/matplotlib/cbook.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2240,7 +2240,7 @@ def _unpack_to_numpy(x):
22402240
# If numpy, return directly
22412241
return x
22422242
if hasattr(x, 'to_numpy'):
2243-
# Assume that any function to_numpy() do actually return a numpy array
2243+
# Assume that any to_numpy() method actually returns a numpy array
22442244
return x.to_numpy()
22452245
if hasattr(x, 'values'):
22462246
xtmp = x.values

lib/matplotlib/colors.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2050,8 +2050,7 @@ def inverse(self, value):
20502050

20512051
def rgb_to_hsv(arr):
20522052
"""
2053-
Convert float RGB values (in the range [0, 1]), in a numpy array to HSV
2054-
values.
2053+
Convert an array of float RGB values (in the range [0, 1]) to HSV values.
20552054
20562055
Parameters
20572056
----------

lib/matplotlib/dates.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,6 @@ def _from_ordinalf(x, tz=None):
383383

384384
# a version of _from_ordinalf that can operate on numpy arrays
385385
_from_ordinalf_np_vectorized = np.vectorize(_from_ordinalf, otypes="O")
386-
387-
388386
# a version of dateutil.parser.parse that can operate on numpy arrays
389387
_dateutil_parser_parse_np_vectorized = np.vectorize(dateutil.parser.parse)
390388

lib/matplotlib/figure.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,13 +1928,11 @@ def _make_array(inp):
19281928
19291929
We need to have this internal function rather than
19301930
``np.asarray(..., dtype=object)`` so that a list of lists
1931-
of lists does not get converted to an array of dimension >
1932-
2
1931+
of lists does not get converted to an array of dimension > 2.
19331932
19341933
Returns
19351934
-------
19361935
2D object array
1937-
19381936
"""
19391937
r0, *rest = inp
19401938
if isinstance(r0, str):
@@ -1960,13 +1958,13 @@ def _identify_keys_and_nested(mosaic):
19601958
19611959
Parameters
19621960
----------
1963-
mosaic : 2D numpy object array
1961+
mosaic : 2D object array
19641962
19651963
Returns
19661964
-------
19671965
unique_ids : tuple
19681966
The unique non-sub mosaic entries in this mosaic
1969-
nested : dict[tuple[int, int]], 2D object array
1967+
nested : dict[tuple[int, int], 2D object array]
19701968
"""
19711969
# make sure we preserve the user supplied order
19721970
unique_ids = cbook._OrderedSet()
@@ -1990,7 +1988,7 @@ def _do_layout(gs, mosaic, unique_ids, nested):
19901988
----------
19911989
gs : GridSpec
19921990
mosaic : 2D object array
1993-
The input converted to a 2D numpy array for this level.
1991+
The input converted to a 2D array for this level.
19941992
unique_ids : tuple
19951993
The identified scalar labels at this level of nesting.
19961994
nested : dict[tuple[int, int]], 2D object array

lib/matplotlib/patches.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@ def get_xy(self):
11251125
11261126
Returns
11271127
-------
1128-
(N, 2) numpy array
1128+
(N, 2) array
11291129
The coordinates of the vertices.
11301130
"""
11311131
return self._path.vertices
@@ -1164,7 +1164,7 @@ def set_xy(self, xy):
11641164
self.stale = True
11651165

11661166
xy = property(get_xy, set_xy,
1167-
doc='The vertices of the path as (N, 2) numpy array.')
1167+
doc='The vertices of the path as a (N, 2) array.')
11681168

11691169

11701170
class Wedge(Patch):

lib/matplotlib/path.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ def _fast_from_codes_and_verts(cls, verts, codes, internals_from=None):
166166
167167
Parameters
168168
----------
169-
verts : numpy array
170-
codes : numpy array
169+
verts : array-like
170+
codes : array
171171
internals_from : Path or None
172172
If not None, another `Path` from which the attributes
173173
``should_simplify``, ``simplify_threshold``, and
@@ -223,12 +223,12 @@ def vertices(self, vertices):
223223
@property
224224
def codes(self):
225225
"""
226-
The list of codes in the `Path` as a 1D numpy array. Each
227-
code is one of `STOP`, `MOVETO`, `LINETO`, `CURVE3`, `CURVE4`
228-
or `CLOSEPOLY`. For codes that correspond to more than one
229-
vertex (`CURVE3` and `CURVE4`), that code will be repeated so
230-
that the length of `vertices` and `codes` is always
231-
the same.
226+
The list of codes in the `Path` as a 1D array.
227+
228+
Each code is one of `STOP`, `MOVETO`, `LINETO`, `CURVE3`, `CURVE4` or
229+
`CLOSEPOLY`. For codes that correspond to more than one vertex
230+
(`CURVE3` and `CURVE4`), that code will be repeated so that the length
231+
of `vertices` and `codes` is always the same.
232232
"""
233233
return self._codes
234234

lib/matplotlib/textpath.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,15 @@ def get_text_path(self, prop, s, ismath=False):
7878
----------
7979
prop : `~matplotlib.font_manager.FontProperties`
8080
The font properties for the text.
81-
8281
s : str
8382
The text to be converted.
84-
8583
ismath : {False, True, "TeX"}
8684
If True, use mathtext parser. If "TeX", use tex for rendering.
8785
8886
Returns
8987
-------
9088
verts : list
91-
A list of numpy arrays containing the x and y coordinates of the
92-
vertices.
93-
89+
A list of arrays containing the (x, y) coordinates of the vertices.
9490
codes : list
9591
A list of path codes.
9692

lib/matplotlib/transforms.py

Lines changed: 36 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -830,11 +830,10 @@ def from_extents(*args, minpos=None):
830830
----------
831831
left, bottom, right, top : float
832832
The four extents of the bounding box.
833-
834833
minpos : float or None
835-
If this is supplied, the Bbox will have a minimum positive value
836-
set. This is useful when dealing with logarithmic scales and other
837-
scales where negative bounds result in floating point errors.
834+
If this is supplied, the Bbox will have a minimum positive value
835+
set. This is useful when dealing with logarithmic scales and other
836+
scales where negative bounds result in floating point errors.
838837
"""
839838
bbox = Bbox(np.reshape(args, (2, 2)))
840839
if minpos is not None:
@@ -858,11 +857,10 @@ def ignore(self, value):
858857
by subsequent calls to :meth:`update_from_data_xy`.
859858
860859
value : bool
861-
- When ``True``, subsequent calls to :meth:`update_from_data_xy`
862-
will ignore the existing bounds of the `Bbox`.
863-
864-
- When ``False``, subsequent calls to :meth:`update_from_data_xy`
865-
will include the existing bounds of the `Bbox`.
860+
- When ``True``, subsequent calls to `update_from_data_xy` will
861+
ignore the existing bounds of the `Bbox`.
862+
- When ``False``, subsequent calls to `update_from_data_xy` will
863+
include the existing bounds of the `Bbox`.
866864
"""
867865
self._ignore = value
868866

@@ -875,12 +873,10 @@ def update_from_path(self, path, ignore=None, updatex=True, updatey=True):
875873
Parameters
876874
----------
877875
path : `~matplotlib.path.Path`
878-
879876
ignore : bool, optional
880-
- when ``True``, ignore the existing bounds of the `Bbox`.
881-
- when ``False``, include the existing bounds of the `Bbox`.
882-
- when ``None``, use the last value passed to :meth:`ignore`.
883-
877+
- When ``True``, ignore the existing bounds of the `Bbox`.
878+
- When ``False``, include the existing bounds of the `Bbox`.
879+
- When ``None``, use the last value passed to :meth:`ignore`.
884880
updatex, updatey : bool, default: True
885881
When ``True``, update the x/y values.
886882
"""
@@ -912,7 +908,6 @@ def update_from_data_x(self, x, ignore=None):
912908
----------
913909
x : `~numpy.ndarray`
914910
Array of x-values.
915-
916911
ignore : bool, optional
917912
- When ``True``, ignore the existing bounds of the `Bbox`.
918913
- When ``False``, include the existing bounds of the `Bbox`.
@@ -932,34 +927,32 @@ def update_from_data_y(self, y, ignore=None):
932927
----------
933928
y : `~numpy.ndarray`
934929
Array of y-values.
935-
936930
ignore : bool, optional
937-
- When ``True``, ignore the existing bounds of the `Bbox`.
938-
- When ``False``, include the existing bounds of the `Bbox`.
939-
- When ``None``, use the last value passed to :meth:`ignore`.
931+
- When ``True``, ignore the existing bounds of the `Bbox`.
932+
- When ``False``, include the existing bounds of the `Bbox`.
933+
- When ``None``, use the last value passed to :meth:`ignore`.
940934
"""
941935
y = np.ravel(y)
942936
self.update_from_data_xy(np.column_stack([np.ones(y.size), y]),
943937
ignore=ignore, updatex=False)
944938

945939
def update_from_data_xy(self, xy, ignore=None, updatex=True, updatey=True):
946940
"""
947-
Update the bounds of the `Bbox` based on the passed in data. After
948-
updating, the bounds will have positive *width* and *height*;
941+
Update the `Bbox` bounds based on the passed in *xy* coordinates.
942+
943+
After updating, the bounds will have positive *width* and *height*;
949944
*x0* and *y0* will be the minimal values.
950945
951946
Parameters
952947
----------
953-
xy : `~numpy.ndarray`
954-
A numpy array of 2D points.
955-
948+
xy : (N, 2) array-like
949+
The (x, y) coordinates.
956950
ignore : bool, optional
957-
- When ``True``, ignore the existing bounds of the `Bbox`.
958-
- When ``False``, include the existing bounds of the `Bbox`.
959-
- When ``None``, use the last value passed to :meth:`ignore`.
960-
951+
- When ``True``, ignore the existing bounds of the `Bbox`.
952+
- When ``False``, include the existing bounds of the `Bbox`.
953+
- When ``None``, use the last value passed to :meth:`ignore`.
961954
updatex, updatey : bool, default: True
962-
When ``True``, update the x/y values.
955+
When ``True``, update the x/y values.
963956
"""
964957
if len(xy) == 0:
965958
return
@@ -1051,17 +1044,17 @@ def minposy(self):
10511044

10521045
def get_points(self):
10531046
"""
1054-
Get the points of the bounding box directly as a numpy array
1055-
of the form: ``[[x0, y0], [x1, y1]]``.
1047+
Get the points of the bounding box as an array of the form
1048+
``[[x0, y0], [x1, y1]]``.
10561049
"""
10571050
self._invalid = 0
10581051
return self._points
10591052

10601053
def set_points(self, points):
10611054
"""
1062-
Set the points of the bounding box directly from a numpy array
1063-
of the form: ``[[x0, y0], [x1, y1]]``. No error checking is
1064-
performed, as this method is mainly for internal use.
1055+
Set the points of the bounding box directly from an array of the form
1056+
``[[x0, y0], [x1, y1]]``. No error checking is performed, as this
1057+
method is mainly for internal use.
10651058
"""
10661059
if np.any(self._points != points):
10671060
self._points = points
@@ -1483,14 +1476,14 @@ def transform(self, values):
14831476
14841477
Parameters
14851478
----------
1486-
values : array
1487-
The input values as NumPy array of length :attr:`input_dims` or
1479+
values : array-like
1480+
The input values as an array of length :attr:`input_dims` or
14881481
shape (N, :attr:`input_dims`).
14891482
14901483
Returns
14911484
-------
14921485
array
1493-
The output values as NumPy array of length :attr:`output_dims` or
1486+
The output values as an array of length :attr:`output_dims` or
14941487
shape (N, :attr:`output_dims`), depending on the input.
14951488
"""
14961489
# Ensure that values is a 2d array (but remember whether
@@ -1529,13 +1522,13 @@ def transform_affine(self, values):
15291522
Parameters
15301523
----------
15311524
values : array
1532-
The input values as NumPy array of length :attr:`input_dims` or
1525+
The input values as an array of length :attr:`input_dims` or
15331526
shape (N, :attr:`input_dims`).
15341527
15351528
Returns
15361529
-------
15371530
array
1538-
The output values as NumPy array of length :attr:`output_dims` or
1531+
The output values as an array of length :attr:`output_dims` or
15391532
shape (N, :attr:`output_dims`), depending on the input.
15401533
"""
15411534
return self.get_affine().transform(values)
@@ -1554,13 +1547,13 @@ def transform_non_affine(self, values):
15541547
Parameters
15551548
----------
15561549
values : array
1557-
The input values as NumPy array of length :attr:`input_dims` or
1550+
The input values as an array of length :attr:`input_dims` or
15581551
shape (N, :attr:`input_dims`).
15591552
15601553
Returns
15611554
-------
15621555
array
1563-
The output values as NumPy array of length :attr:`output_dims` or
1556+
The output values as an array of length :attr:`output_dims` or
15641557
shape (N, :attr:`output_dims`), depending on the input.
15651558
"""
15661559
return values
@@ -1933,7 +1926,7 @@ def from_values(a, b, c, d, e, f):
19331926

19341927
def get_matrix(self):
19351928
"""
1936-
Get the underlying transformation matrix as a 3x3 numpy array::
1929+
Get the underlying transformation matrix as a 3x3 array::
19371930
19381931
a c e
19391932
b d f
@@ -1948,7 +1941,7 @@ def get_matrix(self):
19481941

19491942
def set_matrix(self, mtx):
19501943
"""
1951-
Set the underlying transformation matrix from a 3x3 numpy array::
1944+
Set the underlying transformation matrix from a 3x3 array::
19521945
19531946
a c e
19541947
b d f

lib/mpl_toolkits/mplot3d/art3d.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ def get_dir_vector(zdir):
5252
- 'y': equivalent to (0, 1, 0)
5353
- 'z': equivalent to (0, 0, 1)
5454
- *None*: equivalent to (0, 0, 0)
55-
- an iterable (x, y, z) is converted to a NumPy array, if not already
55+
- an iterable (x, y, z) is converted to an array
5656
5757
Returns
5858
-------
59-
x, y, z : array-like
59+
x, y, z : array
6060
The direction vector.
6161
"""
6262
if zdir == 'x':

0 commit comments

Comments
 (0)