MCPcopy Create free account
hub / github.com/numpy/numpy / test_0d_array

Method test_0d_array

numpy/lib/tests/test_shape_base.py:160–172  ·  view source on GitHub ↗
(self, cls=np.ndarray)

Source from the content-addressed store, hash-verified

158 assert_array_equal(res, np.array([6, 6, 6]).view(cls))
159
160 def test_0d_array(self, cls=np.ndarray):
161 def sum_to_0d(x):
162 """ Sum x, returning a 0d array of the same class """
163 assert_equal(x.ndim, 1)
164 return np.squeeze(np.sum(x, keepdims=True))
165 a = np.ones((6, 3)).view(cls)
166 res = apply_along_axis(sum_to_0d, 0, a)
167 assert_(isinstance(res, cls))
168 assert_array_equal(res, np.array([6, 6, 6]).view(cls))
169
170 res = apply_along_axis(sum_to_0d, 1, a)
171 assert_(isinstance(res, cls))
172 assert_array_equal(res, np.array([3, 3, 3, 3, 3, 3]).view(cls))
173
174 def test_axis_insertion(self, cls=np.ndarray):
175 def f1to2(x):

Callers 1

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