Skip to content

Commit 45688e7

Browse files
committed
one ptr copy
1 parent 4087447 commit 45688e7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/scanpy/tools/_score_genes.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ def _get_sparce_nanmean_columns(
4242
def _get_sparce_nanmean_rows(
4343
data: NDArray[Any], indptr: NDArray[np.int32], shape: tuple
4444
) -> NDArray[np.float64]:
45+
#copy 1 time
46+
new_ptr = indptr[:-1]
4547
sum_arr = np.add.reduceat(
46-
np.nan_to_num(data, nan=0.0), indptr[:-1], dtype=np.float64
48+
np.nan_to_num(data, nan=0.0), new_ptr, dtype=np.float64
4749
)
48-
nans_arr = np.add.reduceat(np.isnan(data), indptr[:-1], dtype=np.float64)
50+
nans_arr = np.add.reduceat(np.isnan(data), new_ptr, dtype=np.float64)
4951
return sum_arr / (shape[1] - nans_arr)
5052

5153

0 commit comments

Comments
 (0)