(m, **options)
Convert a sympy Matrix/complex number to a numpy matrix or scalar.
Convert a sympy Matrix/complex number to a numpy matrix or scalar.
Convert a sympy Matrix / complex number to a numpy matrix or scalar .
def sympy_to_numpy(m, **options):
    """Convert a sympy Matrix/complex number to a numpy matrix or scalar."""
    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 )