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

Method test_testAverage3

numpy/ma/tests/test_extras.py:258–280  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

256 [0., 1., 99., 99., 4.0, 10.0])
257
258 def test_testAverage3(self):
259 # Yet more tests of average!
260 a = arange(6)
261 b = arange(6) * 3
262 r1, w1 = average([[a, b], [b, a]], axis=1, returned=True)
263 assert_equal(shape(r1), shape(w1))
264 assert_equal(r1.shape, w1.shape)
265 r2, w2 = average(ones((2, 2, 3)), axis=0, weights=[3, 1], returned=True)
266 assert_equal(shape(w2), shape(r2))
267 r2, w2 = average(ones((2, 2, 3)), returned=True)
268 assert_equal(shape(w2), shape(r2))
269 r2, w2 = average(ones((2, 2, 3)), weights=ones((2, 2, 3)), returned=True)
270 assert_equal(shape(w2), shape(r2))
271 a2d = array([[1, 2], [0, 4]], float)
272 a2dm = masked_array(a2d, [[False, False], [True, False]])
273 a2da = average(a2d, axis=0)
274 assert_equal(a2da, [0.5, 3.0])
275 a2dma = average(a2dm, axis=0)
276 assert_equal(a2dma, [1.0, 3.0])
277 a2dma = average(a2dm, axis=None)
278 assert_equal(a2dma, 7. / 3.)
279 a2dma = average(a2dm, axis=1)
280 assert_equal(a2dma, [1.5, 4.0])
281
282 def test_testAverage4(self):
283 # Test that `keepdims` works with average

Callers

nothing calls this directly

Calls 5

averageFunction · 0.90
assert_equalFunction · 0.90
shapeFunction · 0.90
onesFunction · 0.90
arrayFunction · 0.90

Tested by

no test coverage detected