#NEWLINE# def to_numpy( m , **options ) : #NEWLINE# #INDENT# 'Convert a sympy/scipy.sparse matrix to a numpy matrix.' #NEWLINE# dtype = options . get ( 'dtype' , 'complex' ) #NEWLINE# if isinstance ( m , ( Matrix , Expr ) ) : #NEWLINE# #INDENT# return sympy_to_numpy ( m , dtype = dtype ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( m , numpy_ndarray ) : #NEWLINE# #INDENT# return m #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( m , scipy_sparse_matrix ) : #NEWLINE# #INDENT# return m . todense ( ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# raise TypeError ( ( 'Expected sympy/numpy/scipy.sparse matrix, got: %r' % options ) )