def test_incompatible(self):
     # Does not enforce compatibility of results.
     a1 = np.array([1, 2])
     a2 = np.array([1, 2, 3])
     result = _reshape_vector_args([(a1, (0,)), (a2, (0,))])
     expected = [a1, a2]
     self._check(result, expected)
Exemple #2
0
 def test_incompatible(self):
     # Does not enforce compatibility of results.
     a1 = np.array([1, 2])
     a2 = np.array([1, 2, 3])
     result = _reshape_vector_args([(a1, (0, )), (a2, (0, ))])
     expected = [a1, a2]
     self._check(result, expected)
 def test_triple(self):
     a1 = np.array([[1, 2, 3, 4]])
     a2 = np.array([3, 4])
     a3 = np.array(7)
     result = _reshape_vector_args([(a1, (0, 2)), (a2, (1,)), (a3, ())])
     expected = [a1.reshape(1, 1, 4),
                 a2.reshape(1, 2, 1),
                 a3.reshape(1, 1, 1)]
     self._check(result, expected)
Exemple #4
0
 def test_triple(self):
     a1 = np.array([[1, 2, 3, 4]])
     a2 = np.array([3, 4])
     a3 = np.array(7)
     result = _reshape_vector_args([(a1, (0, 2)), (a2, (1, )), (a3, ())])
     expected = [
         a1.reshape(1, 1, 4),
         a2.reshape(1, 2, 1),
         a3.reshape(1, 1, 1)
     ]
     self._check(result, expected)
 def test(self):
     result = _reshape_vector_args([])
     self.assertEqual(result, [])
 def test_double_extend(self):
     a1 = np.array([[1, 2, 3], [4, 5, 6]])
     a2 = np.array(1)
     result = _reshape_vector_args([(a1, (0, 2)), (a2, ())])
     expected = [a1.reshape(2, 1, 3), a2.reshape(1, 1, 1)]
     self._check(result, expected)
 def test_nochange(self):
     a1 = np.array([[1, 2, 3], [4, 5, 6]])
     a2 = np.array([[0, 2, 4], [7, 8, 9]])
     result = _reshape_vector_args([(a1, (0, 1)), (a2, (0, 1))])
     expected = [a1, a2]
     self._check(result, expected)
 def test_scalar(self):
     points = 5
     result = _reshape_vector_args([(points, ())])
     expected = [points]
     self._check(result, expected)
 def test_transpose(self):
     points = np.array([[1, 2, 3], [4, 5, 6]])
     result = _reshape_vector_args([(points, (1, 0))])
     expected = [points.T]
     self._check(result, expected)
Exemple #10
0
 def test_transpose(self):
     points = np.array([[1, 2, 3], [4, 5, 6]])
     result = _reshape_vector_args([(points, (1, 0))])
     expected = [points.T]
     self._check(result, expected)
Exemple #11
0
 def test_extend(self):
     points = np.array([[1, 2, 3, 4], [21, 22, 23, 24], [31, 32, 33, 34]])
     result = _reshape_vector_args([(points, (1, 3))])
     expected = [points.reshape(1, 3, 1, 4)]
     self._check(result, expected)
Exemple #12
0
 def test_scalar(self):
     points = 5
     result = _reshape_vector_args([(points, ())])
     expected = [points]
     self._check(result, expected)
Exemple #13
0
 def test_nonarray(self):
     points = [[1, 2, 3], [4, 5, 6]]
     result = _reshape_vector_args([(points, (0, 1))])
     expected = [np.array(points)]
     self._check(result, expected)
Exemple #14
0
 def test_bad_dimensions(self):
     points = np.array([[1, 2, 3], [4, 5, 6]])
     with self.assertRaisesRegexp(ValueError, 'Length'):
         _reshape_vector_args([(points, (0, 1, 2))])
Exemple #15
0
 def test_nochange(self):
     points = np.array([[1, 2, 3], [4, 5, 6]])
     result = _reshape_vector_args([(points, (0, 1))])
     expected = [points]
     self._check(result, expected)
Exemple #16
0
 def test(self):
     result = _reshape_vector_args([])
     self.assertEqual(result, [])
 def test_nochange(self):
     points = np.array([[1, 2, 3], [4, 5, 6]])
     result = _reshape_vector_args([(points, (0, 1))])
     expected = [points]
     self._check(result, expected)
Exemple #18
0
 def test_nochange(self):
     a1 = np.array([[1, 2, 3], [4, 5, 6]])
     a2 = np.array([[0, 2, 4], [7, 8, 9]])
     result = _reshape_vector_args([(a1, (0, 1)), (a2, (0, 1))])
     expected = [a1, a2]
     self._check(result, expected)
 def test_bad_dimensions(self):
     points = np.array([[1, 2, 3], [4, 5, 6]])
     with self.assertRaisesRegexp(ValueError, 'Length'):
         _reshape_vector_args([(points, (0, 1, 2))])
Exemple #20
0
 def test_array_and_scalar(self):
     a1 = [[1, 2, 3], [3, 4, 5]]
     a2 = 5
     result = _reshape_vector_args([(a1, (0, 1)), (a2, ())])
     expected = [a1, np.array([[5]])]
     self._check(result, expected)
 def test_nonarray(self):
     points = [[1, 2, 3], [4, 5, 6]]
     result = _reshape_vector_args([(points, (0, 1))])
     expected = [np.array(points)]
     self._check(result, expected)
Exemple #22
0
 def test_extend_transpose(self):
     a1 = np.array([[1, 2, 3], [4, 5, 6]])
     a2 = np.array([11, 12, 13])
     result = _reshape_vector_args([(a1, (1, 0)), (a2, (1, ))])
     expected = [a1.T, a2.reshape(1, 3)]
     self._check(result, expected)
 def test_extend(self):
     points = np.array([[1, 2, 3, 4], [21, 22, 23, 24], [31, 32, 33, 34]])
     result = _reshape_vector_args([(points, (1, 3))])
     expected = [points.reshape(1, 3, 1, 4)]
     self._check(result, expected)
 def test_extend_transpose(self):
     a1 = np.array([[1, 2, 3], [4, 5, 6]])
     a2 = np.array([11, 12, 13])
     result = _reshape_vector_args([(a1, (1, 0)), (a2, (1,))])
     expected = [a1.T, a2.reshape(1, 3)]
     self._check(result, expected)
 def test_array_and_scalar(self):
     a1 = [[1, 2, 3], [3, 4, 5]]
     a2 = 5
     result = _reshape_vector_args([(a1, (0, 1)), (a2, ())])
     expected = [a1, np.array([[5]])]
     self._check(result, expected)
Exemple #26
0
 def test_double_extend(self):
     a1 = np.array([[1, 2, 3], [4, 5, 6]])
     a2 = np.array(1)
     result = _reshape_vector_args([(a1, (0, 2)), (a2, ())])
     expected = [a1.reshape(2, 1, 3), a2.reshape(1, 1, 1)]
     self._check(result, expected)