def _count_nans_per_row_sparse(X, weights):
 items_per_row = (1 if (X.ndim == 1) else X.shape[1])
 counts = (np.ones(X.shape[0]) * items_per_row)
 nnz_per_row = np.bincount(X.indices, minlength=len(counts))
 counts -= nnz_per_row
 if (weights is not None):
  counts *= weights
 return np.sum(counts)

def _count_nans_per_row_sparse ( X , weights ) : items_per_row = ( 1 if ( X . ndim == 1 ) else X . shape [ 1 ] ) counts = ( np . ones ( X . shape [ 0 ] ) * items_per_row ) nnz_per_row = np . bincount ( X . indices , minlength = len ( counts ) ) counts -= nnz_per_row if ( weights is not None ) : counts *= weights return np . sum ( counts )
count the number of nans values per row .