Skip to content

Commit 7992ecf

Browse files
Make call to scipy.stats.mode compatible with scipy 1.11.0
Starting with scipy 1.11.0, scipy.stats.mode returns a scalar value for the mode instead of a one-element array. This change was foreshadowed in scipy version 1.9.0 with the addition of the `keepdims` parameter, with the eventual goal of setting it to false by default for consistency with other scipy.stats functions. See scipy/scipy#16418 for the initial proposal and scipy/scipy#17561 for the final change that is now breaking the _demean function. This commit changes the indexing to be compatible with scipy 1.11.0 and other future versions. I have also tested this change with older scipy versions up to 0.17.1, which was released in 2016.
1 parent 08152b2 commit 7992ecf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sdcflows/workflows/gre.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def _demean(in_file, in_mask=None, usemode=True):
212212

213213
if usemode:
214214
from scipy.stats import mode
215-
data[msk] -= mode(data[msk], axis=None)[0][0]
215+
data[msk] -= mode(data[msk], axis=None).mode.item()
216216
else:
217217
data[msk] -= np.median(data[msk], axis=None)
218218

0 commit comments

Comments
 (0)