def test_array_bigger_than_expected(self): # An array structure which has a length which is a product # of potential dimensions should not result in an array struct = ArrayStructure(2, [1, 2, 3, 4, 5, 6]) orig = np.array([1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) with self.assertRaises(_UnstructuredArrayException): struct.nd_array_and_dims(orig, (2, 3, 2), order=self.order)
def test_orig_array_and_target_shape_inconsistent(self): # An array structure which has a length which is a product # of potential dimensions should not result in an array struct = ArrayStructure(2, [1, 2, 3]) orig = np.array([1, 1, 2, 2, 3, 3]) msg = "Original array and target shape do not match up." with self.assertRaisesRegex(ValueError, msg): struct.nd_array_and_dims(orig, (2, 3, 2), order=self.order)
def test_orig_array_and_target_shape_inconsistent(self): # An array structure which has a length which is a product # of potential dimensions should not result in an array struct = ArrayStructure(2, [1, 2, 3]) orig = np.array([1, 1, 2, 2, 3, 3]) msg = 'Original array and target shape do not match up.' with self.assertRaisesRegexp(ValueError, msg): struct.nd_array_and_dims(orig, (2, 3, 2), order=self.order)
def test_scalar_non_len1_first_dim(self): struct = ArrayStructure(1, [1]) orig = np.array([1, 1, 1]) array, dims = struct.nd_array_and_dims(orig, (3, 1), order=self.order) self.assertArrayEqual(array, [1]) self.assertEqual(dims, ())