summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_io.py
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2020-02-03 16:17:26 -0800
committerSebastian Berg <sebastian@sipsolutions.net>2020-02-06 20:10:40 -0800
commit1a1611a33cfb5ea50d16d20affa5c6fa03e148d7 (patch)
treefb55b590501702b096a1fb3833c90589de1d86bb /numpy/lib/tests/test_io.py
parentdae4f67c797176c66281101be8f3b4d6c424735c (diff)
downloadnumpy-1a1611a33cfb5ea50d16d20affa5c6fa03e148d7.tar.gz
DEP: Do not allow "abstract" dtype conversion/creation
These dtypes do not really make sense as instances. We can (somewhat) reasonably define np.dtype(np.int64) as the default (machine endianess) int64. (Arguably, it is unclear that `np.array(arr_of_>f8, dtype="f")` should return arr_of_<f8, but that would be very noisy!) However, `np.integer` as equivalent to long, is not well defined. Similarly, `dtype=Decimal` may be neat to spell `dtype=object` when you intend to put Decimal objects into the array. But it is misleading, since there is no special meaning to it at this time. The biggest issue with it, is that `arr.astype(np.floating)` looks like it will let float32 or float128 pass, but it will force a float64 output! Arguably downcasting is a bug in this case. A related issue is `np.dtype("S")` and especially "S0". The dtype "S" does make sense for most or all places where `dtype=...` can be passed. However, it is conceptionally different from other dtypes, since it will not end up being attached to the array (unlike "S2" which would be). The dtype "S" really means the type number/DType class of String, and not a specific dtype instance.
Diffstat (limited to 'numpy/lib/tests/test_io.py')
-rw-r--r--numpy/lib/tests/test_io.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py
index 436cd1d24..db9f35f2a 100644
--- a/numpy/lib/tests/test_io.py
+++ b/numpy/lib/tests/test_io.py
@@ -2332,7 +2332,7 @@ M 33 21.99
assert_(test.dtype['f0'] == float)
assert_(test.dtype['f1'] == np.int64)
- assert_(test.dtype['f2'] == np.integer)
+ assert_(test.dtype['f2'] == np.int_)
assert_allclose(test['f0'], 73786976294838206464.)
assert_equal(test['f1'], 17179869184)