#NEWLINE# def isnan( ctx , x ) : #NEWLINE# #INDENT# '\n        Return *True* if *x* is a NaN (not-a-number), or for a complex\n        number, whether either the real or complex part is NaN;\n        otherwise return *False*::\n\n            >>> from mpmath import *\n            >>> isnan(3.14)\n            False\n            >>> isnan(nan)\n            True\n            >>> isnan(mpc(3.14,2.72))\n            False\n            >>> isnan(mpc(3.14,nan))\n            True\n\n        ' #NEWLINE# if hasattr ( x , '_mpf_' ) : #NEWLINE# #INDENT# return ( x . _mpf_ == fnan ) #NEWLINE# #UNINDENT# if hasattr ( x , '_mpc_' ) : #NEWLINE# #INDENT# return ( fnan in x . _mpc_ ) #NEWLINE# #UNINDENT# if ( isinstance ( x , int_types ) or isinstance ( x , rational . mpq ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# x = ctx . convert ( x ) #NEWLINE# if ( hasattr ( x , '_mpf_' ) or hasattr ( x , '_mpc_' ) ) : #NEWLINE# #INDENT# return ctx . isnan ( x ) #NEWLINE# #UNINDENT# raise TypeError ( 'isnan() needs a number as input' )