def _sympy_to_scalar(e):
 if isinstance(e, Expr):
  if e.is_Integer:
   return int(e)
  elif e.is_Float:
   return float(e)
  elif e.is_Rational:
   return float(e)
  elif (e.is_Number or e.is_NumberSymbol or (e == I)):
   return complex(e)
 raise TypeError(('Expected number, got: %r' % e))

def _sympy_to_scalar ( e ) : if isinstance ( e , Expr ) : if e . is_Integer : return int ( e ) elif e . is_Float : return float ( e ) elif e . is_Rational : return float ( e ) elif ( e . is_Number or e . is_NumberSymbol or ( e == I ) ) : return complex ( e ) raise TypeError ( ( 'Expected number, got: %r' % e ) )
convert from a sympy scalar to a python scalar .