8000 Merge pull request #5076 from argriffing/simplify-numpy-int · scipy/scipy@10ca036 · GitHub
[go: up one dir, main page]

Skip to content

Commit 10ca036

Browse files
committed
Merge pull request #5076 from argriffing/simplify-numpy-int
use int, float, bool instead of np.int, np.float, np.bool See numpy/numpy#6103 for rationale.
2 parents b9af56a + 4f78ccd commit 10ca036

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+204
-204
lines changed

doc/source/tutorial/stats/plots/kde_plot2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import matplotlib.pyplot as plt
33
from scipy import stats
44

5-
x1 = np.array([-7, -5, 1, 4, 5], dtype=np.float)
5+
x1 = np.array([-7, -5, 1, 4, 5], dtype=float)
66
x_eval = np.linspace(-10, 10, num=200)
77
kde1 = stats.gaussian_kde(x1)
88
kde2 = stats.gaussian_kde(x1, bw_method='silverman')

scipy/cluster/hierarchy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -917,8 +917,8 @@ def to_tree(Z, rd=False):
917917

918918

919919
def _convert_to_bool(X):
920-
if X.dtype != np.bool:
921-
X = X.astype(np.bool)
920+
if X.dtype != bool:
921+
X = X.astype(bool)
922922
if not X.flags.contiguous:
923923
X = X.copy()
924924
return X

scipy/cluster/tests/test_hierarchy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def check_is_valid_linkage_various_size(self, nrow, ncol, valid):
301301
def test_is_valid_linkage_int_type(self):
302302
# Tests is_valid_linkage(Z) with integer type.
303303
Z = np.asarray([[0, 1, 3.0, 2],
304-
[3, 2, 4.0, 3]], dtype=np.int)
304+
[3, 2, 4.0, 3]], dtype=int)
305305
assert_(is_valid_linkage(Z) == False)
306306
assert_raises(TypeError, is_valid_linkage, Z, throw=True)
307307

@@ -364,7 +364,7 @@ class TestIsValidInconsistent(object):
364364
def test_is_valid_im_int_type(self):
365365
# Tests is_valid_im(R) with integer type.
366366
R = np.asarray([[0, 1, 3.0, 2],
367-
[3, 2, 4.0, 3]], dtype=np.int)
367+
[3, 2, 4.0, 3]], dtype=int)
368368
assert_(is_valid_im(R) == False)
369369
assert_raises(TypeError, is_valid_im, R, throw=True)
370370

scipy/cluster/tests/test_vq.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def test__vq_sametype(self):
120120
assert_raises(TypeError, _vq.vq, a, b)
121121

122122
def test__vq_invalid_type(self):
123-
a = np.array([1, 2], dtype=np.int)
123+
a = np.array([1, 2], dtype=int)
124124
assert_raises(TypeError, _vq.vq, a, a)
125125

126126
def test_vq_large_nfeat(self):

scipy/fftpack/tests/test_basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ def setUp(self):
673673
np.random.seed(1234)
674674

675675
def test_complex(self):
676-
if np.dtype(np.longcomplex).itemsize == np.dtype(np.complex).itemsize:
676+
if np.dtype(np.longcomplex).itemsize == np.dtype(complex).itemsize:
677677
# longdouble == double; so fft is supported
678678
return
679679

scipy/fftpack/tests/test_real_transforms.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def setUp(self):
156156

157157
class TestDCTIInt(_TestDCTBase):
158158
def setUp(self):
159-
self.rdt = np.int
159+
self.rdt = int
160160
self.dec = 5
161161
self.type = 1
162162

@@ -177,7 +177,7 @@ def setUp(self):
177177

178178
class TestDCTIIInt(_TestDCTIIBase):
179179
def setUp(self):
180-
self.rdt = np.int
180+
self.rdt = int
181181
self.dec = 5
182182
self.type = 2
183183

@@ -198,7 +198,7 @@ def setUp(self):
198198

199199
class TestDCTIIIInt(_TestDCTIIIBase):
200200
def setUp(self):
201-
self.rdt = np.int
201+
self.rdt = int
202202
self.dec = 5
203203
self.type = 3
204204

@@ -242,7 +242,7 @@ def setUp(self):
242242

243243
class TestIDCTIInt(_TestIDCTBase):
244244
def setUp(self):
245-
self.rdt = np.int
245+
self.rdt = int
246246
self.dec = 4
247247
self.type = 1
248248

@@ -263,7 +263,7 @@ def setUp(self):
263263

264264
class TestIDCTIIInt(_TestIDCTBase):
265265
def setUp(self):
266-
self.rdt = np.int
266+
self.rdt = int
267267
self.dec = 5
268268
self.type = 2
269269

@@ -284,7 +284,7 @@ def setUp(self):
284284

