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

Method test_testAverage1

numpy/ma/tests/test_old_ma.py:566–583  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

564 assert_equal(filled(xx[1], 0), 0)
565
566 def test_testAverage1(self):
567 # Test of average.
568 ott = array([0., 1., 2., 3.], mask=[1, 0, 0, 0])
569 assert_(eq(2.0, average(ott, axis=0)))
570 assert_(eq(2.0, average(ott, weights=[1., 1., 2., 1.])))
571 result, wts = average(ott, weights=[1., 1., 2., 1.], returned=True)
572 assert_(eq(2.0, result))
573 assert_(wts == 4.0)
574 ott[:] = masked
575 assert_(average(ott, axis=0) is masked)
576 ott = array([0., 1., 2., 3.], mask=[1, 0, 0, 0])
577 ott = ott.reshape(2, 2)
578 ott[:, 1] = masked
579 assert_(eq(average(ott, axis=0), [2.0, 0.0]))
580 assert_(average(ott, axis=1)[0] is masked)
581 assert_(eq([2., 0.], average(ott, axis=0)))
582 result, wts = average(ott, axis=0, returned=True)
583 assert_(eq(wts, [1., 0.]))
584
585 def test_testAverage2(self):
586 # More tests of average.

Callers

nothing calls this directly

Calls 5

arrayFunction · 0.90
assert_Function · 0.90
averageFunction · 0.90
eqFunction · 0.85
reshapeMethod · 0.80

Tested by

no test coverage detected