Commit 8aa3891
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
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
573 | 573 | | |
574 | 574 | | |
575 | 575 | | |
576 | | - | |
577 | | - | |
| 576 | + | |
| 577 | + | |
578 | 578 | | |
579 | 579 | | |
580 | 580 | | |
| |||
0 commit comments