Skip to content

Commit

Permalink
[MAINT] Upgrade from Python 3.9 to 3.10 (mne-tools#228)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
tsbinns and pre-commit-ci[bot] authored Aug 20, 2024
1 parent 5f2a38d commit 9846729
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 30 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/linux_conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
# Linux
job:
timeout-minutes: 90
name: 'py3.9'
name: 'py3.10'
runs-on: ubuntu-20.04
defaults:
run:
Expand All @@ -23,7 +23,7 @@ jobs:
MNE_LOGGING_LEVEL: 'warning'
MKL_NUM_THREADS: '1'
PYTHONUNBUFFERED: '1'
PYTHON_VERSION: '3.9'
PYTHON_VERSION: '3.10'
steps:
- uses: actions/checkout@v4
- uses: pyvista/setup-headless-display-action@main
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
matrix:
include:
- os: ubuntu-latest
python-version: "3.9"
python-version: "3.10"
mne-version: mne-main
- os: ubuntu-latest
python-version: "3.12"
Expand Down
4 changes: 2 additions & 2 deletions doc/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Dependencies
* ``netCDF4`` (>=1.6.5)
* ``matplotlib`` (optional, for using the interactive data inspector)

We require that you use Python 3.9 or higher.
We require that you use Python 3.10 or higher.
You may choose to install ``mne-connectivity`` `via pip <#Installation via pip>`_,
or conda.

Expand All @@ -27,7 +27,7 @@ simply run the following at the root of the repository:

.. code-block:: bash
# with python>=3.9 at least
# with python>=3.10 at least
conda create -n mne
conda activate mne
conda install -c conda-forge mne-connectivity
Expand Down
4 changes: 2 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: mne-connectivity
channels:
- conda-forge
dependencies:
- python>=3.8
- python>=3.10
- pip
- numpy
- scipy
Expand All @@ -20,6 +20,6 @@ dependencies:
- pyvista>=0.32,!=0.35.2,!=0.38.0,!=0.38.1,!=0.38.2,!=0.38.3,!=0.38.4,!=0.38.5
- pyvistaqt>=0.4
- qtpy
- mne-base>=1.3
- mne-base>=1.6
- h5netcdf
- pyside6
13 changes: 6 additions & 7 deletions mne_connectivity/decoding/decomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#
# License: BSD (3-clause)

from typing import Optional, Union

import numpy as np
from mne import Info
Expand Down Expand Up @@ -81,12 +80,12 @@ class CoherencyDecomposition(BaseEstimator, TransformerMixin):
.. footbibliography::
"""

filters_: Optional[tuple] = None
patterns_: Optional[tuple] = None
filters_: tuple | None = None
patterns_: tuple | None = None

_conn_estimator: Optional[Union[_CaCohEst, _MICEst]] = None
_indices: Optional[tuple] = None
_rank: Optional[tuple] = None
_conn_estimator: _CaCohEst | _MICEst | None = None
_indices: tuple | None = None
_rank: tuple | None = None

@property
def indices(self):
Expand Down Expand Up @@ -199,7 +198,7 @@ def __init__(
"`cwt_n_cycles`",
"int, float, or array-like",
)
if isinstance(cwt_n_cycles, (tuple, list, np.ndarray)) and len(
if isinstance(cwt_n_cycles, tuple | list | np.ndarray) and len(
cwt_n_cycles
) != len(cwt_freqs):
raise ValueError(
Expand Down
10 changes: 5 additions & 5 deletions mne_connectivity/spectral/epochs.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ def _get_n_epochs(epochs, n):
"""Generate lists with at most n epochs."""
epochs_out = list()
for epoch in epochs:
if not isinstance(epoch, (list, tuple)):
if not isinstance(epoch, list | tuple):
epoch = (epoch,)
epochs_out.append(epoch)
if len(epochs_out) >= n:
Expand Down Expand Up @@ -620,7 +620,7 @@ def _get_and_verify_data_sizes(
data, sfreq, n_signals=None, n_times=None, times=None, warn_times=True
):
"""Get and/or verify the data sizes and time scales."""
if not isinstance(data, (list, tuple)):
if not isinstance(data, list | tuple):
raise ValueError("data has to be a list or tuple")
n_signals_tot = 0
# Sometimes data can be (ndarray, SourceEstimate) groups so in the case
Expand Down Expand Up @@ -1076,7 +1076,7 @@ def spectral_connectivity_epochs(
n_bands = len(fmin)

# assign names to connectivity methods
if not isinstance(method, (list, tuple)):
if not isinstance(method, list | tuple):
method = [method] # make it a list so we can iterate over it

if n_bands != 1 and any(this_method in _gc_methods for this_method in method):
Expand Down Expand Up @@ -1105,7 +1105,7 @@ def spectral_connectivity_epochs(
weights = None
metadata = None
spectrum_computed = False
if isinstance(data, (BaseEpochs, EpochsSpectrum, EpochsSpectrumArray)):
if isinstance(data, BaseEpochs | EpochsSpectrum | EpochsSpectrumArray):
names = data.ch_names
sfreq = data.info["sfreq"]

Expand All @@ -1126,7 +1126,7 @@ def spectral_connectivity_epochs(
data.add_annotations_to_metadata(overwrite=True)
metadata = data.metadata

if isinstance(data, (EpochsSpectrum, EpochsSpectrumArray)):
if isinstance(data, EpochsSpectrum | EpochsSpectrumArray):
# XXX: Will need to be updated if new Spectrum methods are added
if not np.iscomplexobj(data.get_data()):
raise TypeError(
Expand Down
5 changes: 2 additions & 3 deletions mne_connectivity/spectral/epochs_multivariate.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import copy
import inspect
from typing import Optional

import numpy as np
from mne.epochs import BaseEpochs
Expand All @@ -33,7 +32,7 @@ def _check_rank_input(rank, data, indices):
if "copy" in inspect.getfullargspec(data.get_data).kwonlyargs:
kwargs["copy"] = False
data_arr = data.get_data(**kwargs)
elif isinstance(data, (EpochsSpectrum, EpochsSpectrumArray)):
elif isinstance(data, EpochsSpectrum | EpochsSpectrumArray):
# Spectrum objs will drop bad channels, so specify picking all channels
data_arr = data.get_data(picks=np.arange(data.info["nchan"]))
# Convert to power (and aggregate over tapers) before computing rank
Expand Down Expand Up @@ -241,7 +240,7 @@ class _MultivariateCohEstBase(_EpochMeanMultivariateConEstBase):
(2019). NeuroImage. DOI: 10.1016/j.neuroimage.2019.116009
"""

name: Optional[str] = None
name: str | None = None
accumulate_psd = False

def __init__(
Expand Down
8 changes: 4 additions & 4 deletions mne_connectivity/spectral/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,11 +442,11 @@ def spectral_connectivity_time(
multivariate_con = False

# convert kernel width in time to samples
if isinstance(sm_times, (int, float)):
if isinstance(sm_times, int | float):
sm_times = int(np.round(sm_times * sfreq))

# convert frequency smoothing from hz to samples
if isinstance(sm_freqs, (int, float)):
if isinstance(sm_freqs, int | float):
sm_freqs = int(np.round(max(sm_freqs, 1)))

# temporal decimation
Expand Down Expand Up @@ -529,7 +529,7 @@ def spectral_connectivity_time(
gc_n_lags = None

# check freqs
if isinstance(freqs, (int, float)):
if isinstance(freqs, int | float):
freqs = [freqs]
# array conversion
freqs = np.asarray(freqs)
Expand Down Expand Up @@ -812,7 +812,7 @@ def _spectral_connectivity(
n_jobs=n_jobs,
**kw_mt,
)
if isinstance(n_cycles, (int, float)):
if isinstance(n_cycles, int | float):
n_cycles = [n_cycles] * len(freqs)
mt_bandwidth = mt_bandwidth if mt_bandwidth else 4
n_tapers = int(np.floor(mt_bandwidth - 1))
Expand Down
4 changes: 2 additions & 2 deletions mne_connectivity/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def check_indices(indices):
)

if any(
isinstance(inds, (np.ndarray, list, tuple))
isinstance(inds, np.ndarray | list | tuple)
for inds in [*indices[0], *indices[1]]
):
raise TypeError("Channel indices must be integers, not array-likes")
Expand Down Expand Up @@ -158,7 +158,7 @@ def _check_multivariate_indices(indices, n_chans):
max_n_chans = 0
for group_idx, group in enumerate(indices):
for con_idx, con in enumerate(group):
if not isinstance(con, (np.ndarray, list, tuple)):
if not isinstance(con, np.ndarray | list | tuple):
raise TypeError(
"multivariate indices must contain array-likes of channel indices "
"for each seed and target"
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ classifiers = [
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.9',
'Topic :: Scientific/Engineering',
'Topic :: Software Development',
]
Expand Down Expand Up @@ -43,7 +42,7 @@ maintainers = [
]
name = 'mne-connectivity'
readme = {content-type = "text/x-rst", file = 'README.rst'}
requires-python = '>=3.9'
requires-python = '>=3.10'

[project.optional-dependencies]
all = [
Expand Down

0 comments on commit 9846729

Please sign in to comment.