def make_iterator(): crap = set() for item in map(self.perm_type, self._iter()): fc = nifty_collections.FrozenBag(item) if fc in crap: continue else: yield item crap.add(fc)
def __init__(self, iterable_or_length, domain=None, n_elements=None, fixed_map={}, degrees=None, is_combination=False, slice_=None, perm_type=None): self.sequence = tuple(iterable_or_length) if \ isinstance(iterable_or_length, collections.Iterable) else \ sequence_tools.CuteRange(iterable_or_length) self.sequence_length = len(self.sequence) self._sequence_frozen_bag = \ nifty_collections.FrozenBag(self.sequence) self.is_recurrent = len(set(self.sequence)) < len(self.sequence) self.n_elements = n_elements if n_elements is not None else \ len(self.sequence) self.domain = (domain or sequence_tools.CuteRange( self.sequence_length))[:self.n_elements] self.fixed_map = { key: value for key, value in fixed_map.items() if key in self.domain } self.degrees = \ degrees or sequence_tools.CuteRange(self.sequence_length) self.is_combination = is_combination self.is_degreed = (self.degrees != sequence_tools.CuteRange( self.sequence_length)) self.slice_ = slice_ if perm_type is None: self.perm_type = tuple self.is_typed = False else: self.perm_type = FruityTuple self.is_typed = True