8000 MAINT: Use builtin when np.{x} is builtins.{x}. · LindyBalboa/matplotlib@c9612cc · GitHub
[go: up one dir, main page]

Skip to content

Commit c9612cc

Browse files
committed
MAINT: Use builtin when np.{x} is builtins.{x}.
This is the case for x in {int, bool, str, float, complex, object}. Using the np.{x} version is deceptive as it suggests that there is a difference. This change doesn't affect any external behaviour. The `long` type is missing in python 3, so np.long is still useful
1 parent a1937d4 commit c9612cc

File tree

14 files changed

+44
-44
lines changed

14 files changed

+44
-44
lines changed

examples/event_handling/viewlims.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ def __call__(self, xstart, xend, ystart, yend):
3636
self.y = np.linspace(ystart, yend, self.height).reshape(-1, 1)
3737
c = self.x + 1.0j * self.y
3838
threshold_time = np.zeros((self.height, self.width))
39-
z = np.zeros(threshold_time.shape, dtype=np.complex)
40-
mask = np.ones(threshold_time.shape, dtype=np.bool)
39+
z = np.zeros(threshold_time.shape, dtype=complex)
40+
mask = np.ones(threshold_time.shape, dtype=bool)
4141
for i in range(self.niter):
4242
z[mask] = z[mask]**self.power + c[mask]
4343
mask = (np.abs(z) < self.radius)

examples/images_contours_and_fields/contour_corner_mask.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
z = np.sin(0.5 * x) * np.cos(0.52 * y)
1515

1616
# Mask various z values.
17-
mask = np.zeros_like(z, dtype=np.bool)
17+
mask = np.zeros_like(z, dtype=bool)
1818
mask[2, 3:5] = True
1919
mask[3:5, 4] = True
2020
mask[7, 2] = True

examples/images_contours_and_fields/tricontour_smooth_delaunay.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def experiment_res(x, y):
7575
ntri = tri.triangles.shape[0]
7676

7777
# Some invalid data are masked out
78-
mask_init = np.zeros(ntri, dtype=np.bool)
78+
mask_init = np.zeros(ntri, dtype=bool)
7979
masked_tri = random_gen.randint(0, ntri, int(ntri * init_mask_frac))
8080
mask_init[masked_tri] = True
8181
tri.set_mask(mask_init)

lib/matplotlib/axes/_axes.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4769,9 +4769,9 @@ def fill_between(self, x, y1, y2=0, where=None, interpolate=False,
47694769
y2 = np.ones_like(x) * y2
47704770

47714771
if where is None:
4772-
where = np.ones(len(x), np.bool)
4772+
where = np.ones(len(x), bool)
47734773
else:
4774-
where = np.asarray(where, np.bool)
4774+
where = np.asarray(where, bool)
47754775

47764776
if not (x.shape == y1.shape == y2.shape == where.shape):
47774777
raise ValueError("Argument dimensions are incompatible")
@@ -4930,9 +4930,9 @@ def fill_betweenx(self, y, x1, x2=0, where=None,
49304930
x2 = np.ones_like(y) * x2
49314931

49324932
if where is None:
4933-
where = np.ones(len(y), np.bool)
4933+
where = np.ones(len(y), bool)
49344934
else:
4935-
where = np.asarray(where, np.bool)
4935+
where = np.asarray(where, bool)
49364936

49374937
if not (y.shape == x1.shape == x2.shape == where.shape):
49384938
raise ValueError("Argument dimensions are incompatible")
@@ -4954,7 +4954,7 @@ def fill_betweenx(self, y, x1, x2=0, where=None,
49544954
continue
49554955

49564956
N = len(yslice)
4957-
Y = np.zeros((2 * N + 2, 2), np.float)
4957+
Y = np.zeros((2 * N + 2, 2), float)
49584958
if interpolate:
49594959
def get_interp_point(ind):
49604960
im1 = max(ind - 1, 0)

lib/matplotlib/colors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1443,7 +1443,7 @@ def hsv_to_rgb(hsv):
14431443
g = np.empty_like(h)
14441444
b = np.empty_like(h)
14451445

1446-
i = (h * 6.0).astype(np.int)
1446+
i = (h * 6.0).astype(int)
14471447
f = (h * 6.0) - i
14481448
p = v * (1.0 - s)
14491449
q = v * (1.0 - s * f)

lib/matplotlib/finance.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,27 +58,27 @@ def md5(x):
5858
(str('year'), np.int16),
5959
(str('month'), np.int8),
6060
(str('day'), np.int8),
61-
(str('d'), np.float), # mpl datenum
62-
(str('open'), np.float),
63-
(str('high'), np.float),
64-
(str('low'), np.float),
65-
(str('close'), np.float),
66-
(str('volume'), np.float),
67-
(str('aclose'), np.float)])
61+
(str('d'), float), # mpl datenum
62+
(str('open'), float),
63+
(str('high'), float),
64+
(str('low'), float),
65+
(str('close'), float),
66+
(str('volume'), float),
67+
(str('aclose'), float)])
6868

