test_regression.py 927 B

12345678910111213141516171819202122232425262728293031
  1. import numpy as np
  2. from numpy.testing import assert_, assert_equal, assert_raises
  3. class TestRegression:
  4. def test_kron_matrix(self):
  5. # Ticket #71
  6. x = np.matrix('[1 0; 1 0]')
  7. assert_equal(type(np.kron(x, x)), type(x))
  8. def test_matrix_properties(self):
  9. # Ticket #125
  10. a = np.matrix([1.0], dtype=float)
  11. assert_(type(a.real) is np.matrix)
  12. assert_(type(a.imag) is np.matrix)
  13. c, d = np.matrix([0.0]).nonzero()
  14. assert_(type(c) is np.ndarray)
  15. assert_(type(d) is np.ndarray)
  16. def test_matrix_multiply_by_1d_vector(self):
  17. # Ticket #473
  18. def mul():
  19. np.mat(np.eye(2))*np.ones(2)
  20. assert_raises(ValueError, mul)
  21. def test_matrix_std_argmax(self):
  22. # Ticket #83
  23. x = np.asmatrix(np.random.uniform(0, 1, (3, 3)))
  24. assert_equal(x.std().shape, ())
  25. assert_equal(x.argmax().shape, ())