1616infinity = float ('inf' )
1717
1818
19- class UnorderedIterableException (Exception ):
20- '''
21- An unordered iterable was encountered when we expected an orderable one.
22- '''
23-
24-
2519def are_equal_regardless_of_order (seq1 , seq2 ):
2620 '''
2721 Do `seq1` and `seq2` contain the same elements, same number of times?
@@ -231,8 +225,7 @@ def get_recurrences(sequence):
231225
232226
233227def ensure_iterable_is_immutable_sequence (iterable , default_type = tuple ,
234- unallowed_types = (bytes ,),
235- allow_unordered = True ):
228+ unallowed_types = (bytes ,)):
236229 '''
237230 Return a version of `iterable` that is an immutable sequence.
238231
@@ -242,9 +235,6 @@ def ensure_iterable_is_immutable_sequence(iterable, default_type=tuple,
242235 '''
243236 from python_toolbox import nifty_collections
244237 assert isinstance (iterable , collections .abc .Iterable )
245- if not allow_unordered and \
246- isinstance (iterable , nifty_collections .DefinitelyUnordered ):
247- raise UnorderedIterableException
248238 if isinstance (iterable , collections .abc .MutableSequence ) or \
249239 isinstance (iterable , unallowed_types ) or \
250240 not isinstance (iterable , collections .abc .Sequence ):
@@ -254,8 +244,7 @@ def ensure_iterable_is_immutable_sequence(iterable, default_type=tuple,
254244
255245
256246def ensure_iterable_is_sequence (iterable , default_type = tuple ,
257- unallowed_types = (bytes ,),
258- allow_unordered = True ):
247+ unallowed_types = (bytes ,)):
259248 '''
260249 Return a version of `iterable` that is a sequence.
261250
@@ -264,8 +253,6 @@ def ensure_iterable_is_sequence(iterable, default_type=tuple,
264253 `default_type`.
265254 '''
266255 assert isinstance (iterable , collections .abc .Iterable )
267- if not allow_unordered and isinstance (iterable , (set , frozenset )):
268- raise UnorderedIterableException
269256 if isinstance (iterable , collections .abc .Sequence ) and \
270257 not isinstance (iterable , unallowed_types ):
271258 return iterable
@@ -336,10 +323,8 @@ def is_subsequence(big_sequence, small_sequence):
336323 strings.
337324 '''
338325 from python_toolbox import nifty_collections
339- big_sequence = ensure_iterable_is_sequence (big_sequence ,
340- allow_unordered = False )
341- small_sequence = ensure_iterable_is_sequence (small_sequence ,
342- allow_unordered = False )
326+ big_sequence = ensure_iterable_is_sequence (big_sequence )
327+ small_sequence = ensure_iterable_is_sequence (small_sequence )
343328 small_sequence_length = len (small_sequence )
344329 last_index_that_subsequence_can_start = \
345330 len (big_sequence ) - len (small_sequence ) + 1
0 commit comments