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
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.7
numpy==1.24
scipy==1.10
networkx==3.0
nibabel==5.0
matplotlib==3.9
numpy==2.0
scipy==1.13
networkx==3.3
nibabel==5.3
5 changes: 0 additions & 5 deletions nitime/_compat.py

This file was deleted.

15 changes: 7 additions & 8 deletions nitime/algorithms/spectral.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
# To support older versions of numpy that don't have tril_indices:
from nitime.index_utils import tril_indices, triu_indices


# Set global variables for the default NFFT to be used in spectral analysis and
# the overlap:
default_nfft = 64
Expand Down Expand Up @@ -308,7 +307,7 @@ def periodogram_csd(s, Fs=2 * np.pi, Sk=None, NFFT=None, sides='default',

"""
s_shape = s.shape
s.shape = (-1, s_shape[-1])
s = s.reshape((-1, s_shape[-1]))
# defining an Sk_loc is a little opaque, but it avoids having to
# reset the shape of any user-given Sk later on
if Sk is not None:
Expand All @@ -322,7 +321,7 @@ def periodogram_csd(s, Fs=2 * np.pi, Sk=None, NFFT=None, sides='default',
N = s.shape[-1]
Sk_loc = fftpack.fft(s, n=N)
# reset s.shape
s.shape = s_shape
s = s.reshape(s_shape)

M = Sk_loc.shape[0]

Expand Down Expand Up @@ -550,7 +549,7 @@ def multi_taper_psd(
NFFT = spectra.shape[-1]
K = len(eigvals)
# collapse spectra's shape back down to 3 dimensions
spectra.shape = (M, K, NFFT)
spectra = spectra.reshape((M, K, NFFT))

last_freq = NFFT // 2 + 1 if sides == 'onesided' else NFFT

Expand Down Expand Up @@ -593,12 +592,12 @@ def multi_taper_psd(
freqs = np.linspace(0, Fs, NFFT, endpoint=False)

out_shape = s.shape[:-1] + (len(freqs),)
sdf_est.shape = out_shape
sdf_est = sdf_est.reshape(out_shape)
if jackknife:
jk_var.shape = out_shape
jk_var = jk_var.reshape(out_shape)
return freqs, sdf_est, jk_var
else:
nu.shape = out_shape
nu = nu.reshape(out_shape)
return freqs, sdf_est, nu


Expand Down Expand Up @@ -690,7 +689,7 @@ def multi_taper_csd(s, Fs=2 * np.pi, NW=None, BW=None, low_bias=True,
NFFT = spectra.shape[-1]
K = len(eigvals)
# collapse spectra's shape back down to 3 dimensions
spectra.shape = (M, K, NFFT)
spectra = spectra.reshape((M, K, NFFT))

# compute the cross-spectral density functions
last_freq = NFFT // 2 + 1 if sides == 'onesided' else NFFT
Expand Down
3 changes: 2 additions & 1 deletion nitime/algorithms/tests/test_autoregressive.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import numpy as np
import numpy.testing as npt

from numpy import trapezoid

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
3 changes: 2 additions & 1 deletion nitime/tests/test_algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
from scipy import fftpack, signal

import nitime
from numpy import trapezoid

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

#Define globally
test_dir_path = os.path.join(nitime.__path__[0], 'tests')
Expand Down
2 changes: 1 addition & 1 deletion nitime/tests/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ def test_timearray_math_functions(f, tu):
"Calling TimeArray.min() .max(), mean() should return TimeArrays"
a = np.arange(2, 11)
b = ts.TimeArray(a, time_unit=tu)
if f == "ptp" and ts._NP_2:
if f == "ptp":
want = np.ptp(a)
else:
want = getattr(a, f)()
Expand Down
10 changes: 1 addition & 9 deletions nitime/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
# Our own
from nitime import descriptors as desc

try:
_NP_2 = int(np.__version__.split(".")[0]) >= 2
except Exception:
_NP_2 = True

#-----------------------------------------------------------------------------
# Module globals
Expand Down Expand Up @@ -319,11 +315,7 @@ def mean(self, *args, **kwargs):
return ret

def ptp(self, *args, **kwargs):
if _NP_2:
ptp = np.ptp
else:
ptp = np.ndarray.ptp
ret = TimeArray(ptp(self, *args, **kwargs),
ret = TimeArray(np.ptp(self, *args, **kwargs),
time_unit=base_unit)
ret.convert_unit(self.time_unit)
return ret
Expand Down
4 changes: 2 additions & 2 deletions nitime/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ def tapered_spectra(s, tapers, NFFT=None, low_bias=True):
# compute the y_{i,k}(f) -- full FFT takes ~1.5x longer, but unpacking
# results of real-valued FFT eats up memory
t_spectra = fftpack.fft(tapered, n=NFFT, axis=-1)
t_spectra.shape = rest_of_dims + (K, NFFT)
t_spectra = t_spectra.reshape(rest_of_dims + (K, NFFT))
if eigvals is None:
return t_spectra
return t_spectra, eigvals
Expand Down Expand Up @@ -834,7 +834,7 @@ def detect_lines(s, tapers, p=None, **taper_kws):
numr[...,0] = 1; # don't care about DC
# denominator -- strength of residual
spectra = np.rollaxis(spectra, -2, 0)
U0.shape = (K,) + (1,) * (spectra.ndim-1)
U0 = U0.reshape((K,) + (1,) * (spectra.ndim-1))
denomr = spectra - U0*mu
denomr = np.sum(np.abs(denomr)**2, axis=0) / (2*K-2)
denomr[...,0] = 1;
Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ classifiers = [
"Topic :: Scientific/Engineering",
]
dependencies = [
"matplotlib>=3.7",
"numpy>=1.24",
"scipy>=1.10",
"matplotlib>=3.9",
"numpy>=2.0",
"scipy>=1.13",
]

[project.optional-dependencies]
full = [
"networkx>=3.0",
"nibabel>=5.0",
"networkx>=3.3",
"nibabel>=5.3",
]

[project.urls]
Expand Down
10 changes: 5 additions & 5 deletions 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.7
numpy>=1.24
scipy>=1.10
networkx>=3.0
nibabel>=5.0
matplotlib>=3.9
numpy>=2.0
scipy>=1.13
networkx>=3.3
nibabel>=5.3
Loading