(self)
Returns the order of the expression.

        The order is determined either from the O(...) term. If there
        is no O(...) term, it returns None.

        Examples
        ========

        >>> from sympy import O
        >>> from sympy.abc import x
        >>> (1 + x + O(x**2)).getn()
        2
        >>> (1 + x).getn()
Returns the order of the expression.
Returns the order of the expression .
def getn(self):
        """
        Returns the order of the expression.

        The order is determined either from the O(...) term. If there
        is no O(...) term, it returns None.

        Examples
        ========

        >>> from sympy import O
        >>> from sympy.abc import x
        >>> (1 + x + O(x**2)).getn()
        2
        >>> (1 + x).getn()

        """
        o = self.getO()
        if o is None:
            return None
        elif o.is_Order:
            o = o.expr
            if o is S.One:
                return S.Zero
            if o.is_Symbol:
                return S.One
            if o.is_Pow:
                return o.args[1]
            if o.is_Mul:  # x**n*log(x)**n or x**n/log(x)**n
                for oi in o.args:
                    if oi.is_Symbol:
                        return S.One
                    if oi.is_Pow:
                        syms = oi.atoms(C.Symbol)
                        if len(syms) == 1:
                            x = syms.pop()
                            oi = oi.subs(x, C.Dummy('x', positive=True))
                            if oi.base.is_Symbol and oi.exp.is_Rational:
                                return abs(oi.exp)

        raise NotImplementedError('not sure of order of %s' % o)
def getn ( self ) : o = self . getO ( ) if o is None : return None elif o . is_Order : o = o . expr if o is S . One : return S . Zero if o . is_Symbol : return S . One if o . is_Pow : return o . args [ 1 ] if o . is_Mul : # x**n*log(x)**n or x**n/log(x)**n for oi in o . args : if oi . is_Symbol : return S . One if oi . is_Pow : syms = oi . atoms ( C . Symbol ) if len ( syms ) == 1 : x = syms . pop ( ) oi = oi . subs ( x , C . Dummy ( 'x' , positive = True ) ) if oi . base . is_Symbol and oi . exp . is_Rational : return abs ( oi . exp ) raise NotImplementedError ( 'not sure of order of %s' % o )