summaryrefslogtreecommitdiff
path: root/numpy/core/tests
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core/tests')
-rw-r--r--numpy/core/tests/test_multiarray.py20
-rw-r--r--numpy/core/tests/test_umath.py10
2 files changed, 30 insertions, 0 deletions
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py
index 50a02058e..ccfbe354c 100644
--- a/numpy/core/tests/test_multiarray.py
+++ b/numpy/core/tests/test_multiarray.py
@@ -946,6 +946,26 @@ class TestSummarization(TestCase):
assert repr(A) == reprA
+class TestChoose(TestCase):
+ def setUp(self):
+ self.x = 2*ones((3,),dtype=int)
+ self.y = 3*ones((3,),dtype=int)
+ self.x2 = 2*ones((2,3), dtype=int)
+ self.y2 = 3*ones((2,3), dtype=int)
+ self.ind = [0,0,1]
+
+ def test_basic(self):
+ A = np.choose(self.ind, (self.x, self.y))
+ assert_equal(A, [2,2,3])
+
+ def test_broadcast1(self):
+ A = np.choose(self.ind, (self.x2, self.y2))
+ assert_equal(A, [[2,2,3],[2,2,3]])
+
+ def test_broadcast2(self):
+ A = np.choose(self.ind, (self.x, self.y2))
+ assert_equal(A, [[2,2,3],[2,2,3]])
+
if __name__ == "__main__":
run_module_suite()
diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py
index b9c2675fd..ee2893f18 100644
--- a/numpy/core/tests/test_umath.py
+++ b/numpy/core/tests/test_umath.py
@@ -281,6 +281,16 @@ class TestAttributes(TestCase):
assert_equal(add.nout, 1)
assert_equal(add.identity, 0)
+class TestSubclass(TestCase):
+ def test_subclass_op(self):
+ class simple(np.ndarray):
+ def __new__(subtype, shape):
+ self = np.ndarray.__new__(subtype, shape, dtype=object)
+ self.fill(0)
+ return self
+ a = simple((3,4))
+ assert_equal(a+a, a)
+
def _check_branch_cut(f, x0, dx, re_sign=1, im_sign=-1, sig_zero_ok=False,
dtype=np.complex):
"""