#NEWLINE# def __eq__( self , other ) : #NEWLINE# #INDENT# if isscalarlike ( other ) : #NEWLINE# #INDENT# if np . isnan ( other ) : #NEWLINE# #INDENT# return self . __class__ ( self . shape , dtype = np . bool_ ) #NEWLINE# #UNINDENT# if ( other == 0 ) : #NEWLINE# #INDENT# warn ( 'Comparing a sparse matrix with 0 using == is inefficient, try using != instead.' , SparseEfficiencyWarning ) #NEWLINE# all_true = self . __class__ ( np . ones ( self . shape , dtype = np . bool_ ) ) #NEWLINE# inv = self . _scalar_binopt ( other , operator . ne ) #NEWLINE# return ( all_true - inv ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return self . _scalar_binopt ( other , operator . eq ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if isdense ( other ) : #NEWLINE# #INDENT# return ( self . todense ( ) == other ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isspmatrix ( other ) : #NEWLINE# #INDENT# warn ( 'Comparing sparse matrices using == is inefficient, try using != instead.' , SparseEfficiencyWarning ) #NEWLINE# if ( self . shape != other . shape ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . format != other . format ) : #NEWLINE# #INDENT# other = other . asformat ( self . format ) #NEWLINE# #UNINDENT# #UNINDENT# res = self . _binopt ( other , '_ne_' ) #NEWLINE# all_true = self . __class__ ( np . ones ( self . shape , dtype = np . bool_ ) ) #NEWLINE# return ( self - res ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return False