Skip to content

Commit e14d9c8

Browse files
authored
Merge pull request numpy#24144 from ev-br/rm_np_cast
API: Remove several niche objects for numpy 2.0 python API cleanup
2 parents 7351341 + cdfda1d commit e14d9c8

File tree

6 files changed

+10
-363
lines changed

6 files changed

+10
-363
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
* ``np.cast`` has been removed. The literal replacement for
2+
``np.cast[dtype](arg)`` is ``np.asarray(arg, dtype=dtype)``.
3+
4+
* ``np.source`` has been removed. The preferred replacement is
5+
``inspect.getsource``.
6+
7+
* ``np.lookfor`` has been removed.

numpy/core/numerictypes.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090

9191
# we add more at the bottom
9292
__all__ = ['sctypeDict', 'sctypes',
93-
'ScalarType', 'obj2sctype', 'cast', 'nbytes', 'sctype2char',
93+
'ScalarType', 'obj2sctype', 'nbytes', 'sctype2char',
9494
'maximum_sctype', 'issctype', 'typecodes', 'find_common_type',
9595
'issubdtype', 'datetime_data', 'datetime_as_string',
9696
'busday_offset', 'busday_count', 'is_busday', 'busdaycalendar',
@@ -434,14 +434,12 @@ def __getitem__(self, obj):
434434
return dict.__getitem__(self, obj2sctype(obj))
435435

436436
nbytes = _typedict()
437-
_alignment = _typedict()
438437
_maxvals = _typedict()
439438
_minvals = _typedict()
440439
def _construct_lookups():
441440
for name, info in _concrete_typeinfo.items():
442441
obj = info.type
443442
nbytes[obj] = info.bits // 8
444-
_alignment[obj] = info.alignment
445443
if len(info) > 5:
446444
_maxvals[obj] = info.max
447445
_minvals[obj] = info.min
@@ -503,12 +501,6 @@ def sctype2char(sctype):
503501
raise KeyError(sctype)
504502
return dtype(sctype).char
505503

506-
# Create dictionary of casting functions that wrap sequences
507-
# indexed by type or type character
508-
cast = _typedict()
509-
for key in _concrete_types:
510-
cast[key] = lambda x, k=key: array(x, copy=False).astype(k)
511-
512504

513505
def _scalar_type_key(typ):
514506
"""A ``key`` function for `sorted`."""

numpy/lib/tests/test_utils.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,6 @@
1111
from io import StringIO
1212

1313

14-
@pytest.mark.skipif(sys.flags.optimize == 2, reason="Python running -OO")
15-
@pytest.mark.skipif(
16-
sys.version_info == (3, 10, 0, "candidate", 1),
17-
reason="Broken as of bpo-44524",
18-
)
19-
def test_lookfor():
20-
out = StringIO()
21-
utils.lookfor('eigenvalue', module='numpy', output=out,
22-
import_modules=False)
23-
out = out.getvalue()
24-
assert_('numpy.linalg.eig' in out)
25-
26-
2714
@deprecate
2815
def old_func(self, x):
2916
return x

0 commit comments

Comments
 (0)