示例#1
0
 def test_reverse_negative_nothing_there(self):
     r = normalize_slice(slice(-3, -1, -1), 10)
     # Would actually result in no index, but it is still valid.
     self.assertSlice(7, 9, -1, r)
示例#2
0
 def normalize_keys(keys, shape):
     result = []
     for key, dim_length in zip(keys, shape):
         result.append(
             key_grouper.normalize_slice(key, dim_length))
     return tuple(result)
示例#3
0
 def test_start_0(self):
     r = normalize_slice(slice(0, None), 10)
     self.assertSlice(None, None, None, r)
示例#4
0
 def test_reverse_negative(self):
     r = normalize_slice(slice(-1, -3, -1), 10)
     self.assertSlice(9, 7, -1, r)
示例#5
0
 def test_start_m1(self):
     r = normalize_slice(slice(-2, -1), 10)
     self.assertSlice(8, 9, None, r)
示例#6
0
 def test_stop_m1(self):
     r = normalize_slice(slice(None, -1), 10)
     self.assertSlice(None, 9, None, r)
示例#7
0
 def test_step_m1(self):
     r = normalize_slice(slice(None, None, None), None)
     self.assertSlice(None, None, None, r)
示例#8
0
 def test_step_1(self):
     r = normalize_slice(slice(None, None, 1), 3)
     self.assertSlice(None, None, None, r)
示例#9
0
 def normalize_keys(keys, shape):
     result = []
     for key, dim_length in zip(keys, shape):
         result.append(key_grouper.normalize_slice(key,
                                                   dim_length))
     return tuple(result)