diff options
author | Antony Lee <anntzer.lee@gmail.com> | 2021-08-24 10:37:06 +0200 |
---|---|---|
committer | Antony Lee <anntzer.lee@gmail.com> | 2021-08-24 10:38:53 +0200 |
commit | 60116f24a7121e1542fda0655bba56bd3647d26d (patch) | |
tree | 55da35750a1b362dac786c0735a00acee7ccce1d | |
parent | 158159d43a988ff418df5aee3c8b3ecfcb1d0986 (diff) | |
download | numpy-60116f24a7121e1542fda0655bba56bd3647d26d.tar.gz |
MAINT: Avoid use of confusing compat aliases.
As of Py3, np.compat.unicode == str, but that's not entirely obvious
(it could correspond to some numpy dtype too), so just use plain str.
Likewise for np.compat.int.
tests are intentionally left unchanged, as they can be considered as
implicitly testing the np.compat.py3k interface as well.
-rw-r--r-- | numpy/lib/npyio.py | 4 | ||||
-rw-r--r-- | numpy/random/_generator.pyx | 2 | ||||
-rw-r--r-- | numpy/random/mtrand.pyx | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index 91c25078b..dfcb07d4f 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -1537,9 +1537,9 @@ def fromregex(file, regexp, dtype, encoding=None): dtype = np.dtype(dtype) content = file.read() - if isinstance(content, bytes) and isinstance(regexp, np.compat.unicode): + if isinstance(content, bytes) and isinstance(regexp, str): regexp = asbytes(regexp) - elif isinstance(content, np.compat.unicode) and isinstance(regexp, bytes): + elif isinstance(content, str) and isinstance(regexp, bytes): regexp = asstr(regexp) if not hasattr(regexp, 'match'): diff --git a/numpy/random/_generator.pyx b/numpy/random/_generator.pyx index e2430d139..60b6bfc72 100644 --- a/numpy/random/_generator.pyx +++ b/numpy/random/_generator.pyx @@ -561,7 +561,7 @@ cdef class Generator: raise TypeError('Unsupported dtype %r for integers' % _dtype) - if size is None and dtype in (bool, int, np.compat.long): + if size is None and dtype in (bool, int): if np.array(ret).shape == (): return dtype(ret) return ret diff --git a/numpy/random/mtrand.pyx b/numpy/random/mtrand.pyx index 4f5862faa..c9d8ee8e3 100644 --- a/numpy/random/mtrand.pyx +++ b/numpy/random/mtrand.pyx @@ -763,7 +763,7 @@ cdef class RandomState: else: raise TypeError('Unsupported dtype %r for randint' % _dtype) - if size is None and dtype in (bool, int, np.compat.long): + if size is None and dtype in (bool, int): if np.array(ret).shape == (): return dtype(ret) return ret |