8000 MAINT: Avoid use of confusing compat aliases. · numpy/numpy@60116f2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 60116f2

Browse files
committed
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.
1 parent 158159d commit 60116f2

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

numpy/lib/npyio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,9 +1537,9 @@ def fromregex(file, regexp, dtype, encoding=None):
15371537
dtype = np.dtype(dtype)
15381538

15391539
content = file.read()
1540-
if isinstance(content, bytes) and isinstance(regexp, np.compat.unicode):
1540+
if isinstance(content, bytes) and isinstance(regexp, str):
15411541
regexp = asbytes(regexp)
1542-
elif isinstance(content, np.compat.unicode) and isinstance(regexp, bytes):
1542+
elif isinstance(content, str) and isinstance(regexp, bytes):
15431543
regexp = asstr(regexp)
15441544

15451545
if not hasattr(regexp, 'match'):

numpy/random/_generator.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ cdef class Generator:
561561
raise TypeError('Unsupported dtype %r for integers' % _dtype)
562562

563563

564-
if size is None and dtype in (bool, int, np.compat.long):
564+
if size is None and dtype in (bool, int):
565565
if np.array(ret).shape == ():
566566
return dtype(ret)
567567
return ret

numpy/random/mtrand.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ cdef class RandomState:
763763
else:
764764
raise TypeError('Unsupported dtype %r for randint' % _dtype)
765765

766-
if size is None and dtype in (bool, int, np.compat.long):
766+
if size is None and dtype in (bool, int):
767767
if np.array(ret).shape == ():
768768
return dtype(ret)
769769
return ret

0 commit comments

Comments
 (0)
0