diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2020-08-25 19:14:51 -0500 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2020-09-02 13:19:29 -0500 |
commit | 07c2e66efbf8d98af0da573f0e7a90765b6b979c (patch) | |
tree | 1ae65ef3687339c674126993fb3debbebc30b450 /numpy | |
parent | 76253895fbfbd2b6f5a5d4a5d2c6b96ff2dc5a0c (diff) | |
download | numpy-07c2e66efbf8d98af0da573f0e7a90765b6b979c.tar.gz |
TST: Test void promotion uses equivalent casting
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/tests/test_numeric.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/numpy/core/tests/test_numeric.py b/numpy/core/tests/test_numeric.py index ae5ee4c88..89a82d3b6 100644 --- a/numpy/core/tests/test_numeric.py +++ b/numpy/core/tests/test_numeric.py @@ -1025,6 +1025,24 @@ class TestTypes: assert res_bs == res assert res_bs.metadata == res.metadata + @pytest.mark.parametrize(["dtype1", "dtype2"], + [[np.dtype("V6"), np.dtype("V10")], + [np.dtype([("name1", "i8")]), np.dtype([("name2", "i8")])], + [np.dtype("i8,i8"), np.dtype("i4,i4")], + ]) + def test_invalid_void_promotion(self, dtype1, dtype2): + # Mainly test structured void promotion, which currently allows + # byte-swapping, but nothing else: + with pytest.raises(TypeError): + np.promote_types(dtype1, dtype2) + + @pytest.mark.parametrize(["dtype1", "dtype2"], + [[np.dtype("V10"), np.dtype("V10")], + [np.dtype([("name1", "<i8")]), np.dtype([("name1", ">i8")])], + [np.dtype("i8,i8"), np.dtype("i8,>i8")], + ]) + def test_valid_void_promotion(self, dtype1, dtype2): + assert np.promote_types(dtype1, dtype2) is dtype1 def test_can_cast(self): assert_(np.can_cast(np.int32, np.int64)) |