Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/neps/roadmap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ improve the dtype system.
- One of these should probably be the default for text data. The current
behavior on Python 3 is neither efficient nor user friendly.

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

Performance
Expand Down
2 changes: 1 addition & 1 deletion doc/source/reference/random/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ cleanup means that legacy and compatibility methods have been removed from
``randint``, ``integers`` Add an ``endpoint`` kwarg
``random_integers``
------------------- -------------- ------------
``tomaxint`` removed Use ``integers(0, np.iinfo(np.int).max,``
``tomaxint`` removed Use ``integers(0, np.iinfo(np.int_).max,``
``endpoint=False)``
------------------- -------------- ------------
``seed`` removed Use `~.SeedSequence.spawn`
Expand Down
2 changes: 1 addition & 1 deletion doc/source/reference/random/multithreading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ seed will produce the same outputs.
self.n = n
self.executor = concurrent.futures.ThreadPoolExecutor(threads)
self.values = np.empty(n)
self.step = np.ceil(n / threads).astype(np.int)
self.step = np.ceil(n / threads).astype(np.int_)

def fill(self):
def _fill(random_state, out, first, last):
Expand Down
2 changes: 1 addition & 1 deletion doc/source/release/1.11.0-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ New Features
* A ``dtype`` parameter has been added to ``np.random.randint``
Random ndarrays of the following types can now be generated:

- ``np.bool``,
- ``np.bool_``,
- ``np.int8``, ``np.uint8``,
- ``np.int16``, ``np.uint16``,
- ``np.int32``, ``np.uint32``,
Expand Down
2 changes: 1 addition & 1 deletion doc/source/release/1.13.0-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ In particular ``np.gradient`` can now take:

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

>>> f = np.array([[1, 2, 6], [3, 4, 5]], dtype=np.float)
>>> f = np.array([[1, 2, 6], [3, 4, 5]], dtype=np.float_)
>>> dx = 2.
>>> y = [1., 1.5, 3.5]
>>> np.gradient(f, dx, y)
Expand Down
2 changes: 1 addition & 1 deletion numpy/core/numerictypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ def sctype2char(sctype):

Examples
--------
>>> for sctype in [np.int32, np.double, np.complex, np.string_, np.ndarray]:
>>> for sctype in [np.int32, np.double, np.complex_, np.string_, np.ndarray]:
... print(np.sctype2char(sctype))
l # may vary
d
Expand Down
2 changes: 1 addition & 1 deletion numpy/core/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ class MyNDArray(np.ndarray):
)
def test_array_astype_warning(t):
# test ComplexWarning when casting from complex to float or int
a = np.array(10, dtype=np.complex)
a = np.array(10, dtype=np.complex_)
assert_warns(np.ComplexWarning, a.astype, t)

def test_copyto_fromscalar():
Expand Down
4 changes: 2 additions & 2 deletions numpy/core/tests/test_dtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def assert_dtype_not_equal(a, b):

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

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

Expand Down
18 changes: 9 additions & 9 deletions numpy/core/tests/test_multiarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ def test_sequence_non_homogenous(self):

@pytest.mark.skipif(sys.version_info[0] >= 3, reason="Not Python 2")
def test_sequence_long(self):
assert_equal(np.array([long(4), long(4)]).dtype, np.long)
assert_equal(np.array([long(4), long(4)]).dtype, long)
assert_equal(np.array([long(4), 2**80]).dtype, object)
assert_equal(np.array([long(4), 2**80, long(4)]).dtype, object)
assert_equal(np.array([2**80, long(4)]).dtype, object)
Expand Down Expand Up @@ -1807,7 +1807,7 @@ def test_sort(self):

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

# test unicode argsorts.
s = 'aaaaaaaa'
a = np.array([s + chr(i) for i in range(101)], dtype=np.unicode)
a = np.array([s + chr(i) for i in range(101)], dtype=np.unicode_)
b = a[::-1]
r = np.arange(101)
rr = r[::-1]
Expand Down Expand Up @@ -2142,7 +2142,7 @@ def test_argsort(self):
a = np.array(['aaaaaaaaa' for i in range(100)])
assert_equal(a.argsort(kind='m'), r)
# unicode
a = np.array(['aaaaaaaaa' for i in range(100)], dtype=np.unicode)
a = np.array(['aaaaaaaaa' for i in range(100)], dtype=np.unicode_)
assert_equal(a.argsort(kind='m'), r)