6969

7070
stock_dt_ochl = np.dtype(
7171
[(str('date'), object),
7272
(str('year'), np.int16),
7373
(str('month'), np.int8),
7474
(str('day'), np.int8),
75-
(str('d'), np.float), # mpl datenum
76-
(str('open'), np.float),
77-
(str('close'), np.float),
78-
(str('high'), np.float),
79-
(str('low'), np.float),
80-
(str('volume'), np.float),
81-
(str('aclose'), np.float)])
75+
(str('d'), float), # mpl datenum
76+
(str('open'), float),
77+
(str('close'), float),
78+
(str('high'), float),
79+
(str('low'), float),
80+
(str('volume'), float),
81+
(str('aclose'), float)])
8282

8383

8484
def parse_yahoo_historical_ochl(fh, adjusted=True, asobject=False):

lib/matplotlib/mlab.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3141,12 +3141,12 @@ def get_justify(colname, column, precision):
31413141
length = max(len(colname), fixed_width)
31423142
return 0, length+padding, "%s" # left justify
31433143

3144-
if np.issubdtype(ntype, np.int):
3144+
if np.issubdtype(ntype, int):
31453145
length = max(len(colname),
31463146
np.max(list(map(len, list(map(str, column))))))
31473147
return 1, length+padding, "%d" # right justify
31483148

3149-
if np.issubdtype(ntype, np.float):
3149+
if np.issubdtype(ntype, float):
31503150
fmt = "%." + str(precision) + "f"
31513151
length = max(
31523152
len(colname),

lib/matplotlib/quiver.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -982,12 +982,12 @@ def _find_tails(self, mag, rounding=True, half=5, full=10, flag=50):
982982
# If rounding, round to the nearest multiple of half, the smallest
983983
# increment
984984
if rounding:
985-
mag = half * (mag / half + 0.5).astype(np.int)
985+
mag = half * (mag / half + 0.5).astype(int)
986986

987-
num_flags = np.floor(mag / flag).astype(np.int)
987+
num_flags = np.floor(mag / flag).astype(int)
988988
mag = np.mod(mag, flag)
989989

990-
num_barb = np.floor(mag / full).astype(np.int)
990+
num_barb = np.floor(mag / full).astype(int)
991991
mag = np.mod(mag, full)
992992

993993
half_flag = mag >= half

lib/matplotlib/streamplot.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -599,14 +599,14 @@ def interpgrid(a, xi, yi):
599599

600600
Ny, Nx = np.shape(a)
601601
if isinstance(xi, np.ndarray):
602-
x = xi.astype(np.int)
603-
y = yi.astype(np.int)
602+
x = xi.astype(int)
603+
y = yi.astype(int)
604604
# Check that xn, yn don't exceed max index
605605
xn = np.clip(x + 1, 0, Nx - 1)
606606
yn = np.clip(y + 1, 0, Ny - 1)
60 B3BA 7607
else:
608-
x = np.int(xi)
609-
y = np.int(yi)
608+
x = int(xi)
609+
y = int(yi)
610610
# conditional is faster than clipping for integers
611611
if x == (Nx - 2):
612612
xn = x

lib/matplotlib/tests/test_image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ def test_mask_image():
705705

706706
ax1.imshow(A, interpolation='nearest')
707707

708-
A = np.zeros((5, 5), dtype=np.bool)
708+
A = np.zeros((5, 5), dtype=bool)
709709
A[1:2, 1:2] = True
710710
A = np.ma.masked_array(np.ones((5, 5), dtype=np.uint16), A)
711711

0 commit comments

Comments
 (0)
0