test_regression.py 1001 B

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