Skip to content

Commit e70c9d2

Browse files
authored
Merge pull request #15991 from anntzer/sdt
Avoid setting dtypes as strings...
2 parents 7ff965a + 3debddb commit e70c9d2

File tree

10 files changed

+24
-26
lines changed

10 files changed

+24
-26
lines changed

examples/axes_grid1/demo_axes_rgb.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def get_rgb():
3434

3535
def make_cube(r, g, b):
3636
ny, nx = r.shape
37-
R = np.zeros([ny, nx, 3], dtype="d")
37+
R = np.zeros((ny, nx, 3))
3838
R[:, :, 0] = r
3939
G = np.zeros_like(R)
4040
G[:, :, 1] = g

examples/axes_grid1/inset_locator_demo2.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ def add_sizebar(ax, size):
5656
# Second subplot, showing an image with an inset zoom
5757
# and a marked inset
5858
Z, extent = get_demo_image()
59-
Z2 = np.zeros([150, 150], dtype="d")
59+
Z2 = np.zeros((150, 150))
6060
ny, nx = Z.shape
61-
Z2[30:30 + ny, 30:30 + nx] = Z
61+
Z2[30:30+ny, 30:30+nx] = Z
6262

6363
# extent = [-3, 4, -4, 3]
6464
ax2.imshow(Z2, extent=extent, origin="lower")

examples/subplots_axes_and_figures/zoom_inset_axes.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ def get_demo_image():
2323

2424
# make data
2525
Z, extent = get_demo_image()
26-
Z2 = np.zeros([150, 150], dtype="d")
26+
Z2 = np.zeros((150, 150))
2727
ny, nx = Z.shape
28-
Z2[30:30 + ny, 30:30 + nx] = Z
28+
Z2[30:30+ny, 30:30+nx] = Z
2929

3030
ax.imshow(Z2, extent=extent, origin="lower")
3131

lib/matplotlib/tests/test_cbook.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,9 @@ def test_to_prestep():
369369

370370
xs, y1s, y2s = cbook.pts_to_prestep(x, y1, y2)
371371

372-
x_target = np.asarray([0, 0, 1, 1, 2, 2, 3], dtype='float')
373-
y1_target = np.asarray([0, 1, 1, 2, 2, 3, 3], dtype='float')
374-
y2_target = np.asarray([3, 2, 2, 1, 1, 0, 0], dtype='float')
372+
x_target = np.asarray([0, 0, 1, 1, 2, 2, 3], dtype=float)
373+
y1_target = np.asarray([0, 1, 1, 2, 2, 3, 3], dtype=float)
374+
y2_target = np.asarray([3, 2, 2, 1, 1, 0, 0], dtype=float)
375375

376376
assert_array_equal(x_target, xs)
377377
assert_array_equal(y1_target, y1s)
@@ -394,9 +394,9 @@ def test_to_poststep():
394394

395395
xs, y1s, y2s = cbook.pts_to_poststep(x, y1, y2)
396396

397-
x_target = np.asarray([0, 1, 1, 2, 2, 3, 3], dtype='float')
398-
y1_target = np.asarray([0, 0, 1, 1, 2, 2, 3], dtype='float')
399-
y2_target = np.asarray([3, 3, 2, 2, 1, 1, 0], dtype='float')
397+
x_target = np.asarray([0, 1, 1, 2, 2, 3, 3], dtype=float)
398+
y1_target = np.asarray([0, 0, 1, 1, 2, 2, 3], dtype=float)
399+
y2_target = np.asarray([3, 3, 2, 2, 1, 1, 0], dtype=float)
400400

401401
assert_array_equal(x_target, xs)
402402
assert_array_equal(y1_target, y1s)
@@ -419,9 +419,9 @@ def test_to_midstep():
419419

420420
xs, y1s, y2s = cbook.pts_to_midstep(x, y1, y2)
421421

422-
x_target = np.asarray([0, .5, .5, 1.5, 1.5, 2.5, 2.5, 3], dtype='float')
423-
y1_target = np.asarray([0, 0, 1, 1, 2, 2, 3, 3], dtype='float')
424-
y2_target = np.asarray([3, 3, 2, 2, 1, 1, 0, 0], dtype='float')
422+
x_target = np.asarray([0, .5, .5, 1.5, 1.5, 2.5, 2.5, 3], dtype=float)
423+
y1_target = np.asarray([0, 0, 1, 1, 2, 2, 3, 3], dtype=float)
424+
y2_target = np.asarray([3, 3, 2, 2, 1, 1, 0, 0], dtype=float)
425425

