8000 MAINT: Remove uses of scalar aliases · eric-wieser/numpy@6dfe331 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6dfe331

Browse files
committed
MAINT: Remove uses of scalar aliases
Relates to numpygh-6103
1 parent 231f59d commit 6dfe331

27 files changed

+77
-79
lines changed

doc/neps/roadmap.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ improve the dtype system.
4242
- One of these should probably be the default for text data. The current
4343
behavior on Python 3 is neither efficient nor user friendly.
4444

45-
- `np.int` should not be platform dependent
45+
- ``np.dtype(int)`` should not be platform dependent
4646
- Better coercion for string + number
4747

4848
Performance

doc/source/reference/random/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ cleanup means that legacy and compatibility methods have been removed from
5757
``randint``, ``integers`` Add an ``endpoint`` kwarg
5858
``random_integers``
5959
------------------- -------------- ------------
60-
``tomaxint`` removed Use ``integers(0, np.iinfo(np.int).max,``
60+
``tomaxint`` removed Use ``integers(0, np.iinfo(np.int_).max,``
6161
``endpoint=False)``
6262
------------------- -------------- ------------
6363
``seed`` removed Use `~.SeedSequence.spawn`

doc/source/reference/random/multithreading.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ seed will produce the same outputs.
4141
self.n = n
4242
self.executor = concurrent.futures.ThreadPoolExecutor(threads)
4343
self.values = np.empty(n)
44-
self.step = np.ceil(n / threads).astype(np.int)
44+
self.step = np.ceil(n / threads).astype(np.int_)
4545
4646
def fill(self):
4747
def _fill(random_state, out, first, last):

doc/source/release/1.11.0-notes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ New Features
200200
* A ``dtype`` parameter has been added to ``np.random.randint``
201201
Random ndarrays of the following types can now be generated:
202202

203-
- ``np.bool``,
203+
- ``np.bool_``,
204204
- ``np.int8``, ``np.uint8``,
205205
- ``np.int16``, ``np.uint16``,
206206
- ``np.int32``, ``np.uint32``,

doc/source/release/1.13.0-notes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ In particular ``np.gradient`` can now take:
275275

276276
This means that, e.g., it is now possible to do the following::
277277

278-
>>> f = np.array([[1, 2, 6], [3, 4, 5]], dtype=np.float)
278+
>>> f = np.array([[1, 2, 6], [3, 4, 5]], dtype=np.float_)
279279
>>> dx = 2.
280280
>>> y = [1., 1.5, 3.5]
281281
>>> np.gradient(f, dx, y)

numpy/core/numerictypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ def sctype2char(sctype):
485485
486486
Examples
487487
--------
488-
>>> for sctype in [np.int32, np.double, np.complex, np.string_, np.ndarray]:
488+
>>> for sctype in [np.int32, np.double, np.complex_, np.string_, np.ndarray]:
489489
... print(np.sctype2char(sctype))
490490
l # may vary
491491
d

numpy/core/tests/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ class MyNDArray(np.ndarray):
296296
)
297297
def test_array_astype_warning(t):
298298
# test ComplexWarning when casting from complex to float or int
299-
a = np.array(10, dtype=np.complex)
299+
a = np.array(10, dtype=np.complex_)
300300
assert_warns(np.ComplexWarning, a.astype, t)
301301

302302
def test_copyto_fromscalar():

numpy/core/tests/test_dtype.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def assert_dtype_not_equal(a, b):
2525

2626
class TestBuiltin(object):
2727
@pytest.mark.parametrize('t', [int, float, complex, np.int32, str, object,
28-
np.unicode])
28+
np.compat.unicode])
2929
def test_run(self, t):
3030
"""Only test hash runs at all."""
3131
dt = np.dtype(t)
@@ -986,7 +986,7 @@ def check_pickling(self, dtype):
986986
assert_equal(x[0], y[0])
987987

988988
@pytest.mark.parametrize('t', [int, float, complex, np.int32, str, object,
989-
np.unicode, bool])
989+
np.compat.unicode, bool])
990990
def test_builtin(self, t):
991991
self.check_pickling(np.dtype(t))
992992

numpy/core/tests/test_multiarray.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ def test_sequence_non_homogenous(self):
964964

