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

Method test_methods_with_output

numpy/ma/tests/test_core.py:1669–1689  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1667 assert_equal(xx.real.dtype, xx._data.real.dtype)
1668
1669 def test_methods_with_output(self):
1670 xm = array(np.random.uniform(0, 10, 12)).reshape(3, 4)
1671 xm[:, 0] = xm[0] = xm[-1, -1] = masked
1672
1673 funclist = ('sum', 'prod', 'var', 'std', 'max', 'min', 'ptp', 'mean',)
1674
1675 for funcname in funclist:
1676 npfunc = getattr(np, funcname)
1677 xmmeth = getattr(xm, funcname)
1678 # A ndarray as explicit input
1679 output = np.empty(4, dtype=float)
1680 output.fill(-9999)
1681 result = npfunc(xm, axis=0, out=output)
1682 # ... the result should be the given output
1683 assert_(result is output)
1684 assert_equal(result, xmmeth(axis=0, out=output))
1685
1686 output = empty(4, dtype=int)
1687 result = xmmeth(axis=0, out=output)
1688 assert_(result is output)
1689 assert_(output[0] is masked)
1690
1691 def test_eq_on_structured(self):
1692 # Test the equality of structured arrays

Callers

nothing calls this directly

Calls 6

arrayFunction · 0.90
assert_equalFunction · 0.90
assert_Function · 0.85
emptyFunction · 0.85
reshapeMethod · 0.80
uniformMethod · 0.80

Tested by

no test coverage detected