(ctx, x)
return ctx.isnpint(ctx.convert(x))
Determine if *x* is a nonpositive integer.
Determine if *x* is a nonpositive integer.
Determine if * x * is a nonpositive integer .
def isnpint(ctx, x):
        """
        Determine if *x* is a nonpositive integer.
        """
        if not x:
            return True
        if hasattr(x, '_mpf_'):
            sign, man, exp, bc = x._mpf_
            return sign and exp >= 0
        if hasattr(x, '_mpc_'):
            return not x.imag and ctx.isnpint(x.real)
        if type(x) in int_types:
            return x <= 0
        if isinstance(x, ctx.mpq):
            p, q = x._mpq_
            if not p:
                return True
            return q == 1 and p <= 0
        return ctx.isnpint(ctx.convert(x))
def isnpint ( ctx , x ) : if not x : return True if hasattr ( x , '_mpf_' ) : sign , man , exp , bc = x . _mpf_ return sign and exp >= 0 if hasattr ( x , '_mpc_' ) : return not x . imag and ctx . isnpint ( x . real ) if type ( x ) in int_types : return x <= 0 if isinstance ( x , ctx . mpq ) : p , q = x . _mpq_ if not p : return True return q == 1 and p <= 0 return ctx . isnpint ( ctx . convert ( x ) )