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

Method test_power

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

Source from the content-addressed store, hash-verified

4428 assert_equal(a, np.identity(5))
4429
4430 def test_power(self):
4431 x = -1.1
4432 assert_almost_equal(power(x, 2.), 1.21)
4433 assert_(power(x, masked) is masked)
4434 x = array([-1.1, -1.1, 1.1, 1.1, 0.])
4435 b = array([0.5, 2., 0.5, 2., -1.], mask=[0, 0, 0, 0, 1])
4436 y = power(x, b)
4437 assert_almost_equal(y, [0, 1.21, 1.04880884817, 1.21, 0.])
4438 assert_equal(y._mask, [1, 0, 0, 0, 1])
4439 b.mask = nomask
4440 y = power(x, b)
4441 assert_equal(y._mask, [1, 0, 0, 0, 1])
4442 z = x ** b
4443 assert_equal(z._mask, y._mask)
4444 assert_almost_equal(z, y)
4445 assert_almost_equal(z._data, y._data)
4446 x **= b
4447 assert_equal(x._mask, y._mask)
4448 assert_almost_equal(x, y)
4449 assert_almost_equal(x._data, y._data)
4450
4451 def test_power_with_broadcasting(self):
4452 # 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.50

Tested by

no test coverage detected