summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_function_base.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r--numpy/lib/tests/test_function_base.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index 27e7302ce..fcf89cb90 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -1919,6 +1919,20 @@ class TestMedian(TestCase):
assert_almost_equal(np.median(x2), 2)
assert_allclose(np.median(x2, axis=0), x)
+ def test_subclass(self):
+ # gh-3846
+ class MySubClass(np.ndarray):
+ def __new__(cls, input_array, info=None):
+ obj = np.asarray(input_array).view(cls)
+ obj.info = info
+ return obj
+
+ def mean(self, axis=None, dtype=None, out=None):
+ return -7
+
+ a = MySubClass([1,2,3])
+ assert_equal(np.median(a), -7)
+
def test_extended_axis(self):
o = np.random.normal(size=(71, 23))
x = np.dstack([o] * 10)