Skip to content

Commit 8aa3891

Browse files
committed
fix: replace strided slicing with out= for NumPy 2.x compatibility
NumPy 2.x rejects strided slicing (e.g., array[::2, :]) as the out= parameter in reduction operations due to stricter dimension validation. Before: np.sum(cohort_is_amp, axis=1, out=count[::2, cohort_index]) After: count[::2, cohort_index] = np.sum(cohort_is_amp, axis=1) Root cause: NumPy 2.x enforces strict dimension checking for out= parameters in ufunc.reduce operations. Strided views create non-contiguous arrays that fail this validation with ValueError. The explicit assignment approach produces identical results and works with both NumPy 1.26.x and 2.x. Fixes coverage job failures under NumPy 2.x test matrix.
1 parent d175b24 commit 8aa3891

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

malariagen_data/anoph/cnv_frq.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,8 @@ def _gene_cnv_frequencies_advanced(
573573
cohort_is_called = np.take(is_called, sample_indices, axis=1)
574574

575575
# compute cohort allele counts
576-
np.sum(cohort_is_amp, axis=1, out=count[::2, cohort_index])
577-
np.sum(cohort_is_del, axis=1, out=count[1::2, cohort_index])
576+
count[::2, cohort_index] = np.sum(cohort_is_amp, axis=1)
577+
count[1::2, cohort_index] = np.sum(cohort_is_del, axis=1)
578578

579579
# compute cohort allele numbers
580580
cohort_n_called = np.sum(cohort_is_called, axis=1)

0 commit comments

Comments
 (0)