def test_sort_unicode_kind(self):
Expand Down Expand Up @@ -2271,7 +2271,7 @@ def test_searchsorted_unicode(self):
'P:\\20x_dapi_cy3\\20x_dapi_cy3_20100197_1',
'P:\\20x_dapi_cy3\\20x_dapi_cy3_20100198_1',
'P:\\20x_dapi_cy3\\20x_dapi_cy3_20100199_1'],
dtype=np.unicode)
dtype=np.unicode_)
ind = np.arange(len(a))
assert_equal([a.searchsorted(v, 'left') for v in a], ind)
assert_equal([a.searchsorted(v, 'right') for v in a], ind + 1)
Expand Down Expand Up @@ -7930,20 +7930,20 @@ def test_null_inside_bstring_array_is_truthy(self):
class TestUnicodeArrayNonzero(object):

def test_empty_ustring_array_is_falsey(self):
assert_(not np.array([''], dtype=np.unicode))
assert_(not np.array([''], dtype=np.unicode_))

def test_whitespace_ustring_array_is_falsey(self):
a = np.array(['eggs'], dtype=np.unicode)
a = np.array(['eggs'], dtype=np.unicode_)
a[0] = ' \0\0'
assert_(not a)

def test_all_null_ustring_array_is_falsey(self):
a = np.array(['eggs'], dtype=np.unicode)
a = np.array(['eggs'], dtype=np.unicode_)
a[0] = '\0\0\0\0'
assert_(not a)

def test_null_inside_ustring_array_is_truthy(self):
a = np.array(['eggs'], dtype=np.unicode)
a = np.array(['eggs'], dtype=np.unicode_)
a[0] = ' \0 \0'
assert_(a)

Expand Down
2 changes: 1 addition & 1 deletion numpy/core/tests/test_nditer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2104,7 +2104,7 @@ def test_iter_buffering_string():
assert_equal(i[0], b'abc')
assert_equal(i[0].dtype, np.dtype('S6'))

a = np.array(['abc', 'a', 'abcd'], dtype=np.unicode)
a = np.array(['abc', 'a', 'abcd'], dtype=np.unicode_)
assert_equal(a.dtype, np.dtype('U4'))
assert_raises(TypeError, nditer, a, ['buffered'], ['readonly'],
op_dtypes='U2')
Expand Down
2 changes: 1 addition & 1 deletion numpy/core/tests/test_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -2953,7 +2953,7 @@ def test_sparse(self):
assert_array_equal(x, np.array([[0], [1], [2], [3]]))
assert_array_equal(y, np.array([[0, 1, 2]]))

@pytest.mark.parametrize("dtype", [np.int, np.float32, np.float64])
@pytest.mark.parametrize("dtype", [np.int32, np.int64, np.float32, np.float64])
@pytest.mark.parametrize("dims", [(), (0,), (4, 3)])
def test_return_type(self, dtype, dims):
inds = np.indices(dims, dtype=dtype)
Expand Down
4 changes: 2 additions & 2 deletions numpy/core/tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -1511,7 +1511,7 @@ def test_type(t):
min //= -1

with np.errstate(divide="ignore"):
for t in (np.int8, np.int16, np.int32, np.int64, int, np.long):
for t in (np.int8, np.int16, np.int32, np.int64, int, np.compat.long):
test_type(t)

def test_buffer_hashlib(self):
Expand Down Expand Up @@ -2112,7 +2112,7 @@ def test_unicode_alloc_dealloc_match(self):
# Ticket #1578, the mismatch only showed up when running
# python-debug for python versions >= 2.7, and then as
# a core dump and error message.
a = np.array(['abc'], dtype=np.unicode)[0]
a = np.array(['abc'], dtype=np.unicode_)[0]
del a

def test_refcount_error_in_clip(self):
Expand Down
5 changes: 2 additions & 3 deletions numpy/core/tests/test_scalarinherit.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ class Mystr(str, np.generic):
def test_char_repeat(self):
np_s = np.string_('abc')
np_u = np.unicode_('abc')
np_i = np.int(5)
res_s = b'abc' * 5
res_u = u'abc' * 5
assert_(np_s * np_i == res_s)
assert_(np_u * np_i == res_u)
assert_(np_s * 5 == res_s)
assert_(np_u * 5 == res_u)
2 changes: 1 addition & 1 deletion numpy/core/tests/test_ufunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ def test_can_ignore_signature(self):
assert_array_equal(out, mm_row_col_vec.squeeze())

