Skip to content

Commit 6faefb5

Browse files
always sort
1 parent 937ec5b commit 6faefb5

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/netmap/downstream/edge_selection.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import numpy as np
66
from scipy.sparse import issparse
77

8-
def chunked_argsort(adata, layer_name='sorted', chunk_size=500, dtype=None):
8+
def chunked_argsort(unsadata, layer_name='sorted', chunk_size=500, dtype=None):
99
"""
1010
Computes np.argsort on adata.X in chunks to save memory.
1111
@@ -21,7 +21,7 @@ def chunked_argsort(adata, layer_name='sorted', chunk_size=500, dtype=None):
2121
The integer type for the output. If None, it will automatically
2222
choose uint16 or uint32 based on the number of genes.
2323
"""
24-
n_obs, n_vars = adata.shape
24+
n_obs, n_vars = unsadata.shape
2525

2626
# 1. Automatically determine the smallest safe integer type
2727
if dtype is None:
@@ -31,19 +31,19 @@ def chunked_argsort(adata, layer_name='sorted', chunk_size=500, dtype=None):
3131
dtype = np.uint32
3232

3333
# 2. Pre-allocate the layer
34-
adata.layers[layer_name] = np.empty((n_obs, n_vars), dtype=dtype)
34+
unsadata.layers[layer_name] = np.empty((n_obs, n_vars), dtype=dtype)
3535

3636
# 3. Loop through chunks
3737
for i in range(0, n_obs, chunk_size):
3838
end = min(i + chunk_size, n_obs)
3939

4040
# Pull chunk and densify only if necessary
41-
chunk = adata.X[i:end]
41+
chunk = unsadata.X[i:end]
4242
if issparse(chunk):
4343
chunk = chunk.toarray()
4444

4545
# Perform sort and assign
46-
adata.layers[layer_name][i:end] = np.argsort(chunk, axis=1)
46+
unsadata.layers[layer_name][i:end] = np.argsort(chunk, axis=1)
4747

4848
print(f"Successfully created layer '{layer_name}' using {dtype}.")
4949

0 commit comments

Comments
 (0)