#NEWLINE# def _process_sample_weight( self , interactions , sample_weight ) : #NEWLINE# #INDENT# if ( sample_weight is not None ) : #NEWLINE# #INDENT# if ( self . loss == 'warp-kos' ) : #NEWLINE# #INDENT# raise NotImplementedError ( 'k-OS loss with sample weights not implemented.' ) #NEWLINE# #UNINDENT# if ( not isinstance ( sample_weight , sp . coo_matrix ) ) : #NEWLINE# #INDENT# raise ValueError ( 'Sample_weight must be a COO matrix.' ) #NEWLINE# #UNINDENT# if ( sample_weight . shape != interactions . shape ) : #NEWLINE# #INDENT# raise ValueError ( 'Sample weight and interactions matrices must be the same shape' ) #NEWLINE# #UNINDENT# if ( not ( np . array_equal ( interactions . row , sample_weight . row ) and np . array_equal ( interactions . col , sample_weight . col ) ) ) : #NEWLINE# #INDENT# raise ValueError ( 'Sample weight and interaction matrix entries must be in the same order' ) #NEWLINE# #UNINDENT# if ( sample_weight . data . dtype != CYTHON_DTYPE ) : #NEWLINE# #INDENT# sample_weight_data = sample_weight . data . astype ( CYTHON_DTYPE ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# sample_weight_data = sample_weight . data #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if np . array_equiv ( interactions . data , 1.0 ) : #NEWLINE# #INDENT# sample_weight_data = sample_weight . data #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# sample_weight_data = np . ones_like ( interactions . data , dtype = CYTHON_DTYPE ) #NEWLINE# #UNINDENT# #UNINDENT# return sample_weight_data