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