summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_function_base.py
diff options
context:
space:
mode:
authorAnthony Vo <anthonyhvo12@gmail.com>2021-04-05 23:27:23 +0700
committerAnthony Vo <anthonyhvo12@gmail.com>2021-04-05 23:27:23 +0700
commite4856c1197274a4b57b6ddc0e8ea7d7e4854986d (patch)
treed2a5dd5209cdd367a953b8c25f625cf94300f464 /numpy/lib/tests/test_function_base.py
parent2c1410becc7fbe660426e2a946d54304fc470148 (diff)
parent7bb6a502ebaecd829e3c763e9f90220835e7b733 (diff)
downloadnumpy-e4856c1197274a4b57b6ddc0e8ea7d7e4854986d.tar.gz
Merge branch 'main' of https://github.com/numpy/numpy into avo-exceptions-chaining
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r--numpy/lib/tests/test_function_base.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index 4c7c0480c..afcb81eff 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -2399,6 +2399,14 @@ class TestPiecewise:
assert_array_equal(y, np.array([[-1., -1., -1.],
[3., 3., 1.]]))
+ def test_subclasses(self):
+ class subclass(np.ndarray):
+ pass
+ x = np.arange(5.).view(subclass)
+ r = piecewise(x, [x<2., x>=4], [-1., 1., 0.])
+ assert_equal(type(r), subclass)
+ assert_equal(r, [-1., -1., 0., 0., 1.])
+
class TestBincount: