Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,10 @@ dist/

# setuptools_scm
nitime/_version.py

# coverage
.coverage
coverage.xml

# tox
.tox
10 changes: 5 additions & 5 deletions min-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Auto-generated by tools/update_requirements.py
--only-binary numpy,scipy
--extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple
matplotlib==3.5
numpy==1.22
scipy==1.8
networkx==2.7
nibabel==4.0
matplotlib==3.7
numpy==1.24
scipy==1.10
networkx==3.0
nibabel==5.0
5 changes: 5 additions & 0 deletions nitime/_compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# np.trapezoid was introduced and np.trapz deprecated in numpy 2.0
try: # NP2
from numpy import trapezoid
except ImportError: # NP1
from numpy import trapz as trapezoid
226 changes: 0 additions & 226 deletions nitime/_mpl_units.py

This file was deleted.

9 changes: 5 additions & 4 deletions nitime/algorithms/tests/test_autoregressive.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import nitime.algorithms as tsa
import nitime.utils as utils
from nitime._compat import trapezoid

# Set the random seed:
np.random.seed(1)
Expand Down Expand Up @@ -46,14 +47,14 @@ def test_AR_YW():

# evaluate this integral numerically from 0 to pi
dw = np.pi / len(psd)
avg_pwr_est = np.trapz(psd, dx=dw) / (2 * np.pi)
avg_pwr_est = trapezoid(psd, dx=dw) / (2 * np.pi)
# consistency on the order of 10**0 is pretty good for this test
npt.assert_almost_equal(avg_pwr, avg_pwr_est, decimal=0)

# Test for providing the autocovariance as an input:
ak, sigma_v = tsa.AR_est_YW(arsig, order, utils.autocov(arsig))
w, psd = tsa.AR_psd(ak, sigma_v)
avg_pwr_est = np.trapz(psd, dx=dw) / (2 * np.pi)
avg_pwr_est = trapezoid(psd, dx=dw) / (2 * np.pi)
npt.assert_almost_equal(avg_pwr, avg_pwr_est, decimal=0)


Expand All @@ -76,13 +77,13 @@ def test_AR_LD():

# evaluate this integral numerically from 0 to pi
dw = np.pi / len(psd)
avg_pwr_est = np.trapz(psd, dx=dw) / (2 * np.pi)
avg_pwr_est = trapezoid(psd, dx=dw) / (2 * np.pi)
npt.assert_almost_equal(avg_pwr, avg_pwr_est, decimal=0)

# Test for providing the autocovariance as an input:
ak, sigma_v = tsa.AR_est_LD(arsig, order, utils.autocov(arsig))
w, psd = tsa.AR_psd(ak, sigma_v)
avg_pwr_est = np.trapz(psd, dx=dw) / (2 * np.pi)
avg_pwr_est = trapezoid(psd, dx=dw) / (2 * np.pi)
npt.assert_almost_equal(avg_pwr, avg_pwr_est, decimal=0)


