Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def shift_down(self, times=1):
"""Return the perm shifted times steps down."""
return Perm(self._zb_perm.shift_down(times))
def occurrences_in(self, perm):
"""Find all occurrences of the patt self in perm.
See also:
Perm.avoids
Perm.contains
Perm.occurrence*
"""
perm = Perm(perm)
return list(list(perm[index + 1] for index in occurrence_indices)
for occurrence_indices
in self._zb_perm.occurrences_in(perm._zb_perm))
def reverse_complement(self):
"""Return the reverse complement of the perm."""
return Perm(self._zb_perm.reverse_complement())
def shift_up(self, times=1):
"""Return the perm shifted times steps up."""
return Perm(self._zb_perm.shift_up(times))
def occurrences_of(self, patt):
"""Find all occurrences of patt in the perm self.
See also:
Perm.avoids
Perm.contains
Perm.occurrence*
"""
patt = Perm(patt)
return patt.occurrences_in(self)
def direct_sum(self, perm):
"""Return the direct sum of the two perms.
See also:
Perm.__sum__
"""
perm = Perm(perm)
zb_perm = self._zb_perm.direct_sum(perm._zb_perm)
return Perm(zb_perm)
def _assert_perm(perm):
"""Helper function for this module."""
# TODO: Do we want to use this function anyway?
if not isinstance(perm, Perm):
raise TypeError("Not a perm: {}".format(perm))
else:
return True
def __imul__(self, perm):
return self*Perm(perm)
def skew_sum(self, perm):
"""Return the skew sum of the two perms.
See also:
Perm.__sub__
"""
perm = Perm(perm)
zb_perm = self._zb_perm.skew_sum(perm._zb_perm)
return Perm(zb_perm)
def compose(self, perm):
"""Return the composition of the two perms.
See also:
Perm.multiply
Perm.__mul__
"""
perm = Perm(perm)
zb_perm = self._zb_perm.compose(perm._zb_perm)
return Perm(zb_perm)