33
44from python_toolbox import math_tools
55
6- from python_toolbox .sequence_tools import parse_slice
6+ from python_toolbox .sequence_tools import CanonicalSlice
77
88
99infinity = float ('inf' )
@@ -23,17 +23,20 @@ def test():
2323 slice (None , None , - 2 )]
2424
2525 for slice_ in slices :
26- ( start , stop , step ) = parse_slice (slice_ )
26+ canonical_slice = CanonicalSlice (slice_ )
2727
2828 # Replacing `infinity` with huge number cause Python's lists can't
2929 # handle `infinity`:
30- if abs (start ) == infinity : start = 10 ** 10 * math_tools .get_sign (start )
31- if abs (stop ) == infinity : stop = 10 ** 10 * math_tools .get_sign (stop )
32- if abs (step ) == infinity : step = 10 ** 10 * math_tools .get_sign (step )
30+ if abs (canonical_slice .start ) == infinity :
31+ start = 10 ** 10 * math_tools .get_sign (canonical_slice .start )
32+ if abs (canonical_slice .stop ) == infinity :
33+ stop = 10 ** 10 * math_tools .get_sign (canonical_slice .stop )
34+ if abs (canonical_slice .step ) == infinity :
35+ step = 10 ** 10 * math_tools .get_sign (canonical_slice .step )
3336 #######################################################################
3437
35- assert [start , stop , step ].count (None ) == 0
38+ assert [canonical_slice .start , canonical_slice .stop ,
39+ canonical_slice .step ].count (None ) == 0
3640
37- parsed_slice = slice (start , stop , step )
3841 for range_ in ranges :
39- assert range_ [slice_ ] == range_ [parsed_slice ]
42+ assert range_ [slice_ ] == range_ [canonical_slice . slice_ ]
0 commit comments