Example #1
0
File: str.py Project: mianzg/sympy
 def _print_Permutation(self, expr):
     from sympy.combinatorics.permutations import Permutation, Cycle
     if Permutation.print_cyclic:
         if not expr.size:
             return '()'
         # before taking Cycle notation, see if the last element is
         # a singleton and move it to the head of the string
         s = Cycle(expr)(expr.size - 1).__repr__()[len('Cycle'):]
         last = s.rfind('(')
         if not last == 0 and ',' not in s[last:]:
             s = s[last:] + s[:last]
         s = s.replace(',', '')
         return s
     else:
         s = expr.support()
         if not s:
             if expr.size < 5:
                 return 'Permutation(%s)' % self._print(expr.array_form)
             return 'Permutation([], size=%s)' % self._print(expr.size)
         trim = self._print(
             expr.array_form[:s[-1] +
                             1]) + ', size=%s' % self._print(expr.size)
         use = full = self._print(expr.array_form)
         if len(trim) < len(full):
             use = trim
         return 'Permutation(%s)' % use
Example #2
0
File: str.py Project: MooVI/sympy
    def _print_Permutation(self, expr):
        from sympy.combinatorics.permutations import Permutation, Cycle

        if Permutation.print_cyclic:
            if not expr.size:
                return "()"
            # before taking Cycle notation, see if the last element is
            # a singleton and move it to the head of the string
            s = Cycle(expr)(expr.size - 1).__repr__()[len("Cycle") :]
            last = s.rfind("(")
            if not last == 0 and "," not in s[last:]:
                s = s[last:] + s[:last]
            s = s.replace(",", "")
            return s
        else:
            s = expr.support()
            if not s:
                if expr.size < 5:
                    return "Permutation(%s)" % str(expr.array_form)
                return "Permutation([], size=%s)" % expr.size
            trim = str(expr.array_form[: s[-1] + 1]) + ", size=%s" % expr.size
            use = full = str(expr.array_form)
            if len(trim) < len(full):
                use = trim
            return "Permutation(%s)" % use
Example #3
0
    def _print_Permutation(self, expr):
        from sympy.combinatorics.permutations import Permutation, Cycle
        from sympy.utilities.exceptions import sympy_deprecation_warning

        perm_cyclic = Permutation.print_cyclic
        if perm_cyclic is not None:
            sympy_deprecation_warning(
                f"""
                Setting Permutation.print_cyclic is deprecated. Instead use
                init_printing(perm_cyclic={perm_cyclic}).
                """,
                deprecated_since_version="1.6",
                active_deprecations_target=
                "deprecated-permutation-print_cyclic",
                stacklevel=7,
            )
        else:
            perm_cyclic = self._settings.get("perm_cyclic", True)

        if perm_cyclic:
            if not expr.size:
                return '()'
            # before taking Cycle notation, see if the last element is
            # a singleton and move it to the head of the string
            s = Cycle(expr)(expr.size - 1).__repr__()[len('Cycle'):]
            last = s.rfind('(')
            if not last == 0 and ',' not in s[last:]:
                s = s[last:] + s[:last]
            s = s.replace(',', '')
            return s
        else:
            s = expr.support()
            if not s:
                if expr.size < 5:
                    return 'Permutation(%s)' % self._print(expr.array_form)
                return 'Permutation([], size=%s)' % self._print(expr.size)
            trim = self._print(
                expr.array_form[:s[-1] +
                                1]) + ', size=%s' % self._print(expr.size)
            use = full = self._print(expr.array_form)
            if len(trim) < len(full):
                use = trim
            return 'Permutation(%s)' % use
Example #4
0
    def _print_Permutation(self, expr):
        print("Warning: _print_Permutation was called")
        from sympy.combinatorics.permutations import Permutation, Cycle
        from sympy.utilities.exceptions import SymPyDeprecationWarning

        perm_cyclic = Permutation.print_cyclic
        if perm_cyclic is not None:
            SymPyDeprecationWarning(
                feature="Permutation.print_cyclic = {}".format(perm_cyclic),
                useinstead="init_printing(perm_cyclic={})".format(perm_cyclic),
                issue=15201,
                deprecated_since_version="1.6").warn()
        else:
            perm_cyclic = self._settings.get("perm_cyclic", True)

        if perm_cyclic:
            if not expr.size:
                return '()'
            # before taking Cycle notation, see if the last element is
            # a singleton and move it to the head of the string
            s = Cycle(expr)(expr.size - 1).__repr__()[len('Cycle'):]
            last = s.rfind('(')
            if not last == 0 and ',' not in s[last:]:
                s = s[last:] + s[:last]
            s = s.replace(',', '')
            return s
        else:
            s = expr.support()
            if not s:
                if expr.size < 5:
                    return 'Permutation(%s)' % self._print(expr.array_form)
                return 'Permutation([], size=%s)' % self._print(expr.size)
            trim = self._print(
                expr.array_form[:s[-1] +
                                1]) + ', size=%s' % self._print(expr.size)
            use = full = self._print(expr.array_form)
            if len(trim) < len(full):
                use = trim
            return 'Permutation(%s)' % use
Example #5
0
File: str.py Project: Lenqth/sympy
 def _print_Permutation(self, expr):
     from sympy.combinatorics.permutations import Permutation, Cycle
     if Permutation.print_cyclic:
         if not expr.size:
             return '()'
         # before taking Cycle notation, see if the last element is
         # a singleton and move it to the head of the string
         s = Cycle(expr)(expr.size - 1).__repr__()[len('Cycle'):]
         last = s.rfind('(')
         if not last == 0 and ',' not in s[last:]:
             s = s[last:] + s[:last]
         s = s.replace(',', '')
         return s
     else:
         s = expr.support()
         if not s:
             if expr.size < 5:
                 return 'Permutation(%s)' % self._print(expr.array_form)
             return 'Permutation([], size=%s)' % self._print(expr.size)
         trim = self._print(expr.array_form[:s[-1] + 1]) + ', size=%s' % self._print(expr.size)
         use = full = self._print(expr.array_form)
         if len(trim) < len(full):
             use = trim
         return 'Permutation(%s)' % use