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

Method test_power

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

Source from the content-addressed store, hash-verified

4655 assert_equal(a, np.identity(5))
4656
4657 def test_power(self):
4658 x = -1.1
4659 assert_almost_equal(power(x, 2.), 1.21)
4660 assert_(power(x, masked) is masked)
4661 x = array([-1.1, -1.1, 1.1, 1.1, 0.])
4662 b = array([0.5, 2., 0.5, 2., -1.], mask=[0, 0, 0, 0, 1])
4663 y = power(x, b)
4664 assert_almost_equal(y, [0, 1.21, 1.04880884817, 1.21, 0.])
4665 assert_equal(y._mask, [1, 0, 0, 0, 1])
4666 b.mask = nomask
4667 y = power(x, b)
4668 assert_equal(y._mask, [1, 0, 0, 0, 1])
4669 z = x ** b
4670 assert_equal(z._mask, y._mask)
4671 assert_almost_equal(z, y)
4672 assert_almost_equal(z._data, y._data)
4673 x **= b
4674 assert_equal(x._mask, y._mask)
4675 assert_almost_equal(x, y)
4676 assert_almost_equal(x._data, y._data)
4677
4678 def test_power_with_broadcasting(self):
4679 # Test power w/ broadcasting

Callers

nothing calls this directly

Calls 5

assert_almost_equalFunction · 0.90
powerFunction · 0.90
arrayFunction · 0.90
assert_equalFunction · 0.90
assert_Function · 0.85

Tested by

no test coverage detected