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

Method test_pow

numpy/matrixlib/tests/test_defmatrix.py:237–248  ·  view source on GitHub ↗

Test raising a matrix to an integer power works as expected.

(self)

Source from the content-addressed store, hash-verified

235 assert_(np.allclose(mA2.A, 3*A))
236
237 def test_pow(self):
238 """Test raising a matrix to an integer power works as expected."""
239 m = matrix("1. 2.; 3. 4.")
240 m2 = m.copy()
241 m2 **= 2
242 mi = m.copy()
243 mi **= -1
244 m4 = m2.copy()
245 m4 **= 2
246 assert_array_almost_equal(m2, m**2)
247 assert_array_almost_equal(m4, np.dot(m2, m2))
248 assert_array_almost_equal(np.dot(mi, m), np.eye(2))
249
250 def test_scalar_type_pow(self):
251 m = matrix([[1, 2], [3, 4]])

Callers

nothing calls this directly

Calls 4

matrixClass · 0.90
dotMethod · 0.80
copyMethod · 0.45

Tested by

no test coverage detected