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

Method test_testAverage1

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

Source from the content-addressed store, hash-verified

626 assert_equal(filled(xx[1], 0), 0)
627
628 def test_testAverage1(self):
629 # Test of average.
630 ott = array([0., 1., 2., 3.], mask=[1, 0, 0, 0])
631 assert_(eq(2.0, average(ott, axis=0)))
632 assert_(eq(2.0, average(ott, weights=[1., 1., 2., 1.])))
633 result, wts = average(ott, weights=[1., 1., 2., 1.], returned=True)
634 assert_(eq(2.0, result))
635 assert_(wts == 4.0)
636 ott[:] = masked
637 assert_(average(ott, axis=0) is masked)
638 ott = array([0., 1., 2., 3.], mask=[1, 0, 0, 0])
639 ott = ott.reshape(2, 2)
640 ott[:, 1] = masked
641 assert_(eq(average(ott, axis=0), [2.0, 0.0]))
642 assert_(average(ott, axis=1)[0] is masked)
643 assert_(eq([2., 0.], average(ott, axis=0)))
644 result, wts = average(ott, axis=0, returned=True)
645 assert_(eq(wts, [1., 0.]))
646
647 def test_testAverage2(self):
648 # 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