test_numeric.py 441 B

1234567891011121314151617
  1. import numpy as np
  2. from numpy.testing import assert_equal
  3. class TestDot:
  4. def test_matscalar(self):
  5. b1 = np.matrix(np.ones((3, 3), dtype=complex))
  6. assert_equal(b1*1.0, b1)
  7. def test_diagonal():
  8. b1 = np.matrix([[1,2],[3,4]])
  9. diag_b1 = np.matrix([[1, 4]])
  10. array_b1 = np.array([1, 4])
  11. assert_equal(b1.diagonal(), diag_b1)
  12. assert_equal(np.diagonal(b1), array_b1)
  13. assert_equal(np.diag(b1), array_b1)