summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_function_base.py
diff options
context:
space:
mode:
authornjsmith <njs@pobox.com>2013-10-02 11:11:37 -0700
committernjsmith <njs@pobox.com>2013-10-02 11:11:37 -0700
commitf665c617065ba59b1c517b8dd44080c83dbfd5bd (patch)
treed0116d3adb263c80d1ccb11282c26dc7f663e87d /numpy/lib/tests/test_function_base.py
parentd2316262a7837dd68904645453c0eee01427a0fc (diff)
parente6f0c9023d9a57a83d83684c2f63ad924038be69 (diff)
downloadnumpy-f665c617065ba59b1c517b8dd44080c83dbfd5bd.tar.gz
Merge pull request #3851 from juliantaylor/median-subclass
BUG: preserve ndarray subclasses in median
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r--numpy/lib/tests/test_function_base.py13
1 files changed, 13 insertions, 0 deletions
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):