Skip to content

Commit 2d5a7b0

Browse files
authored
Merge pull request #204 from effigies/fix/deprecations
FIX: Address deprecation warnings
2 parents 4411b30 + 0632672 commit 2d5a7b0

File tree

6 files changed

+18
-20
lines changed

6 files changed

+18
-20
lines changed

nitime/algorithms/spectral.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ def multi_taper_psd(
523523
"""
524524
# have last axis be time series for now
525525
N = s.shape[-1]
526-
M = int(np.product(s.shape[:-1]))
526+
M = int(np.prod(s.shape[:-1]))
527527

528528
if BW is not None:
529529
# BW wins in a contest (since it was the original implementation)
@@ -663,7 +663,7 @@ def multi_taper_csd(s, Fs=2 * np.pi, NW=None, BW=None, low_bias=True,
663663
"""
664664
# have last axis be time series for now
665665
N = s.shape[-1]
666-
M = int(np.product(s.shape[:-1]))
666+
M = int(np.prod(s.shape[:-1]))
667667

668668
if BW is not None:
669669
# BW wins in a contest (since it was the original implementation)

nitime/algorithms/tests/test_coherence.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import numpy as np
1010
import numpy.testing as npt
11-
from scipy.signal import signaltools
11+
from scipy import signal
1212
import pytest
1313

1414
import matplotlib
@@ -203,7 +203,7 @@ def test_correlation_spectrum():
203203
# XXX FIXME: http://github.com/nipy/nitime/issues/issue/1
204204
@pytest.mark.skipif(True, reason="http://github.com/nipy/nitime/issues/issue/1")
205205
def test_coherence_linear_dependence():
206-
"""
206+
r"""
207207
Tests that the coherence between two linearly dependent time-series
208208
behaves as expected.
209209
@@ -239,7 +239,7 @@ def test_coherence_linear_dependence():
239239
"Fs": 2 * np.pi}
240240

241241
f, c = tsa.coherence(np.vstack([x, y]), csd_method=method)
242-
c_t = np.abs(signaltools.resample(c_t, c.shape[-1]))
242+
c_t = np.abs(signal.resample(c_t, c.shape[-1]))
243243

244244
npt.assert_array_almost_equal(c[0, 1], c_t, 2)
245245

nitime/algorithms/tests/test_spectral.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ def test_get_spectra_complex():
7070
r, _, _ = utils.ar_generator(N=2 ** 16) # It needs to be that long for
7171
# the answers to converge
7272
c, _, _ = utils.ar_generator(N=2 ** 16)
73-
arsig1 = r + c * scipy.sqrt(-1)
73+
arsig1 = r + c * 1j
7474

7575
r, _, _ = utils.ar_generator(N=2 ** 16)
7676
c, _, _ = utils.ar_generator(N=2 ** 16)
7777

78-
arsig2 = r + c * scipy.sqrt(-1)
78+
arsig2 = r + c * 1j
7979
avg_pwr1.append((arsig1 * arsig1.conjugate()).mean())
8080
avg_pwr2.append((arsig2 * arsig2.conjugate()).mean())
8181

@@ -118,7 +118,7 @@ def test_periodogram():
118118
N = 1024
119119
r, _, _ = utils.ar_generator(N=N)
120120
c, _, _ = utils.ar_generator(N=N)
121-
arsig = r + c * scipy.sqrt(-1)
121+
arsig = r + c * 1j
122122

123123
f, c = tsa.periodogram(arsig)
124124
npt.assert_equal(f.shape[0], N) # Should be N, not the one-sided N/2 + 1
@@ -143,11 +143,11 @@ def test_periodogram_csd():
143143
N = 1024
144144
r, _, _ = utils.ar_generator(N=N)
145145
c, _, _ = utils.ar_generator(N=N)
146-
arsig1 = r + c * scipy.sqrt(-1)
146+
arsig1 = r + c * 1j
147147

148148
r, _, _ = utils.ar_generator(N=N)
149149
c, _, _ = utils.ar_generator(N=N)
150-
arsig2 = r + c * scipy.sqrt(-1)
150+
arsig2 = r + c * 1j
151151

152152
tseries = np.vstack([arsig1, arsig2])
153153

nitime/tests/test_algorithms.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
import numpy as np
44
import numpy.testing as npt
55

6-
from scipy.signal import signaltools
7-
from scipy import fftpack
6+
from scipy import fftpack, signal
87

98
import nitime
109
from nitime import algorithms as tsa
@@ -24,16 +23,16 @@ def test_scipy_resample():
2423
for f in freq_list]
2524
tst = np.array(a).sum(axis=0)
2625
# interpolate to 128 Hz sampling
27-
t_up = signaltools.resample(tst, 128)
26+
t_up = signal.resample(tst, 128)
2827
np.testing.assert_array_almost_equal(t_up[::2], tst)
2928
# downsample to 32 Hz
30-
t_dn = signaltools.resample(tst, 32)
29+
t_dn = signal.resample(tst, 32)
3130
np.testing.assert_array_almost_equal(t_dn, tst[::2])
3231

3332
# downsample to 48 Hz, and compute the sampling analytically for comparison
3433
dn_samp_ana = np.array([np.sin(2 * np.pi * f * np.linspace(0, 1, 48, endpoint=False))
3534
for f in freq_list]).sum(axis=0)
36-
t_dn2 = signaltools.resample(tst, 48)
35+
t_dn2 = signal.resample(tst, 48)
3736
npt.assert_array_almost_equal(t_dn2, dn_samp_ana)
3837

3938

nitime/tests/test_lazy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ def test_lazy_noreload():
3737
with pytest.raises(ImportError) as e_info:
3838
reload(mod)
3939
elif major == 3:
40-
import imp
40+
import importlib
4141
with pytest.raises(ImportError) as e_info:
42-
imp.reload(mod)
42+
importlib.reload(mod)

nitime/utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -730,9 +730,8 @@ def tapered_spectra(s, tapers, NFFT=None, low_bias=True):
730730
if NFFT is None or NFFT < N:
731731
NFFT = N
732732
rest_of_dims = s.shape[:-1]
733-
M = int(np.product(rest_of_dims))
734733

735-
s = s.reshape(int(np.product(rest_of_dims)), N)
734+
s = s.reshape(-1, N)
736735
# de-mean this sucker
737736
s = remove_bias(s, axis=-1)
738737

@@ -1193,7 +1192,7 @@ def fftconvolve(in1, in2, mode="full", axis=None):
11931192
if mode == "full":
11941193
return ret
11951194
elif mode == "same":
1196-
if np.product(s1, axis=0) > np.product(s2, axis=0):
1195+
if np.prod(s1, axis=0) > np.prod(s2, axis=0):
11971196
osize = s1
11981197
else:
11991198
osize = s2

0 commit comments

Comments
 (0)