Skip to content

Commit

Permalink
[Main] remove deprecated features (#488)
Browse files Browse the repository at this point in the history
* removed deprecated aliases from unitary_event_analysis.py

* updated unitary_event_analysis.ipynb accordingly

* removed deprecated aliases from cell_assembly_detection.py

* removed deprecated aliases from change_point_detection.py

* removed deprecated aliases from conversion.py

* stationary poisson process from parallel

* fixed statistics.py, changed binsize to bin_size

* removed deprecated aliases from cubic.py

* removed deprecated aliases from current_source_density.py, refactored test_csd to test_current_source_density

* refactor dictionary creation

* removed deprecated aliases from gpfa.py, refactored test_gpfa.py to use StationaryPoissonProcess

* remove homogeneous_poisson_process from spike_train_generation.py

* removed deprecated aliases from gpfa_util.py

* removed deprecated aliases from kernels.py

* removed deprecated aliases from neo_tools.py

* removed deprecated aliases from signal_processing.py

* removed deprecated aliases from spade.py

* removed deprecated aliases from spectral.py

* removed deprecated aliases from spike_train_correlation.py

* removed deprecated aliases from spike_train_dissimilarity.py

* removed deprecated aliases from spike_train_generation.py

* update keyword argument in spade tutorial

* fix example code for cubic

* fix example code spike_train_generation

* fix example code gpfa

* removed deprecated aliases from unitary_event_analysis.py

* updated unitary_event_analysis.ipynb accordingly

* removed deprecated aliases from change_point_detection.py

* removed deprecated aliases from conversion.py

* stationary poisson process from parallel

* fixed statistics.py, changed binsize to bin_size

* removed deprecated aliases from cubic.py

* removed deprecated aliases from current_source_density.py, refactored test_csd to test_current_source_density

* refactor dictionary creation

* removed deprecated aliases from gpfa.py, refactored test_gpfa.py to use StationaryPoissonProcess

* remove homogeneous_poisson_process from spike_train_generation.py

* removed deprecated aliases from gpfa_util.py

* removed deprecated aliases from kernels.py

* removed deprecated aliases from neo_tools.py

* removed deprecated aliases from signal_processing.py

* removed deprecated aliases from spectral.py

* removed deprecated aliases from spike_train_dissimilarity.py

* removed deprecated aliases from spike_train_generation.py

* update keyword argument in spade tutorial

* fix example code for cubic

* fix example code spike_train_generation

* add missing import statement for check_neo_consistency

* fix imports

* fix pep8

* remove "TODO" from statistics tutorial notebook
  • Loading branch information
Moritz-Alexander-Kern authored Nov 10, 2023
1 parent e867b94 commit 2fa63bc
Show file tree
Hide file tree
Showing 28 changed files with 260 additions and 413 deletions.
6 changes: 3 additions & 3 deletions doc/tutorials/spade.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"outputs": [],
"source": [
"spiketrains = elephant.spike_train_generation.compound_poisson_process(\n",
" rate=5*pq.Hz, A=[0]+[0.98]+[0]*8+[0.02], t_stop=10*pq.s)\n",
" rate=5*pq.Hz, amplitude_distribution=[0]+[0.98]+[0]*8+[0.02], t_stop=10*pq.s)\n",
"len(spiketrains)"
]
},
Expand Down Expand Up @@ -152,7 +152,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "New_Filter",
"language": "python",
"name": "python3"
},
Expand All @@ -166,7 +166,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.10.4"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
Expand Down
21 changes: 0 additions & 21 deletions doc/tutorials/statistics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -520,27 +520,6 @@
"source": [
"As predicted by theory, the CV values are clustered around 1."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# TODO"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Spike interval statistics"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Statistics across spike trains"
]
}
],
"metadata": {
Expand Down
5 changes: 4 additions & 1 deletion doc/tutorials/unitary_event_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -495,14 +495,17 @@
"outputs": [],
"source": [
"UE = ue.jointJ_window_analysis(\n",
" spiketrains, bin_size=5*pq.ms, winsize=100*pq.ms, winstep=10*pq.ms, pattern_hash=[3])\n",
" spiketrains, bin_size=5*pq.ms, win_size=100*pq.ms, win_step=10*pq.ms, pattern_hash=[3])\n",
"\n",
"plot_ue(spiketrains, UE, significance_level=0.05)\n",
"plt.show()"
]
}
],
"metadata": {
"interpreter": {
"hash": "623e048a0474aa032839f97d38ba0837cc9041adc49a14b480c72f2df8ea99e3"
},
"kernelspec": {
"display_name": "inm-elephant",
"language": "python",
Expand Down
21 changes: 1 addition & 20 deletions elephant/cell_assembly_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,28 +71,23 @@
import copy
import math
import time
import warnings

import numpy as np
from scipy.stats import f

import elephant.conversion as conv
from elephant.utils import deprecated_alias

__all__ = [
"cell_assembly_detection"
]


@deprecated_alias(data='binned_spiketrain', maxlag='max_lag',
min_occ='min_occurrences',
same_config_cut='same_configuration_pruning')
def cell_assembly_detection(binned_spiketrain, max_lag, reference_lag=2,
alpha=0.05, min_occurrences=1, size_chunks=100,
max_spikes=np.inf, significance_pruning=True,
subgroup_pruning=True,
same_configuration_pruning=False,
bool_times_format=None, verbose=False):
verbose=False):
"""
Perform the CAD analysis :cite:`cad-Russo2017_e19428` for the binned
(discretized) spike trains given in the input. The method looks for
Expand Down Expand Up @@ -156,14 +151,6 @@ def cell_assembly_detection(binned_spiketrain, max_lag, reference_lag=2,
efficient), not testing assemblies already formed
if they appear in the very same configuration.
Default: False
bool_times_format : bool, optional
.. deprecated:: 0.10.0
Has no effect, the returning 'times' are always a quantity array
specifying the pattern spike times.
Default: None
verbose : bool, optional
Regulates the number of prints given by the method. If true all prints
are given, otherwise the method does give any prints.
Expand Down Expand Up @@ -216,12 +203,6 @@ def cell_assembly_detection(binned_spiketrain, max_lag, reference_lag=2,
size_chunks=size_chunks,
max_spikes=max_spikes)

if bool_times_format is not None:
warnings.warn("'bool_times_format' is deprecated and has no effect; "
"the returning 'times' are always a quantity array "
"specifying the pattern spike times. Set this parameter "
"to None.", DeprecationWarning)

bin_size = binned_spiketrain.bin_size
t_start = binned_spiketrain.t_start

Expand Down
4 changes: 0 additions & 4 deletions elephant/change_point_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,12 @@
import numpy as np
import quantities as pq

from elephant.utils import deprecated_alias

__all__ = [
"multiple_filter_test",
"empirical_parameters"
]


@deprecated_alias(dt='time_step')
def multiple_filter_test(window_sizes, spiketrain, t_final, alpha,
n_surrogates=1000, test_quantile=None,
test_param=None, time_step=None):
Expand Down Expand Up @@ -253,7 +250,6 @@ def _limit_processes(window_sizes, t_final, time_step):
return limit_processes


@deprecated_alias(dt='time_step')
def empirical_parameters(window_sizes, t_final, alpha, n_surrogates=1000,
time_step=None):
r"""
Expand Down
42 changes: 1 addition & 41 deletions elephant/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
import quantities as pq
import scipy.sparse as sps

from elephant.utils import is_binary, deprecated_alias, is_time_quantity, \
from elephant.utils import is_binary, is_time_quantity, \
check_neo_consistency, round_binning_errors

__all__ = [
Expand Down Expand Up @@ -334,7 +334,6 @@ class BinnedSpikeTrain(object):
"""

@deprecated_alias(binsize='bin_size', num_bins='n_bins')
def __init__(self, spiketrains, bin_size=None, n_bins=None, t_start=None,
t_stop=None, tolerance=1e-8, sparse_format="csr"):
if sparse_format not in ("csr", "csc"):
Expand Down Expand Up @@ -387,24 +386,6 @@ def t_stop(self):
"""
return pq.Quantity(self._t_stop, units=self.units, copy=False)

@property
def binsize(self):
"""
Deprecated in favor of :attr:`bin_size`.
"""
warnings.warn("'.binsize' is deprecated; use '.bin_size'",
DeprecationWarning)
return self._bin_size

@property
def num_bins(self):
"""
Deprecated in favor of :attr:`n_bins`.
"""
warnings.warn("'.num_bins' is deprecated; use '.n_bins'",
DeprecationWarning)
return self.n_bins

def __repr__(self):
return f"{type(self).__name__}(t_start={str(self.t_start)}, " \
f"t_stop={str(self.t_stop)}, bin_size={str(self.bin_size)}; " \
Expand Down Expand Up @@ -619,27 +600,6 @@ def bin_centers(self):
bin_centers = pq.Quantity(bin_centers, units=self.units, copy=False)
return bin_centers

def to_sparse_array(self):
"""
Getter for sparse matrix with time points. Deprecated in favor of
:attr:`sparse_matrix`.
Returns
-------
scipy.sparse.csr_matrix or scipy.sparse.csc_matrix
Sparse matrix, version with spike counts.
See also
--------
scipy.sparse.csr_matrix
to_array
"""
warnings.warn("'.to_sparse_array()' function is deprecated; "
"use '.sparse_matrix' attribute directly",
DeprecationWarning)
return self.sparse_matrix

def to_sparse_bool_array(self):
"""
Getter for boolean version of the sparse matrix, calculated from
Expand Down
9 changes: 3 additions & 6 deletions elephant/cubic.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
>>> import quantities as pq
>>> from elephant import statistics
>>> from elephant.cubic import cubic
>>> from elephant.spike_train_generation import homogeneous_poisson_process
>>> from elephant.spike_train_generation import StationaryPoissonProcess
>>> np.random.seed(10)
>>> spiketrains = [homogeneous_poisson_process(rate=10*pq.Hz,
... t_stop=10 * pq.s) for _ in range(20)]
>>> spiketrains = [StationaryPoissonProcess(rate=10*pq.Hz,
... t_stop=10 * pq.s).generate_spiketrain() for _ in range(20)]
>>> pop_count = statistics.time_histogram(spiketrains, bin_size=0.1 * pq.s)
2) apply CuBIC to the population count
Expand All @@ -52,8 +52,6 @@
import scipy.special
import scipy.stats

from elephant.utils import deprecated_alias

__all__ = [
"cubic"
]
Expand All @@ -63,7 +61,6 @@
# Adaptation to python by Pietro Quaglio and Emiliano Torre


@deprecated_alias(data='histogram', ximax='max_iterations')
def cubic(histogram, max_iterations=100, alpha=0.05):
r"""
Performs the CuBIC analysis :cite:`cubic-Staude2010_327` on a population
Expand Down
5 changes: 0 additions & 5 deletions elephant/current_source_density.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@

import elephant.current_source_density_src.utility_functions as utils
from elephant.current_source_density_src import KCSD, icsd
from elephant.utils import deprecated_alias

__all__ = [
"estimate_csd",
Expand All @@ -61,7 +60,6 @@
py_iCSD_toolbox = ['StandardCSD'] + icsd_methods


@deprecated_alias(coords='coordinates')
def estimate_csd(lfp, coordinates='coordinates', method=None,
process_estimate=True, **kwargs):
"""
Expand Down Expand Up @@ -209,9 +207,6 @@ def estimate_csd(lfp, coordinates='coordinates', method=None,
return output


@deprecated_alias(ele_xx='x_positions', ele_yy='y_positions',
ele_zz='z_positions', xlims='x_limits', ylims='y_limits',
zlims='z_limits', res='resolution')
def generate_lfp(csd_profile, x_positions, y_positions=None, z_positions=None,
x_limits=[0., 1.], y_limits=[0., 1.], z_limits=[0., 1.],
resolution=50):
Expand Down
18 changes: 4 additions & 14 deletions elephant/gpfa/gpfa.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,8 @@
import numpy as np
import quantities as pq
import sklearn
import warnings

from elephant.gpfa import gpfa_core, gpfa_util
from elephant.utils import deprecated_alias


__all__ = [
Expand Down Expand Up @@ -212,12 +210,10 @@ class GPFA(sklearn.base.BaseEstimator):
... n_channels = 20
... firing_rates = np.random.randint(low=1, high=100,
... size=n_channels) * pq.Hz
... spike_times = []
... for rate in firing_rates:
... spike_times.append(
... StationaryPoissonProcess(rate=rate).generate_spiketrain())
... data.append((trial, spike_times))
>>> spike_times = [StationaryPoissonProcess(rate
... ).generate_spiketrain() for rate in firing_rates]
>>> data.append((trial, spike_times))
...
>>> gpfa = GPFA(bin_size=20*pq.ms, x_dim=8)
>>> gpfa.fit(data) # doctest: +SKIP
>>> results = gpfa.transform(data, returned_data=['latent_variable_orth',
Expand All @@ -232,7 +228,6 @@ class GPFA(sklearn.base.BaseEstimator):
... 'latent_variable'])
"""

@deprecated_alias(binsize='bin_size')
def __init__(self, bin_size=20 * pq.ms, x_dim=3, min_var_frac=0.01,
tau_init=100.0 * pq.ms, eps_init=1.0E-3, em_tol=1.0E-8,
em_max_iters=500, freq_ll=5, verbose=False):
Expand Down Expand Up @@ -263,11 +258,6 @@ def __init__(self, bin_size=20 * pq.ms, x_dim=3, min_var_frac=0.01,
self.fit_info = dict()
self.transform_info = dict()

@property
def binsize(self):
warnings.warn("'binsize' is deprecated; use 'bin_size'")
return self.bin_size

def fit(self, spiketrains):
"""
Fit the model with the given training data.
Expand Down
2 changes: 0 additions & 2 deletions elephant/gpfa/gpfa_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
import scipy as sp

from elephant.conversion import BinnedSpikeTrain
from elephant.utils import deprecated_alias


@deprecated_alias(binsize='bin_size')
def get_seqs(data, bin_size, use_sqrt=True):
"""
Converts the data into a rec array using internally BinnedSpikeTrain.
Expand Down
Loading

0 comments on commit 2fa63bc

Please sign in to comment.