(cls, order)
return key, reverse
Parse and configure the ordering of terms.
Parse and configure the ordering of terms.
Parse and configure the ordering of terms .
def _parse_order(cls, order):
        """Parse and configure the ordering of terms. """
        from sympy.polys.orderings import monomial_key

        try:
            reverse = order.startswith('rev-')
        except AttributeError:
            reverse = False
        else:
            if reverse:
                order = order[4:]

        monom_key = monomial_key(order)

        def neg(monom):
            result = []

            for m in monom:
                if isinstance(m, tuple):
                    result.append(neg(m))
                else:
                    result.append(-m)

            return tuple(result)

        def key(term):
            _, ((re, im), monom, ncpart) = term

            monom = neg(monom_key(monom))
            ncpart = tuple([ e.sort_key(order=order) for e in ncpart ])
            coeff = ((bool(im), im), (re, im))

            return monom, ncpart, coeff

        return key, reverse
def _parse_order ( cls , order ) : from sympy . polys . orderings import monomial_key try : reverse = order . startswith ( 'rev-' ) except AttributeError : reverse = False else : if reverse : order = order [ 4 : ] monom_key = monomial_key ( order ) def neg ( monom ) : result = [ ] for m in monom : if isinstance ( m , tuple ) : result . append ( neg ( m ) ) else : result . append ( - m ) return tuple ( result ) def key ( term ) : _ , ( ( re , im ) , monom , ncpart ) = term monom = neg ( monom_key ( monom ) ) ncpart = tuple ( [ e . sort_key ( order = order ) for e in ncpart ] ) coeff = ( ( bool ( im ) , im ) , ( re , im ) ) return monom , ncpart , coeff return key , reverse