Browse files

TST: Add test for special case in array interface

  • Loading branch information...
1 parent 9e7a766 commit bfceb537ee18c02537fd56b76328bd000a272ff2 @87 committed Sep 16, 2012
Showing with 14 additions and 0 deletions.
  1. +14 −0 numpy/core/tests/test_multiarray.py
View
14 numpy/core/tests/test_multiarray.py
@@ -2809,6 +2809,20 @@ def test_multiarray_flags_not_writable_attribute_deletion(self):
for s in attr:
assert_raises(AttributeError, delattr, a, s)
+def test_array_interface():
+ class Foo(object):
+ def __init__(self, value):
+ self.value = value
+ def __float__(self):
+ return float(self.value)
+ @property
+ def __array_interface__(self):
+ return {'typestr' : '=f8',
+ 'shape' : ()}
+ f = Foo(0.5)
+ assert_equal(np.array(f), [0.5])
+ assert_equal(np.array([f, f]), [0.5, 0.5])
+ assert_equal(np.array(f).dtype, np.dtype('=f8'))
def test_flat_element_deletion():
it = np.ones(3).flat

0 comments on commit bfceb53

Please sign in to comment.