diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 5f1517744..76679cf71 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -57,8 +57,8 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - # python versions for elephant: [3.8, 3.9, "3.10", 3.11] - python-version: [3.8, 3.9, "3.10", 3.11] + # python versions for elephant: [3.8, 3.9, "3.10", 3.11, 3.12] + python-version: [3.9, "3.10", 3.11, 3.12] # OS [ubuntu-latest, macos-latest, windows-latest] os: [ubuntu-latest] # do not cancel all in-progress jobs if any matrix job fails diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 2e8926dbf..b5dbea1f9 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -18,15 +18,17 @@ jobs: os: [ubuntu-20.04, windows-2019] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Used to host cibuildwheel - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.10' - name: Install cibuildwheel run: | python -m pip install --upgrade pip - python -m pip install cibuildwheel==2.13.1 + python -m pip install cibuildwheel==2.16.2 - name: Install libomp if: runner.os == 'macOS' diff --git a/doc/install.rst b/doc/install.rst index 6a85b2331..e663b0932 100644 --- a/doc/install.rst +++ b/doc/install.rst @@ -14,7 +14,7 @@ Below is the explanation of how to proceed with these two steps. Prerequisites ************* -Elephant requires `Python `_ 3.8, 3.9, 3.10 or 3.11. +Elephant requires `Python `_ 3.8, 3.9, 3.10, 3.11 or 3.12. .. tabs:: diff --git a/elephant/current_source_density.py b/elephant/current_source_density.py index 094e66853..00a25f0b4 100644 --- a/elephant/current_source_density.py +++ b/elephant/current_source_density.py @@ -38,7 +38,7 @@ import neo import numpy as np import quantities as pq -from scipy.integrate import simps +from scipy.integrate import simpson import elephant.current_source_density_src.utility_functions as utils from elephant.current_source_density_src import KCSD, icsd @@ -281,7 +281,7 @@ def generate_lfp(csd_profile, x_positions, y_positions=None, z_positions=None, def integrate_1D(x0, csd_x, csd, h): m = np.sqrt((csd_x - x0) ** 2 + h ** 2) - abs(csd_x - x0) y = csd * m - I = simps(y, csd_x) + I = simpson(y, x=csd_x) return I def integrate_2D(x, y, xlin, ylin, csd, h, X, Y): @@ -293,17 +293,17 @@ def integrate_2D(x, y, xlin, ylin, csd, h, X, Y): m = np.sqrt((x - X) ** 2 + (y - Y) ** 2) np.clip(m, a_min=0.0000001, a_max=None, out=m) y = np.arcsinh(2 * h / m) * csd - I = simps(y.T, ylin) - F = simps(I, xlin) + I = simpson(y.T, x=ylin) + F = simpson(I, x=xlin) return F def integrate_3D(x, y, z, csd, xlin, ylin, zlin, X, Y, Z): m = np.sqrt((x - X) ** 2 + (y - Y) ** 2 + (z - Z) ** 2) np.clip(m, a_min=0.0000001, a_max=None, out=m) z = csd / m - Iy = simps(np.transpose(z, (1, 0, 2)), zlin) - Iy = simps(Iy, ylin) - F = simps(Iy, xlin) + Iy = simpson(np.transpose(z, (1, 0, 2)), x=zlin) + Iy = simpson(Iy, x=ylin) + F = simpson(Iy, x=xlin) return F dim = 1 diff --git a/elephant/current_source_density_src/icsd.py b/elephant/current_source_density_src/icsd.py index 3ba02b335..bb3376ab3 100644 --- a/elephant/current_source_density_src/icsd.py +++ b/elephant/current_source_density_src/icsd.py @@ -95,26 +95,26 @@ def filter_csd(self, csd, filterfunction='convolve'): raise ae('filter order f_order must be a tuple of length 2') else: try: - assert(self.f_order > 0 and isinstance(self.f_order, int)) + assert (self.f_order > 0 and isinstance(self.f_order, int)) except AssertionError as ae: raise ae('Filter order must be int > 0!') try: - assert(filterfunction in ['filtfilt', 'convolve']) + assert (filterfunction in ['filtfilt', 'convolve']) except AssertionError as ae: raise ae("{} not equal to 'filtfilt' or \ 'convolve'".format(filterfunction)) if self.f_type == 'boxcar': - num = ss.boxcar(self.f_order) + num = ss.windows.boxcar(self.f_order) denom = np.array([num.sum()]) elif self.f_type == 'hamming': - num = ss.hamming(self.f_order) + num = ss.windows.hamming(self.f_order) denom = np.array([num.sum()]) elif self.f_type == 'triangular': - num = ss.triang(self.f_order) + num = ss.windows.triang(self.f_order) denom = np.array([num.sum()]) elif self.f_type == 'gaussian': - num = ss.gaussian(self.f_order[0], self.f_order[1]) + num = ss.windows.gaussian(self.f_order[0], self.f_order[1]) denom = np.array([num.sum()]) elif self.f_type == 'identity': num = np.array([1.]) diff --git a/elephant/spike_train_correlation.py b/elephant/spike_train_correlation.py index 9abf1e35a..03b4d9acb 100644 --- a/elephant/spike_train_correlation.py +++ b/elephant/spike_train_correlation.py @@ -1073,5 +1073,5 @@ def spike_train_timescale(binned_spiketrain, max_tau): # Calculate the timescale using trapezoidal integration integr = (corrfct / corrfct[0]) ** 2 - timescale = 2 * integrate.trapz(integr, dx=bin_size) + timescale = 2 * integrate.trapezoid(integr, dx=bin_size) return pq.Quantity(timescale, units=binned_spiketrain.units, copy=False) diff --git a/elephant/spike_train_dissimilarity.py b/elephant/spike_train_dissimilarity.py index 217322b2f..6fa8f4f8e 100644 --- a/elephant/spike_train_dissimilarity.py +++ b/elephant/spike_train_dissimilarity.py @@ -24,7 +24,6 @@ import numpy as np import quantities as pq -import scipy as sp from neo.core import SpikeTrain import elephant.kernels as kernels @@ -364,7 +363,7 @@ def van_rossum_distance(spiketrains, time_constant=1.0 * pq.s, sort=True): for i, j in np.ndindex(k_dist.shape): vr_dist[i, j] = ( k_dist[i, i] + k_dist[j, j] - k_dist[i, j] - k_dist[j, i]) - return sp.sqrt(vr_dist) + return np.sqrt(vr_dist) def _summed_dist_matrix(spiketrains, tau, presorted=False): diff --git a/elephant/test/test_kernels.py b/elephant/test/test_kernels.py index ddcd9e319..0fa7ae865 100644 --- a/elephant/test/test_kernels.py +++ b/elephant/test/test_kernels.py @@ -81,7 +81,7 @@ def test_kernels_normalization(self): restric_defdomain = np.linspace( -b, b, num=n_points) * sigma.units kern = kernel(restric_defdomain) - norm = spint.cumtrapz(y=kern.magnitude, + norm = spint.cumulative_trapezoid(y=kern.magnitude, x=restric_defdomain.magnitude)[-1] self.assertAlmostEqual(norm, 1, delta=0.003) @@ -104,11 +104,11 @@ def test_kernels_stddev(self): -b, b, num=n_points) * sigma.units kern = kernel(restric_defdomain) av_integr = kern * restric_defdomain - average = spint.cumtrapz( + average = spint.cumulative_trapezoid( y=av_integr.magnitude, x=restric_defdomain.magnitude)[-1] * sigma.units var_integr = (restric_defdomain - average) ** 2 * kern - variance = spint.cumtrapz( + variance = spint.cumulative_trapezoid( y=var_integr.magnitude, x=restric_defdomain.magnitude)[-1] * sigma.units ** 2 stddev = np.sqrt(variance) @@ -132,7 +132,7 @@ def test_kernel_boundary_enclosing(self): restric_defdomain = np.linspace( -b, b, num=n_points) * sigma.units kern = kernel(restric_defdomain) - frac = spint.cumtrapz(y=kern.magnitude, + frac = spint.cumulative_trapezoid(y=kern.magnitude, x=restric_defdomain.magnitude)[-1] self.assertAlmostEqual(frac, fraction, delta=0.002) diff --git a/elephant/test/test_spike_train_dissimilarity.py b/elephant/test/test_spike_train_dissimilarity.py index 75861f79f..7fa2e6cc9 100644 --- a/elephant/test/test_spike_train_dissimilarity.py +++ b/elephant/test/test_spike_train_dissimilarity.py @@ -491,7 +491,7 @@ def test_van_rossum_distance(self): -((self.t - self.st08[1]) / self.tau3).simplified) - (self.t > self.st09[0]) * np.exp( -((self.t - self.st09[0]) / self.tau3).simplified)) ** 2 - distance = np.sqrt(2.0 * spint.cumtrapz( + distance = np.sqrt(2.0 * spint.cumulative_trapezoid( y=f_minus_g_squared, x=self.t.magnitude)[-1] / self.tau3.rescale(self.t.units).magnitude) self.assertAlmostEqual(stds.van_rossum_distance( @@ -573,7 +573,7 @@ def test_van_rossum_distance(self): -((self.t - self.st34[0]) / self.tau3).simplified) - (self.t > self.st34[1]) * np.exp( -((self.t - self.st34[1]) / self.tau3).simplified)) ** 2 - distance = np.sqrt(2.0 * spint.cumtrapz( + distance = np.sqrt(2.0 * spint.cumulative_trapezoid( y=f_minus_g_squared, x=self.t.magnitude)[-1] / self.tau3.rescale(self.t.units).magnitude) self.assertAlmostEqual(stds.van_rossum_distance([self.st31, self.st34], diff --git a/elephant/test/test_statistics.py b/elephant/test/test_statistics.py index aaa48412d..b5bf8be19 100644 --- a/elephant/test/test_statistics.py +++ b/elephant/test/test_statistics.py @@ -616,7 +616,7 @@ def test_instantaneous_rate_rate_estimation_consistency(self): border_correction=border_correction ) num_spikes = len(self.spike_train) - area_under_curve = spint.cumtrapz( + area_under_curve = spint.cumulative_trapezoid( y=rate_estimate.magnitude[:, 0], x=rate_estimate.times.rescale('s').magnitude)[-1] self.assertAlmostEqual(num_spikes, area_under_curve, diff --git a/requirements/environment.yml b/requirements/environment.yml index 2ec822c27..9f6196b6e 100644 --- a/requirements/environment.yml +++ b/requirements/environment.yml @@ -7,7 +7,7 @@ dependencies: - python>=3.8 - mpi4py - numpy>=1.19.5 - - scipy + - scipy>=1.10.0 - tqdm - scikit-learn - statsmodels diff --git a/requirements/requirements.txt b/requirements/requirements.txt index a7b7b836b..929268871 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -1,6 +1,6 @@ neo>=0.10.0 numpy>=1.19.5 quantities>=0.14.1 -scipy>=1.5.4 +scipy>=1.10.0 six>=1.10.0 tqdm