Skip to content

Commit

Permalink
turn sparsified matrix into sparse format
Browse files Browse the repository at this point in the history
  • Loading branch information
katosh committed Nov 26, 2024
1 parent 898c8fa commit b0f949e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/palantir/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,12 @@ def run_magic_imputation(

# Set small values to zero if returning sparse matrix
if sparse:
imputed_data[imputed_data < clip_threshold] = 0
if issparse(X):
imputed_data.data[imputed_data.data < clip_threshold] = 0
imputed_data.eliminate_zeros()
else:
imputed_data = np.where(imputed_data < clip_threshold, 0, imputed_data)
imputed_data = csr_matrix(imputed_data)

# Clean up
gc.collect()
Expand Down

0 comments on commit b0f949e

Please sign in to comment.