def sympy_to_numpy(m, **options):
 if (not np):
  raise ImportError
 dtype = options.get('dtype', 'complex')
 if isinstance(m, Matrix):
  return np.matrix(m.tolist(), dtype=dtype)
 elif isinstance(m, Expr):
  if (m.is_Number or m.is_NumberSymbol or (m == I)):
   return complex(m)
 raise TypeError(('Expected Matrix or complex scalar, got: %r' % m))

def sympy_to_numpy ( m , ** options ) : if ( not np ) : raise ImportError dtype = options . get ( 'dtype' , 'complex' ) if isinstance ( m , Matrix ) : return np . matrix ( m . tolist ( ) , dtype = dtype ) elif isinstance ( m , Expr ) : if ( m . is_Number or m . is_NumberSymbol or ( m == I ) ) : return complex ( m ) raise TypeError ( ( 'Expected Matrix or complex scalar, got: %r' % m ) )
convert a sympy matrix/complex number to a numpy matrix or scalar .