Skip to content

Commit 86417f9

Browse files
committed
[MNT] Import private namespaces if scipy > 1.8.0
Private namespaces where renamed in scipy 1.8.0 to distinguish them from public ones: scipy/scipy#14360. We fixed the import statements appropriately. We used a try/except statement so that the toolbox still works with scipy < 1.8.0.
1 parent 503d9ad commit 86417f9

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

netneurotools/freesurfer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
from nibabel.freesurfer import read_annot, read_geometry
1111
import numpy as np
1212
from scipy import sparse
13-
from scipy.ndimage.measurements import _stats, labeled_comprehension
13+
try: #scipy >= 1.8.0
14+
from scipy.ndimage._measurements import _stats, labeled_comprehension
15+
except ImportError: # scipy < 1.8.0
16+
from scipy.ndimage.measurements import _stats, labeled_comprehension
1417
from scipy.spatial.distance import cdist
1518

1619
from .datasets import fetch_fsaverage

netneurotools/stats.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
from tqdm import tqdm
1010
from itertools import combinations
1111
from scipy import optimize, spatial, special, stats as sstats
12-
from scipy.stats.stats import _chk2_asarray
12+
try: # scipy >= 1.8.0
13+
from scipy.stats._stats_py import _chk2_asarray
14+
except ImportError: # scipy < 1.8.0
15+
from scipy.stats.stats import _chk2_asarray
1316
from sklearn.utils.validation import check_random_state
1417
from sklearn.linear_model import LinearRegression
1518

0 commit comments

Comments
 (0)