def test_matrix_multiply(self):
self.compare_matrix_multiply_results(np.long)
self.compare_matrix_multiply_results(np.int64)
self.compare_matrix_multiply_results(np.double)

def test_matrix_multiply_umath_empty(self):
Expand Down
2 changes: 1 addition & 1 deletion numpy/core/tests/test_umath.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ def test_log_float32(self):
def test_sincos_float32(self):
np.random.seed(42)
N = 1000000
M = np.int(N/20)
M = np.int_(N/20)
index = np.random.randint(low=0, high=N, size=M)
x_f32 = np.float32(np.random.uniform(low=-100.,high=100.,size=N))
# test coverage for elements > 117435.992f for which glibc is used
Expand Down
2 changes: 1 addition & 1 deletion numpy/core/tests/test_umath_accuracy.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_validate_transcendentals(self):
with open(filepath) as fid:
file_without_comments = (r for r in fid if not r[0] in ('$', '#'))
data = np.genfromtxt(file_without_comments,
dtype=('|S39','|S39','|S39',np.int),
dtype=('|S39','|S39','|S39',int),
names=('type','input','output','ulperr'),
delimiter=',',
skip_header=1)
Expand Down
4 changes: 2 additions & 2 deletions numpy/doc/basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
- C type
- Description

* - `np.bool`
* - `np.bool_`
- ``bool``
- Boolean (True or False) stored as a byte

Expand Down Expand Up @@ -283,7 +283,7 @@
minimum or maximum values of NumPy integer and floating point values
respectively ::

>>> np.iinfo(np.int) # Bounds of the default integer on this system.
>>> np.iinfo(int) # Bounds of the default integer on this system.
iinfo(min=-9223372036854775808, max=9223372036854775807, dtype=int64)
>>> np.iinfo(np.int32) # Bounds of a 32-bit integer
iinfo(min=-2147483648, max=2147483647, dtype=int32)
Expand Down
4 changes: 2 additions & 2 deletions numpy/lib/npyio.py
Original file line number Diff line number Diff line change
Expand Up @@ -1529,9 +1529,9 @@ def fromregex(file, regexp, dtype, encoding=None):
dtype = np.dtype(dtype)

content = file.read()
if isinstance(content, bytes) and isinstance(regexp, np.unicode):
if isinstance(content, bytes) and isinstance(regexp, np.compat.unicode):
regexp = asbytes(regexp)
elif isinstance(content, np.unicode) and isinstance(regexp, bytes):
elif isinstance(content, np.compat.unicode) and isinstance(regexp, bytes):
regexp = asstr(regexp)

if not hasattr(regexp, 'match'):
Expand Down
26 changes: 13 additions & 13 deletions numpy/lib/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,15 +518,15 @@ def write(self, text):

def test_unicode(self):
utf8 = b'\xcf\x96'.decode('UTF-8')
a = np.array([utf8], dtype=np.unicode)
a = np.array([utf8], dtype=np.unicode_)
with tempdir() as tmpdir:
# set encoding as on windows it may not be unicode even on py3
np.savetxt(os.path.join(tmpdir, 'test.csv'), a, fmt=['%s'],
encoding='UTF-8')

def test_unicode_roundtrip(self):
utf8 = b'\xcf\x96'.decode('UTF-8')
a = np.array([utf8], dtype=np.unicode)
a = np.array([utf8], dtype=np.unicode_)
# our gz wrapper support encoding
suffixes = ['', '.gz']
# stdlib 2 versions do not support encoding
Expand All @@ -540,20 +540,20 @@ def test_unicode_roundtrip(self):
np.savetxt(os.path.join(tmpdir, 'test.csv' + suffix), a,
fmt=['%s'], encoding='UTF-16-LE')
b = np.loadtxt(os.path.join(tmpdir, 'test.csv' + suffix),
encoding='UTF-16-LE', dtype=np.unicode)
encoding='UTF-16-LE', dtype=np.unicode_)
assert_array_equal(a, b)

def test_unicode_bytestream(self):
utf8 = b'\xcf\x96'.decode('UTF-8')
a = np.array([utf8], dtype=np.unicode)
a = np.array([utf8], dtype=np.unicode_)
s = BytesIO()
np.savetxt(s, a, fmt=['%s'], encoding='UTF-8')
s.seek(0)
assert_equal(s.read().decode('UTF-8'), utf8 + '\n')

