Skip to content

Commit 266ea6a

Browse files
committed
-
1 parent 3e751ff commit 266ea6a

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

source_py2/python_toolbox/sequence_tools/cute_range.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,13 @@ def __getitem__(self, i, allow_out_of_range=False):
197197
canonical_slice = sequence_tools.CanonicalSlice(
198198
i, iterable_or_length=self
199199
)
200-
if not ((0 <= canonical_slice.start < self.length) and
200+
if not ((0 <= canonical_slice.start <= self.length) and
201201
((0 <= canonical_slice.stop <= self.length) or
202202
(canonical_slice.stop == self.length == infinity))):
203203
raise TypeError
204204
return CuteRange(
205-
self[canonical_slice.start],
205+
self.__getitem__(canonical_slice.start,
206+
allow_out_of_range=True),
206207
self.__getitem__(canonical_slice.stop,
207208
allow_out_of_range=True),
208209
self.step * canonical_slice.step

source_py2/test_python_toolbox/test_combi/test_comb_space.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# This program is distributed under the MIT license.
33

44
from python_toolbox import cute_testing
5+
from python_toolbox import sequence_tools
56

67
from python_toolbox.combi import *
78

@@ -41,7 +42,8 @@ def test():
4142
comb_space.get_degreed(3)
4243
assert comb_space.unfixed == comb_space
4344
assert not comb_space.fixed_indices
44-
assert comb_space.free_indices == comb_space.free_keys == range(2)
45+
assert comb_space.free_indices == comb_space.free_keys == \
46+
sequence_tools.CuteRange(2, _avoid_built_in_range=True)
4547
assert comb_space.free_values == 'dumber'
4648

4749
comb = comb_space[7]

source_py3/python_toolbox/sequence_tools/cute_range.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,13 @@ def __getitem__(self, i, allow_out_of_range=False):
191191
canonical_slice = sequence_tools.CanonicalSlice(
192192
i, iterable_or_length=self
193193
)
194-
if not ((0 <= canonical_slice.start < self.length) and
194+
if not ((0 <= canonical_slice.start <= self.length) and
195195
((0 <= canonical_slice.stop <= self.length) or
196196
(canonical_slice.stop == self.length == infinity))):
197197
raise TypeError
198198
return CuteRange(
199-
self[canonical_slice.start],
199+
self.__getitem__(canonical_slice.start,
200+
allow_out_of_range=True),
200201
self.__getitem__(canonical_slice.stop,
201202
allow_out_of_range=True),
202203
self.step * canonical_slice.step

0 commit comments

Comments
 (0)