def test_all_sliced_ellipsis(self):
     keys = key_gen[:, :, :, ...]
     self.assertEqual(_sliced_shape([3, 2, 1], keys), (3, 2, 1))
 def test_invalid_object_indexing(self):
     keys = key_gen[np.nan]
     msg = 'Invalid indexing object "nan"'
     with six.assertRaisesRegex(self, ValueError, msg):
         _sliced_shape([4, 5, 6], keys)
 def test_invalid_object_indexing_float(self):
     # A float is a valid indexing object in numpy.
     keys = key_gen[1.2]
     msg = 'Invalid indexing object "1.2"'
     with six.assertRaisesRegex(self, ValueError, msg):
         _sliced_shape([4, 5, 6], keys)
 def assertSliceShape(self, shape, keys, expected, not_numpy=False):
     self.assertEqual(_sliced_shape(shape, keys), expected)
     if not not_numpy:
         np_actual = np.empty(shape)[keys].shape
         # Will only fail if numpy is not doing what the test anticipates.
         self.assertEqual(np_actual, expected)
Пример #5
0
 def test_all_sliced_ellipsis(self):
     keys = key_gen[:, :, :, ...]
     self.assertEqual(_sliced_shape([3, 2, 1], keys),
                      (3, 2, 1))
Пример #6
0
 def test_invalid_object_indexing_float(self):
     # A float is a valid indexing object in numpy.
     keys = key_gen[1.2]
     msg = 'Invalid indexing object "1.2"'
     with self.assertRaisesRegexp(ValueError, msg):
         _sliced_shape([4, 5, 6], keys)
Пример #7
0
 def test_invalid_object_indexing(self):
     keys = key_gen[np.nan]
     msg = 'Invalid indexing object "nan"'
     with self.assertRaisesRegexp(ValueError, msg):
         _sliced_shape([4, 5, 6], keys)
Пример #8
0
 def assertSliceShape(self, shape, keys, expected, not_numpy=False):
     self.assertEqual(_sliced_shape(shape, keys), expected)
     if not not_numpy:
         np_actual = np.empty(shape)[keys].shape
         # Will only fail if numpy is not doing what the test anticipates.
         self.assertEqual(np_actual, expected)