285285
class TestIDCTIIIInt(_TestIDCTBase):
286286
def setUp(self):
287-
self.rdt = np.int
287+
self.rdt = int
288288
self.dec = 5
289289
self.type = 3
290290

@@ -324,7 +324,7 @@ def setUp(self):
324324

325325
class TestDSTIInt(_TestDSTBase):
326326
def setUp(self):
327-
self.rdt = np.int
327+
self.rdt = int
328328
self.dec = 5
329329
self.type = 1
330330

@@ -345,7 +345,7 @@ def setUp(self):
345345

346346
class TestDSTIIInt(_TestDSTBase):
347347
def setUp(self):
348-
self.rdt = np.int
348+
self.rdt = int
349349
self.dec = 6
350350
self.type = 2
351351

@@ -366,7 +366,7 @@ def setUp(self):
366366

367367
class TestDSTIIIInt(_TestDSTBase):
368368
def setUp(self):
369-
self.rdt = np.int
369+
self.rdt = int
370370
self.dec = 7
371371
self.type = 3
372372

@@ -410,7 +410,7 @@ def setUp(self):
410410

411411
class TestIDSTIInt(_TestIDSTBase):
412412
def setUp(self):
413-
self.rdt = np.int
413+
self.rdt = int
414414
self.dec = 4
415415
self.type = 1
416416

@@ -431,7 +431,7 @@ def setUp(self):
431431

432432
class TestIDSTIIInt(_TestIDSTBase):
433433
def setUp(self):
434-
self.rdt = np.int
434+
self.rdt = int
435435
self.dec = 6
436436
self.type = 2
437437

@@ -452,7 +452,7 @@ def setUp(self):
452452

453453
class TestIDSTIIIInt(_TestIDSTBase):
454454
def setUp(self):
455-
self.rdt = np.int
455+
self.rdt = int
456456
self.dec = 6
457457
self.type = 3
458458

scipy/interpolate/interpolate_wrapper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def nearest(x, y, new_x):
3737

3838
TINY = 1e-10
3939
indices = np.searchsorted(midpoints_of_x, new_x+TINY)-1
40-
indices = np.atleast_1d(np.clip(indices, 0, np.Inf).astype(np.int))
40+
indices = np.atleast_1d(np.clip(indices, 0, np.Inf).astype(int))
4141
new_y = np.take(y, indices, axis=-1)
4242

4343
return new_y
@@ -177,6 +177,6 @@ def block(x, y, new_x):
177177
# If the value is at the front of the list, it'll have -1.
178178
# In this case, we will use the first (0), element in the array.
179179
# take requires the index array to be an Int
180-
indices = np.atleast_1d(np.clip(indices, 0, np.Inf).astype(np.int))
180+
indices = np.atleast_1d(np.clip(indices, 0, np.Inf).astype(int))
181181
new_y = np.take(y, indices, axis=-1)
182182
return new_y

scipy/interpolate/tests/test_fitpack2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def test_resize_regression(self):
8282

8383
def test_out_of_range_regression(self):
8484
# Test different extrapolation modes. See ticket 3557
85-
x = np.arange(5, dtype=np.float)
85+
x = np.arange(5, dtype=float)
8686
y = x**3
8787

8888
xp = linspace(-8, 13, 100)

scipy/interpolate/tests/test_interpolate_wrapper.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ def test_linear(self):
3636

3737
def test_block_average_above(self):
3838
N = 3000
39-
x = arange(N, dtype=np.float)
40-
y = arange(N, dtype=np.float)
39+
x = arange(N, dtype=float)
40+
y = arange(N, dtype=float)
4141

4242
new_x = arange(N // 2) * 2
4343
new_y = block_average_above(x, y, new_x)
4444
self.assertAllclose(new_y[:5], [0.0, 0.5, 2.5, 4.5, 6.5])
4545

4646
def test_linear2(self):
4747
N = 3000
48-
x = arange(N, dtype=np.float)
48+
x = arange(N, dtype=float)
4949
y = ones((100,N)) * arange(N)
5050
new_x = arange(N) + 0.5
5151
new_y = linear(x, y, new_x)

scipy/io/_fortran.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class FortranFile(object):
6666
>>> f = FortranFile('test.unf', 'r')
6767
>>> print(f.read_ints(dtype=np.int32))
6868
[1 2 3 4 5]
69-
>>> print(f.read_reals(dtype=np.float).reshape((5,-1)))
69+
>>> print(f.read_reals(dtype=float).reshape((5,-1)))
7070
[[ 0. 0.05263158 0.10526316 0.15789474]
7171
[ 0.21052632 0.26315789 0.31578947 0.36842105]
7272
[ 0.42105263 0.47368421 0.52631579 0.57894737]

0 commit comments

Comments
 (0)
0