965965
@pytest.mark.skipif(sys.version_info[0] >= 3, reason="Not Python 2")
966966
def test_sequence_long(self):
967-
assert_equal(np.array([long(4), long(4)]).dtype, np.long)
967+
assert_equal(np.array([long(4), long(4)]).dtype, long)
968968
assert_equal(np.array([long(4), 2**80]).dtype, object)
969969
assert_equal(np.array([long(4), 2**80, long(4)]).dtype, object)
970970
assert_equal(np.array([2**80, long(4)]).dtype, object)
@@ -1807,7 +1807,7 @@ def test_sort(self):
18071807

18081808
# test unicode sorts.
18091809
s = 'aaaaaaaa'
1810-
a = np.array([s + chr(i) for i in range(101)], dtype=np.unicode)
1810+
a = np.array([s + chr(i) for i in range(101)], dtype=np.unicode_)
18111811
b = a[::-1].copy()
18121812
for kind in self.sort_kinds:
18131813
msg = "unicode sort, kind=%s" % kind
@@ -2059,7 +2059,7 @@ def test_argsort(self):
20592059

20602060
# test unicode argsorts.
20612061
s = 'aaaaaaaa'
2062-
a = np.array([s + chr(i) for i in range(101)], dtype=np.unicode)
2062+
a = np.array([s + chr(i) for i in range(101)], dtype=np.unicode_)
20632063
b = a[::-1]
20642064
r = np.arange(101)
20652065
rr = r[::-1]
@@ -2142,7 +2142,7 @@ def test_argsort(self):
21422142
a = np.array(['aaaaaaaaa' for i in range(100)])
21432143
assert_equal(a.argsort(kind='m'), r)
21442144
# unicode
2145-
a = np.array(['aaaaaaaaa' for i in range(100)], dtype=np.unicode)
2145+
a = np.array(['aaaaaaaaa' for i in range(100)], dtype=np.unicode_)
21462146
assert_equal(a.argsort(kind='m'), r)
21472147

21482148
def test_sort_unicode_kind(self):
@@ -2271,7 +2271,7 @@ def test_searchsorted_unicode(self):
22712271
'P:\\20x_dapi_cy3\\20x_dapi_cy3_20100197_1',
22722272
'P:\\20x_dapi_cy3\\20x_dapi_cy3_20100198_1',
22732273
'P:\\20x_dapi_cy3\\20x_dapi_cy3_20100199_1'],
2274-
dtype=np.unicode)
2274+
dtype=np.unicode_)
22752275
ind = np.arange(len(a))
22762276
assert_equal([a.searchsorted(v, 'left') for v in a], ind)
22772277
assert_equal([a.searchsorted(v, 'right') for v in a], ind + 1)
@@ -7930,20 +7930,20 @@ def test_null_inside_bstring_array_is_truthy(self):
79307930
class TestUnicodeArrayNonzero(object):
79317931

79327932
def test_empty_ustring_array_is_falsey(self):
7933-
assert_(not np.array([''], dtype=np.unicode))
7933+
assert_(not np.array([''], dtype=np.unicode_))
79347934

79357935
def test_whitespace_ustring_array_is_falsey(self):
7936-
a = np.array(['eggs'], dtype=np.unicode)
7936+
a = np.array(['eggs'], dtype=np.unicode_)
79377937
a[0] = ' \0\0'
79387938
assert_(not a)
79397939

79407940
def test_all_null_ustring_array_is_falsey(self):
7941-
a = np.array(['eggs'], dtype=np.unicode)
7941+
a = np.array(['eggs'], dtype=np.unicode_)
79427942
a[0] = '\0\0\0\0'
79437943
assert_(not a)
79447944

79457945
def test_null_inside_ustring_array_is_truthy(self):
7946-
a = np.array(['eggs'], dtype=np.unicode)
7946+
a = np.array(['eggs'], dtype=np.unicode_)
79477947
a[0] = ' \0 \0'
79487948
assert_(a)
79497949

numpy/core/tests/test_nditer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2104,7 +2104,7 @@ def test_iter_buffering_string():
21042104
assert_equal(i[0], b'abc')
21052105
assert_equal(i[0].dtype, np.dtype('S6'))
21062106

2107-
a = np.array(['abc', 'a', 'abcd'], dtype=np.unicode)
2107+
a = np.array(['abc', 'a', 'abcd'], dtype=np.unicode_)
21082108
assert_equal(a.dtype, np.dtype('U4'))
21092109
assert_raises(TypeError, nditer, a, ['buffered'], ['readonly'],
21102110
op_dtypes='U2')

0 commit comments

Comments
 (0)
0