summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2020-11-09 19:08:49 -0600
committerSebastian Berg <sebastian@sipsolutions.net>2020-11-24 21:25:02 -0600
commitdf1b2a8077052d539ff29b763413360434f3d44a (patch)
tree5ade7f43334059800f4c6843babf6d0ef65363fa
parent3cfcd221818b489712b8cfe1082743a1056b42ec (diff)
downloadnumpy-df1b2a8077052d539ff29b763413360434f3d44a.tar.gz
TST: Fixup tests for Void
Casting from object uses inspection logic, so doesn't actually end up in this path, and thus will not use (arguably incorrectly) reuse the itemsize of the object dtype in any case.
-rw-r--r--numpy/core/tests/test_api.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/numpy/core/tests/test_api.py b/numpy/core/tests/test_api.py
index edc549a94..0f42f7076 100644
--- a/numpy/core/tests/test_api.py
+++ b/numpy/core/tests/test_api.py
@@ -282,12 +282,17 @@ def test_array_astype():
assert_raises(TypeError, a.astype, 'U1', casting='safe')
-@pytest.mark.parametrize("dt", ["d", "f", "S13", "U32", "O"])
+@pytest.mark.parametrize("dt", ["d", "f", "S13", "U32"])
def test_array_astype_to_void(dt):
dt = np.dtype(dt)
arr = np.array([], dtype=dt)
assert arr.astype("V").dtype.itemsize == dt.itemsize
+def test_object_array_astype_to_void():
+ # This is different to `test_array_astype_to_void` as object arrays
+ # are inspected. The default void is "V8" (8 is the length of double)
+ arr = np.array([], dtype="O").astype("V")
+ assert arr.dtype == "V8"
@pytest.mark.parametrize("t",
np.sctypes['uint'] + np.sctypes['int'] + np.sctypes['float']