Expand Down
11 changes: 5 additions & 6 deletions nitime/analysis/coherence.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def __init__(self, input=None, method=None, unwrap_phases=False):
Examples
--------
>>> import nitime.timeseries as ts
>>> np.set_printoptions(precision=4) # for doctesting
>>> t1 = ts.TimeSeries(data = np.arange(0,1024,1).reshape(2,512),
... sampling_rate=np.pi)
>>> c1 = CoherenceAnalyzer(t1)
Expand All @@ -48,11 +47,11 @@ def __init__(self, input=None, method=None, unwrap_phases=False):
>>> c1.method['this_method']
'welch'
>>> c1.coherence[0,1]
array([ 0.9024, 0.9027, 0.9652, 0.9433, 0.9297, 0.9213, 0.9161,
0.9126, 0.9102, 0.9085, 0.9072, 0.9063, 0.9055, 0.905 ,
0.9045, 0.9041, 0.9038, 0.9036, 0.9034, 0.9032, 0.9031,
0.9029, 0.9028, 0.9027, 0.9027, 0.9026, 0.9026, 0.9025,
0.9025, 0.9025, 0.9025, 0.9026, 1. ])
array([0.9024, 0.9027, 0.9652, 0.9433, 0.9297, 0.9213, 0.9161, 0.9126,
0.9102, 0.9085, 0.9072, 0.9063, 0.9055, 0.905 , 0.9045, 0.9041,
0.9038, 0.9036, 0.9034, 0.9032, 0.9031, 0.9029, 0.9028, 0.9027,
0.9027, 0.9026, 0.9026, 0.9025, 0.9025, 0.9025, 0.9025, 0.9026,
1. ])
>>> c1.phase[0,1]
array([ 0. , -0.035 , -0.4839, -0.4073, -0.3373, -0.2828, -0.241 ,
-0.2085, -0.1826, -0.1615, -0.144 , -0.1292, -0.1164, -0.1054,
Expand Down
1 change: 0 additions & 1 deletion nitime/analysis/correlation.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def __init__(self, input=None):

Examples
--------
>>> np.set_printoptions(precision=4) # for doctesting
>>> t1 = ts.TimeSeries(data = np.sin(np.arange(0,
... 10*np.pi,10*np.pi/100)).reshape(2,50),
... sampling_rate=np.pi)
Expand Down
13 changes: 6 additions & 7 deletions nitime/analysis/spectral.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def __init__(self, input=None, method=None, BW=None, adaptive=False,

Examples
--------
>>> np.set_printoptions(precision=4) # for doctesting
>>> t1 = ts.TimeSeries(data = np.arange(0,1024,1).reshape(2,512),
... sampling_rate=np.pi)
>>> s1 = SpectralAnalyzer(t1)
Expand All @@ -53,13 +52,13 @@ def __init__(self, input=None, method=None, BW=None, adaptive=False,
3.1415926535... Hz
>>> f,s = s1.psd
>>> f
array([ 0. , 0.0491, 0.0982, 0.1473, 0.1963, 0.2454, 0.2945,
0.3436, 0.3927, 0.4418, 0.4909, 0.54 , 0.589 , 0.6381,
0.6872, 0.7363, 0.7854, 0.8345, 0.8836, 0.9327, 0.9817,
1.0308, 1.0799, 1.129 , 1.1781, 1.2272, 1.2763, 1.3254,
1.3744, 1.4235, 1.4726, 1.5217, 1.5708])
array([0. , 0.0491, 0.0982, 0.1473, 0.1963, 0.2454, 0.2945, 0.3436,
0.3927, 0.4418, 0.4909, 0.54 , 0.589 , 0.6381, 0.6872, 0.7363,
0.7854, 0.8345, 0.8836, 0.9327, 0.9817, 1.0308, 1.0799, 1.129 ,
1.1781, 1.2272, 1.2763, 1.3254, 1.3744, 1.4235, 1.4726, 1.5217,
1.5708])
>>> s[0,0] # doctest: +ELLIPSIS
1128276.92538360...
1128276.9253836009
"""
BaseAnalyzer.__init__(self, input)

Expand Down
7 changes: 7 additions & 0 deletions nitime/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import numpy as np
import pytest


@pytest.fixture(scope='session', autouse=True)
def legacy_printoptions():
np.set_printoptions(legacy='1.21', precision=4)
6 changes: 3 additions & 3 deletions nitime/index_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ def tri(N, M=None, k=0, dtype=float):
[1, 1, 1, 1, 1]])

>>> np.tri(3, 5, -1)
array([[ 0., 0., 0., 0., 0.],
[ 1., 0., 0., 0., 0.],
[ 1., 1., 0., 0., 0.]])
array([[0., 0., 0., 0., 0.],
[1., 0., 0., 0., 0.],
[1., 1., 0., 0., 0.]])

"""
if M is None: M = N
Expand Down
Loading