From e6f0c9023d9a57a83d83684c2f63ad924038be69 Mon Sep 17 00:00:00 2001 From: Julian Taylor Date: Tue, 1 Oct 2013 20:02:03 +0200 Subject: BUG: preserve ndarray subclasses in median closes gh-3846 --- numpy/lib/tests/test_function_base.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'numpy/lib/tests/test_function_base.py') diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index dd0b6e0ee..8dd862d74 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -1621,6 +1621,19 @@ 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) class TestAdd_newdoc_ufunc(TestCase): -- cgit v1.2.1