def test_unicode_stringstream(self):
utf8 = b'\xcf\x96'.decode('UTF-8')
a = np.array([utf8], dtype=np.unicode)
a = np.array([utf8], dtype=np.unicode_)
s = StringIO()
np.savetxt(s, a, fmt=['%s'], encoding='UTF-8')
s.seek(0)
Expand Down Expand Up @@ -632,20 +632,20 @@ def test_stringload(self):
with temppath() as path:
with open(path, "wb") as f:
f.write(nonascii.encode("UTF-16"))
x = self.loadfunc(path, encoding="UTF-16", dtype=np.unicode)
x = self.loadfunc(path, encoding="UTF-16", dtype=np.unicode_)
assert_array_equal(x, nonascii)

def test_binary_decode(self):
utf16 = b'\xff\xfeh\x04 \x00i\x04 \x00j\x04'
v = self.loadfunc(BytesIO(utf16), dtype=np.unicode, encoding='UTF-16')
v = self.loadfunc(BytesIO(utf16), dtype=np.unicode_, encoding='UTF-16')
assert_array_equal(v, np.array(utf16.decode('UTF-16').split()))

def test_converters_decode(self):
# test converters that decode strings
c = TextIO()
c.write(b'\xcf\x96')
c.seek(0)
x = self.loadfunc(c, dtype=np.unicode,
x = self.loadfunc(c, dtype=np.unicode_,
converters={0: lambda x: x.decode('UTF-8')})
a = np.array([b'\xcf\x96'.decode('UTF-8')])
assert_array_equal(x, a)
Expand All @@ -656,7 +656,7 @@ def test_converters_nodecode(self):
with temppath() as path:
with io.open(path, 'wt', encoding='UTF-8') as f:
f.write(utf8)
x = self.loadfunc(path, dtype=np.unicode,
x = self.loadfunc(path, dtype=np.unicode_,
converters={0: lambda x: x + 't'},
encoding='UTF-8')
a = np.array([utf8 + 't'])
Expand Down Expand Up @@ -1104,7 +1104,7 @@ def test_binary_load(self):
with open(path, "wb") as f:
f.write(butf8)
with open(path, "rb") as f:
x = np.loadtxt(f, encoding="UTF-8", dtype=np.unicode)
x = np.loadtxt(f, encoding="UTF-8", dtype=np.unicode_)
assert_array_equal(x, sutf8)
# test broken latin1 conversion people now rely on
with open(path, "rb") as f:
Expand Down Expand Up @@ -1587,7 +1587,7 @@ def test_utf8_userconverters_with_explicit_dtype(self):
with open(path, 'wb') as f:
f.write(b'skip,skip,2001-01-01' + utf8 + b',1.0,skip')
test = np.genfromtxt(path, delimiter=",", names=None, dtype=float,
usecols=(2, 3), converters={2: np.unicode},
usecols=(2, 3), converters={2: np.compat.unicode},
encoding='UTF-8')
control = np.array([('2001-01-01' + utf8.decode('UTF-8'), 1.)],
dtype=[('', '|U11'), ('', float)])
Expand Down Expand Up @@ -2126,7 +2126,7 @@ def test_utf8_file(self):
ctl = np.array([
["test1", "testNonethe" + utf8.decode("UTF-8"), "test3"],
["test1", "testNonethe" + utf8.decode("UTF-8"), "test3"]],
dtype=np.unicode)
dtype=np.unicode_)
assert_array_equal(test, ctl)

# test a mixed dtype
Expand Down Expand Up @@ -2169,7 +2169,7 @@ def test_utf8_file_nodtype_unicode(self):
["norm1", "norm2", "norm3"],
["norm1", latin1, "norm3"],
["test1", "testNonethe" + utf8, "test3"]],
dtype=np.unicode)
dtype=np.unicode_)
assert_array_equal(test, ctl)

def test_recfromtxt(self):
Expand Down
4 changes: 2 additions & 2 deletions numpy/lib/tests/test_ufunclike.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_isposinf(self):
assert_equal(res, tgt)
assert_equal(out, tgt)

a = a.astype(np.complex)
a = a.astype(np.complex_)
with assert_raises(TypeError):
ufl.isposinf(a)

Expand All @@ -36,7 +36,7 @@ def test_isneginf(self):
assert_equal(res, tgt)
assert_equal(out, tgt)

a = a.astype(np.complex)
a = a.astype(np.complex_)
with assert_raises(TypeError):
ufl.isneginf(a)

Expand Down
Loading