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)
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)
def test_start_0(self): r = normalize_slice(slice(0, None), 10) self.assertSlice(None, None, None, r)
def test_reverse_negative(self): r = normalize_slice(slice(-1, -3, -1), 10) self.assertSlice(9, 7, -1, r)
def test_start_m1(self): r = normalize_slice(slice(-2, -1), 10) self.assertSlice(8, 9, None, r)
def test_stop_m1(self): r = normalize_slice(slice(None, -1), 10) self.assertSlice(None, 9, None, r)
def test_step_m1(self): r = normalize_slice(slice(None, None, None), None) self.assertSlice(None, None, None, r)
def test_step_1(self): r = normalize_slice(slice(None, None, 1), 3) self.assertSlice(None, None, None, r)
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)