diff options
author | Eric Moore <ewm@redtetrahedron.org> | 2016-03-23 09:00:23 -0400 |
---|---|---|
committer | Eric Moore <ewm@redtetrahedron.org> | 2016-03-23 09:00:23 -0400 |
commit | 5ed19d18b2c719a045ccbadf0a7d95d08e1609c8 (patch) | |
tree | f6152844c10b29fd579d61df83685b1d39e93c52 | |
parent | 42ba22c1ae84acb4e008b298801e71b4b121689b (diff) | |
download | numpy-5ed19d18b2c719a045ccbadf0a7d95d08e1609c8.tar.gz |
TST: also test cases that should fail in __complex__
-rw-r--r-- | numpy/core/tests/test_multiarray.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index 67c353451..ffdc50d2c 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -2494,6 +2494,28 @@ class TestMethods(TestCase): cp = complex(c) assert_equal(cp, c, msg) + def test__complex__should_not_work(self): + dtypes = ['i1', 'i2', 'i4', 'i8', + 'u1', 'u2', 'u4', 'u8', + 'f', 'd', 'g', 'F', 'D', 'G', + '?', 'O'] + for dt in dtypes: + a = np.array([1, 2, 3], dtype=dt) + assert_raises(TypeError, complex, a) + + dt = np.dtype([('a', 'f8'), ('b', 'i1')]) + b = np.array((1.0, 3), dtype=dt) + assert_raises(TypeError, complex, b) + + c = np.array([(1.0, 3), (2e-3, 7)], dtype=dt) + assert_raises(TypeError, complex, c) + + d = np.array('1+1j') + assert_raises(TypeError, complex, d) + + e = np.array(['1+1j'], 'U') + assert_raises(TypeError, complex, e) + class TestBinop(object): def test_inplace(self): |