426426
assert_array_equal(x_target, xs)
427427
assert_array_equal(y1_target, y1s)

lib/matplotlib/tests/test_image.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ def test_imshow_masked_interpolation():
955955
N = 20
956956
n = colors.Normalize(vmin=0, vmax=N*N-1)
957957

958-
data = np.arange(N*N, dtype='float').reshape(N, N)
958+
data = np.arange(N*N, dtype=float).reshape(N, N)
959959

960960
data[5, 5] = -1
961961
# This will cause crazy ringing for the higher-order

lib/matplotlib/tests/test_ticker.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ class TestLogFormatterExponent:
575575
# formatted.
576576
(False, 10, np.array([0.1, 0.00001, np.pi, 0.2, -0.2, -0.00001]),
577577
range(6), ['0.1', '1e-05', '3.14', '0.2', '-0.2', '-1e-05']),
578-
(False, 50, np.array([3, 5, 12, 42], dtype='float'), range(6),
578+
(False, 50, np.array([3, 5, 12, 42], dtype=float), range(6),
579579
['3', '5', '12', '42']),
580580
]
581581

lib/matplotlib/tests/test_units.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,8 @@ def test_empty_arrays():
158158

159159

160160
def test_scatter_element0_masked():
161-
162161
times = np.arange('2005-02', '2005-03', dtype='datetime64[D]')
163-
164-
y = np.arange(len(times), dtype='float')
162+
y = np.arange(len(times), dtype=float)
165163
y[0] = np.nan
166164
fig, ax = plt.subplots()
167165
ax.scatter(times, y)

lib/mpl_toolkits/axes_grid1/axes_divider.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,8 @@ def _determine_karray(equivalent_sizes, appended_sizes,
597597
total_appended_size):
598598

599599
n = len(equivalent_sizes)
600-
A = np.mat(np.zeros((n+1, n+1), dtype="d"))
601-
B = np.zeros((n+1), dtype="d")
600+
A = np.mat(np.zeros((n + 1, n + 1)))
601+
B = np.zeros(n + 1)
602602
# AxK = B
603603

604604
# populated A

lib/mpl_toolkits/axes_grid1/axes_rgb.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def make_rgb_axes(ax, pad=0.01, axes_class=None, add_all=True):
5757

5858
def imshow_rgb(ax, r, g, b, **kwargs):
5959
ny, nx = r.shape
60-
R = np.zeros([ny, nx, 3], dtype="d")
60+
R = np.zeros((ny, nx, 3))
6161
R[:, :, 0] = r
6262
G = np.zeros_like(R)
6363
G[:, :, 1] = g

lib/mpl_toolkits/tests/test_axes_grid1.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ def test_inset_locator():
126126
# Z is a 15x15 array
127127
Z = np.load(cbook.get_sample_data("axes_grid/bivariate_normal.npy"))
128128
extent = (-3, 4, -4, 3)
129-
Z2 = np.zeros([150, 150], dtype="d")
129+
Z2 = np.zeros((150, 150))
130130
ny, nx = Z.shape
131-
Z2[30:30 + ny, 30:30 + nx] = Z
131+
Z2[30:30+ny, 30:30+nx] = Z
132132

133133
# extent = [-3, 4, -4, 3]
134134
ax.imshow(Z2, extent=extent, interpolation="nearest",
@@ -168,9 +168,9 @@ def test_inset_axes():
168168
# Z is a 15x15 array
169169
Z = np.load(cbook.get_sample_data("axes_grid/bivariate_normal.npy"))
170170
extent = (-3, 4, -4, 3)
171-
Z2 = np.zeros([150, 150], dtype="d")
171+
Z2 = np.zeros((150, 150))
172172
ny, nx = Z.shape
173-
Z2[30:30 + ny, 30:30 + nx] = Z
173+
Z2[30:30+ny, 30:30+nx] = Z
174174

175175
# extent = [-3, 4, -4, 3]
176176
ax.imshow(Z2, extent=extent, interpolation="nearest",

0 commit comments

Comments
 (0)