MCPcopy Index your code
hub / github.com/numpy/numpy / test_preserve_subclass

Method test_preserve_subclass

numpy/lib/tests/test_shape_base.py:152–168  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

150 [[27, 30, 33], [36, 39, 42], [45, 48, 51]])
151
152 def test_preserve_subclass(self):
153 def double(row):
154 return row * 2
155
156 class MyNDArray(np.ndarray):
157 pass
158
159 m = np.array([[0, 1], [2, 3]]).view(MyNDArray)
160 expected = np.array([[0, 2], [4, 6]]).view(MyNDArray)
161
162 result = apply_along_axis(double, 0, m)
163 assert_(isinstance(result, MyNDArray))
164 assert_array_equal(result, expected)
165
166 result = apply_along_axis(double, 1, m)
167 assert_(isinstance(result, MyNDArray))
168 assert_array_equal(result, expected)
169
170 def test_subclass(self):
171 class MinimalSubclass(np.ndarray):

Callers

nothing calls this directly

Calls 4

apply_along_axisFunction · 0.90
assert_Function · 0.90
assert_array_equalFunction · 0.90
viewMethod · 0.45

Tested by

no test coverage detected