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

Function test_nanfunctions_matrices_general

numpy/matrixlib/tests/test_interaction.py:203–228  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

201
202
203def test_nanfunctions_matrices_general():
204 # Check that it works and that type and
205 # shape are preserved
206 # 2018-04-29: moved here from core.tests.test_nanfunctions
207 mat = np.matrix(np.eye(3))
208 for f in (np.nanargmin, np.nanargmax, np.nansum, np.nanprod,
209 np.nanmean, np.nanvar, np.nanstd):
210 res = f(mat, axis=0)
211 assert_(isinstance(res, np.matrix))
212 assert_(res.shape == (1, 3))
213 res = f(mat, axis=1)
214 assert_(isinstance(res, np.matrix))
215 assert_(res.shape == (3, 1))
216 res = f(mat)
217 assert_(np.isscalar(res))
218
219 for f in np.nancumsum, np.nancumprod:
220 res = f(mat, axis=0)
221 assert_(isinstance(res, np.matrix))
222 assert_(res.shape == (3, 3))
223 res = f(mat, axis=1)
224 assert_(isinstance(res, np.matrix))
225 assert_(res.shape == (3, 3))
226 res = f(mat)
227 assert_(isinstance(res, np.matrix))
228 assert_(res.shape == (1, 3*3))
229
230
231def test_average_matrix():

Callers

nothing calls this directly

Calls 2

assert_Function · 0.90
fFunction · 0.85

Tested by

no test coverage detected