Skip to content

Commit 2623523

Browse files
author
Mathieu Scheltienne
committed
replace np.sctypes with np.core.sctypes
1 parent 8fea2a8 commit 2623523

12 files changed

+34
-32
lines changed

nibabel/casting.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ def ok_floats():
714714
Remove longdouble if it has no higher precision than float64
715715
"""
716716
# copy float list so we don't change the numpy global
717-
floats = np.sctypes['float'][:]
717+
floats = np.core.sctypes['float'][:]
718718
if best_float() != np.longdouble and np.longdouble in floats:
719719
floats.remove(np.longdouble)
720720
return sorted(floats, key=lambda f: type_info(f)['nmant'])
@@ -750,10 +750,10 @@ def able_int_type(values):
750750
mn = min(values)
751751
mx = max(values)
752752
if mn >= 0:
753-
for ityp in np.sctypes['uint']:
753+
for ityp in np.core.sctypes['uint']:
754754
if mx <= np.iinfo(ityp).max:
755755
return ityp
756-
for ityp in np.sctypes['int']:
756+
for ityp in np.core.sctypes['int']:
757757
info = np.iinfo(ityp)
758758
if mn >= info.min and mx <= info.max:
759759
return ityp

nibabel/tests/test_arraywriters.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
from ..testing import assert_allclose_safely, suppress_warnings
2525
from ..volumeutils import _dt_min_max, apply_read_scaling, array_from_file
2626

27-
FLOAT_TYPES = np.sctypes['float']
28-
COMPLEX_TYPES = np.sctypes['complex']
29-
INT_TYPES = np.sctypes['int']
30-
UINT_TYPES = np.sctypes['uint']
27+
FLOAT_TYPES = np.core.sctypes['float']
28+
COMPLEX_TYPES = np.core.sctypes['complex']
29+
INT_TYPES = np.core.sctypes['int']
30+
UINT_TYPES = np.core.sctypes['uint']
3131
CFLOAT_TYPES = FLOAT_TYPES + COMPLEX_TYPES
3232
IUINT_TYPES = INT_TYPES + UINT_TYPES
3333
NUMERIC_TYPES = CFLOAT_TYPES + IUINT_TYPES

nibabel/tests/test_casting.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525

2626
def test_shared_range():
27-
for ft in np.sctypes['float']:
28-
for it in np.sctypes['int'] + np.sctypes['uint']:
27+
for ft in np.core.sctypes['float']:
28+
for it in np.core.sctypes['int'] + np.core.sctypes['uint']:
2929
# Test that going a bit above or below the calculated min and max
3030
# either generates the same number when cast, or the max int value
3131
# (if this system generates that) or something smaller (because of
@@ -54,7 +54,7 @@ def test_shared_range():
5454
assert np.all((bit_bigger == casted_mx) | (bit_bigger == imax))
5555
else:
5656
assert np.all(bit_bigger <= casted_mx)
57-
if it in np.sctypes['uint']:
57+
if it in np.core.sctypes['uint']:
5858
assert mn == 0
5959
continue
6060
# And something larger for the minimum
@@ -90,8 +90,8 @@ def test_shared_range_inputs():
9090

9191

9292
def test_casting():
93-
for ft in np.sctypes['float']:
94-
for it in np.sctypes['int'] + np.sctypes['uint']:
93+
for ft in np.core.sctypes['float']:
94+
for it in np.core.sctypes['int'] + np.core.sctypes['uint']:
9595
ii = np.iinfo(it)
9696
arr = [ii.min - 1, ii.max + 1, -np.inf, np.inf, np.nan, 0.2, 10.6]
9797
farr_orig = np.array(arr, dtype=ft)
@@ -140,7 +140,7 @@ def test_casting():
140140

141141

142142
def test_int_abs():
143-
for itype in np.sctypes['int']:
143+
for itype in np.core.sctypes['int']:
144144
info = np.iinfo(itype)
145145
in_arr = np.array([info.min, info.max], dtype=itype)
146146
idtype = np.dtype(itype)
@@ -188,7 +188,7 @@ def test_able_int_type():
188188

189189
def test_able_casting():
190190
# Check the able_int_type function guesses numpy out type
191-
types = np.sctypes['int'] + np.sctypes['uint']
191+
types = np.core.sctypes['int'] + np.core.sctypes['uint']
192192
for in_type in types:
193193
in_info = np.iinfo(in_type)
194194
in_mn, in_mx = in_info.min, in_info.max

nibabel/tests/test_floating.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def dtt2dict(dtt):
4343

4444
def test_type_info():
4545
# Test routine to get min, max, nmant, nexp
46-
for dtt in np.sctypes['int'] + np.sctypes['uint']:
46+
for dtt in np.core.sctypes['int'] + np.core.sctypes['uint']:
4747
info = np.iinfo(dtt)
4848
infod = type_info(dtt)
4949
assert infod == dict(
@@ -212,7 +212,7 @@ def test_int_to_float():
212212
def test_as_int_np_fix():
213213
# Test as_int works for integers. We need as_int for integers because of a
214214
# numpy 1.4.1 bug such that int(np.uint32(2**32-1) == -1
215-
for t in np.sctypes['int'] + np.sctypes['uint']:
215+
for t in np.core.sctypes['int'] + np.core.sctypes['uint']:
216216
info = np.iinfo(t)
217217
mn, mx = np.array([info.min, info.max], dtype=t)
218218
assert (mn, mx) == (as_int(mn), as_int(mx))

nibabel/tests/test_image_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ def _check_array_caching(self, imaker, meth_name, caching):
403403
return
404404
# Return original array from get_fdata only if the input array is the
405405
# requested dtype.
406-
float_types = np.sctypes['float']
406+
float_types = np.core.sctypes['float']
407407
if arr_dtype not in float_types:
408408
return
409409
for float_type in float_types:

nibabel/tests/test_proxy_api.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ def validate_array_interface_with_dtype(self, pmaker, params):
146146
context.__enter__()
147147
warnings.simplefilter('ignore', np.ComplexWarning)
148148

149-
for dtype in np.sctypes['float'] + np.sctypes['int'] + np.sctypes['uint']:
149+
for dtype in (
150+
np.core.sctypes["float"] + np.core.sctypes["int"] + np.core.sctypes["uint"]
151+
):
150152
# Directly coerce with a dtype
151153
direct = dtype(prox)
152154
# Half-precision is imprecise. Obviously. It's a bad idea, but don't break

nibabel/tests/test_round_trip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def test_round_trip():
102102
rng = np.random.RandomState(20111121)
103103
N = 10000
104104
sd_10s = range(-20, 51, 5)
105-
iuint_types = np.sctypes['int'] + np.sctypes['uint']
105+
iuint_types = np.core.sctypes['int'] + np.core.sctypes['uint']
106106
# Remove types which cannot be set into nifti header datatype
107107
nifti_supported = supported_np_types(Nifti1Header())
108108
iuint_types = [t for t in iuint_types if t in nifti_supported]

nibabel/tests/test_scaling.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ def test_array_file_scales(in_type, out_type):
177177
],
178178
)
179179
def test_scaling_in_abstract(category0, category1, overflow):
180-
for in_type in np.sctypes[category0]:
181-
for out_type in np.sctypes[category1]:
180+
for in_type in np.core.sctypes[category0]:
181+
for out_type in np.core.sctypes[category1]:
182182
if overflow:
183183
with suppress_warnings():
184184
check_int_a2f(in_type, out_type)
@@ -191,7 +191,7 @@ def check_int_a2f(in_type, out_type):
191191
big_floater = np.maximum_sctype(np.float64)
192192
info = type_info(in_type)
193193
this_min, this_max = info['min'], info['max']
194-
if not in_type in np.sctypes['complex']:
194+
if not in_type in np.core.sctypes['complex']:
195195
data = np.array([this_min, this_max], in_type)
196196
# Bug in numpy 1.6.2 on PPC leading to infs - abort
197197
if not np.all(np.isfinite(data)):

nibabel/tests/test_spm99analyze.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from ..volumeutils import _dt_min_max, apply_read_scaling
3636
from . import test_analyze
3737

38-
# np.sctypes values are lists of types with unique sizes
38+
# np.core.sctypes values are lists of types with unique sizes
3939
# For testing, we want all concrete classes of a type
4040
# Key on kind, rather than abstract base classes, since timedelta64 is a signedinteger
4141
sctypes = {}

nibabel/tests/test_testing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def test_assert_allclose_safely():
4848
with pytest.raises(AssertionError):
4949
assert_allclose_safely(a, b)
5050
# Test allcloseness of inf, especially np.float128 infs
51-
for dtt in np.sctypes['float']:
51+
for dtt in np.core.sctypes['float']:
5252
a = np.array([-np.inf, 1, np.inf], dtype=dtt)
5353
b = np.array([-np.inf, 1, np.inf], dtype=dtt)
5454
assert_allclose_safely(a, b)

0 commit comments

Comments
 (0)