#NEWLINE# def _dense_transform( self , X , valid_stats , valid_idx ) : #NEWLINE# #INDENT# 'transformer on dense data.' #NEWLINE# mask = _get_mask ( X , self . missing_values ) #NEWLINE# n_missing = np . sum ( mask , axis = self . axis ) #NEWLINE# values = np . repeat ( valid_stats , n_missing ) #NEWLINE# if ( self . axis == 0 ) : #NEWLINE# #INDENT# coordinates = np . where ( mask . transpose ( ) ) [ : : ( - 1 ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# coordinates = mask #NEWLINE# #UNINDENT# X [ coordinates ] = values #NEWLINE# features_with_missing_values = np . where ( np . any ( mask , axis = 0 ) ) [ 0 ] #NEWLINE# imputed_mask = mask [ : , features_with_missing_values ] #NEWLINE# if ( self . axis == 0 ) : #NEWLINE# #INDENT# self . imputed_features_ = valid_idx [ features_with_missing_values ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . imputed_features_ = features_with_missing_values #NEWLINE# #UNINDENT# if self . add_indicator_features : #NEWLINE# #INDENT# X = np . hstack ( ( X , imputed_mask ) ) #NEWLINE# #UNINDENT# return X