(m, **options)
Convert a sympy/numpy matrix to a scipy.sparse matrix.
Convert a sympy/numpy matrix to a scipy.sparse matrix.
Convert a sympy / numpy matrix to a scipy . sparse matrix .
def to_scipy_sparse(m, **options):
    """Convert a sympy/numpy matrix to a scipy.sparse matrix."""
    dtype = options.get('dtype', 'complex')
    if isinstance(m, (Matrix, Expr)):
        return sympy_to_scipy_sparse(m, dtype=dtype)
    elif isinstance(m, numpy_ndarray):
        if not sparse:
            raise ImportError
        return sparse.csr_matrix(m)
    elif isinstance(m, scipy_sparse_matrix):
        return m
    raise TypeError('Expected sympy/numpy/scipy.sparse matrix, got: %r' % m)
def to_scipy_sparse ( m , * * options ) : dtype = options . get ( 'dtype' , 'complex' ) if isinstance ( m , ( Matrix , Expr ) ) : return sympy_to_scipy_sparse ( m , dtype = dtype ) elif isinstance ( m , numpy_ndarray ) : if not sparse : raise ImportError return sparse . csr_matrix ( m ) elif isinstance ( m , scipy_sparse_matrix ) : return m raise TypeError ( 'Expected sympy/numpy/scipy.sparse matrix, got: %r' % m )