Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

TST: Complex to bool conversion (Ticket 2218)

  • Loading branch information...
commit a8ffb486a825104362698f9738d1759a63251724 1 parent f085bc2
seberg authored
Showing with 8 additions and 0 deletions.
  1. +8 −0 numpy/core/tests/test_regression.py
8 numpy/core/tests/test_regression.py
View
@@ -1459,6 +1459,14 @@ def test_complex_scalar_complex_cast(self):
x = tp(1+2j)
assert_equal(complex(x), 1+2j)
+ def test_complex_boolean_cast(self):
+ """Ticket #2218"""
+ for tp in [np.csingle, np.cdouble, np.clongdouble]:
+ x = np.array([0, 0+0.5j, 0.5+0j], dtype=tp)
+ assert_equal(x.astype(bool), np.array([0, 1, 1], dtype=bool))
+ assert_(np.any(x))
+ assert_(np.all(x[1:]))
+
def test_uint_int_conversion(self):
x = 2**64 - 1
assert_equal(int(np.uint64(x)), x)
Please sign in to comment.
Something went wrong with that request. Please try again.