How to use the permuta.perm.Perm function in permuta

To help you get started, we’ve selected a few permuta examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PermutaTriangle / Permuta / permuta / _perm_set / unbounded / all / permset_all.py View on Github external
def __contains__(self, other):
        """Check if other is a permutation in the set."""
        return isinstance(other, Perm) and len(other) == self.length
github PermutaTriangle / Permuta / permuta / demo / perm.py View on Github external
def __init__(self, *args):
        try:
            if len(args) == 0:
                self._zb_perm = _ZBPerm()
            elif len(args) == 1:
                arg = args[0]
                if isinstance(arg, _ZBPerm):
                    self._zb_perm = arg
                elif isinstance(arg, Perm):
                    self._zb_perm = arg._zb_perm
                elif isinstance(arg, numbers.Integral):
                    self._zb_perm = _ZBPerm.to_standard(str(arg))
                else:
                    self._zb_perm = _ZBPerm.to_standard(arg)
            else:
                    self._zb_perm = _ZBPerm.to_standard(args)
        except Exception:
            format_string = "Don't know how to get a perm from args: {}"
            message = format_string.format(args)
            raise ValueError(message)
github PermutaTriangle / Permuta / permuta / _perm_set / unbounded / all / permset_all.py View on Github external
def __contains__(self, perm):
        return isinstance(perm, Perm)  # Why would you even ask?
github PermutaTriangle / Permuta / permuta / _perm_set / unbounded / all / permset_all.py View on Github external
def random(self):
        """Return a random perm of the length."""
        all_elements = self.domain
        random.shuffle(all_elements)
        return Perm(all_elements)
github PermutaTriangle / Permuta / permuta / _perm_set / finite / permset_static.py View on Github external
def __contains__(self, item):
        return isinstance(item, Perm) and item in self._set
github PermutaTriangle / Permuta / permuta / demo / perm.py View on Github external
def __repr__(self):
        if self._zb_perm == _ZBPerm((0,)):
            return "(1)"
        else:
            return str(tuple(self))
github PermutaTriangle / Permuta / permuta / demo / perm.py View on Github external
def random(cls, length):
        """Return a random perm of the specified length."""
        return cls(_ZBPerm.random(length))
github PermutaTriangle / Permuta / permuta / demo / perm.py View on Github external
def __init__(self, *args):
        try:
            if len(args) == 0:
                self._zb_perm = _ZBPerm()
            elif len(args) == 1:
                arg = args[0]
                if isinstance(arg, _ZBPerm):
                    self._zb_perm = arg
                elif isinstance(arg, Perm):
                    self._zb_perm = arg._zb_perm
                elif isinstance(arg, numbers.Integral):
                    self._zb_perm = _ZBPerm.to_standard(str(arg))
                else:
                    self._zb_perm = _ZBPerm.to_standard(arg)
            else:
                    self._zb_perm = _ZBPerm.to_standard(args)
        except Exception:
            format_string = "Don't know how to get a perm from args: {}"
            message = format_string.format(args)
            raise ValueError(message)