Skip to content

Commit

Permalink
Merge branch 'main' into add_tfr_weights
Browse files Browse the repository at this point in the history
  • Loading branch information
tsbinns authored Dec 14, 2024
2 parents 82dfab9 + bd4a160 commit 5b150aa
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 45 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ jobs:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
python: '3.13'
kind: pip
- os: ubuntu-latest
python: '3.12'
kind: pip-pre
Expand Down
3 changes: 2 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ stages:
python -m pip install --progress-bar off --upgrade pip
python -m pip install --progress-bar off --upgrade --pre --only-binary=\"numpy,scipy,matplotlib,vtk\" numpy scipy matplotlib vtk
python -c "import vtk"
python -m pip install --progress-bar off --upgrade -ve .[full,test_extra]
# Bug on 2.5.13 https://github.com/openmeeg/openmeeg/issues/700
python -m pip install --progress-bar off --upgrade -ve .[full,test_extra] "openmeeg==2.5.12"
displayName: 'Install dependencies with pip'
- bash: |
set -e
Expand Down
1 change: 1 addition & 0 deletions doc/changes/devel/13021.dependency.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Compatibility improved for Python 3.13, by `Eric Larson`_.
3 changes: 2 additions & 1 deletion mne/evoked.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,8 @@ def plot_topo(
exclude="bads",
show=True,
):
"""
""".
Notes
-----
.. versionadded:: 0.10.0
Expand Down
1 change: 1 addition & 0 deletions mne/tests/test_docstring_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def _func_name(func, cls=None):
error_ignores = {
# These we do not live by:
"GL01", # Docstring should start in the line immediately after the quotes
"GL02", # Closing quotes on own line (doesn't work on Python 3.13 anyway)
"EX01",
"EX02", # examples failed (we test them separately)
"ES01", # no extended summary
Expand Down
55 changes: 33 additions & 22 deletions mne/utils/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5121,6 +5121,8 @@ def copy_doc(source):
This is useful when inheriting from a class and overloading a method. This
decorator can be used to copy the docstring of the original method.
Docstrings are processed by :func:`python:inspect.cleandoc` before being used.
Parameters
----------
source : function
Expand All @@ -5143,15 +5145,16 @@ def copy_doc(source):
... ''' this gets appended'''
... pass
>>> print(B.m1.__doc__)
Docstring for m1 this gets appended
Docstring for m1
this gets appended
"""

def wrapper(func):
if source.__doc__ is None or len(source.__doc__) == 0:
raise ValueError("Cannot copy docstring: docstring was empty.")
doc = source.__doc__
if func.__doc__ is not None:
doc += func.__doc__
doc += f"\n{inspect.cleandoc(func.__doc__)}"
func.__doc__ = doc
return func

Expand All @@ -5170,6 +5173,10 @@ def copy_function_doc_to_method_doc(source):
function. This pattern is prevalent in for example the plotting functions
of MNE.
Docstrings are parsed by :func:`python:inspect.cleandoc` before being used.
If indentation and newlines are important, make the first line ``.``, and the dot
will be removed and all following lines dedented jointly.
Parameters
----------
source : function
Expand Down Expand Up @@ -5205,7 +5212,8 @@ def copy_function_doc_to_method_doc(source):
>>> class A:
... @copy_function_doc_to_method_doc(plot_function)
... def plot(self, a, b):
... '''
... '''.
...
... Notes
... -----
... .. versionadded:: 0.13.0
Expand All @@ -5214,26 +5222,31 @@ def copy_function_doc_to_method_doc(source):
>>> print(A.plot.__doc__)
Docstring for plotting function.
<BLANKLINE>
Parameters
----------
a : int
Some parameter
b : int
Some parameter
<BLANKLINE>
Notes
-----
.. versionadded:: 0.13.0
Parameters
----------
a : int
Some parameter
b : int
Some parameter
<BLANKLINE>
Notes
-----
.. versionadded:: 0.13.0
""" # noqa: D410, D411, D214, D215

def wrapper(func):
doc = source.__doc__.split("\n")
# Work with cleandoc'ed sources (py3.13-compat)
doc = inspect.cleandoc(source.__doc__).split("\n")
if func.__doc__ is not None:
func_doc = inspect.cleandoc(func.__doc__)
if func_doc[:2] == ".\n":
func_doc = func_doc[2:]
func_doc = f"\n{func_doc}"
else:
func_doc = ""

if len(doc) == 1:
doc = doc[0]
if func.__doc__ is not None:
doc += func.__doc__
func.__doc__ = doc
func.__doc__ = f"{doc[0]}{func_doc}"
return func

# Find parameter block
Expand Down Expand Up @@ -5281,7 +5294,7 @@ def wrapper(func):
break
else:
# End of docstring reached
first_parameter_end = line
first_parameter_end = line + 1
first_parameter = parameter_block

# Copy the docstring, but remove the first parameter
Expand All @@ -5290,9 +5303,7 @@ def wrapper(func):
+ "\n"
+ "\n".join(doc[first_parameter_end:])
)
if func.__doc__ is not None:
doc += func.__doc__
func.__doc__ = doc
func.__doc__ = f"{doc}{func_doc}"
return func

return wrapper
Expand Down
2 changes: 1 addition & 1 deletion mne/utils/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def test_sys_info_complete():
pyproject = tomllib.loads(pyproject.read_text("utf-8"))
deps = pyproject["project"]["optional-dependencies"]["test_extra"]
for dep in deps:
dep = dep.split("[")[0].split(">")[0]
dep = dep.split("[")[0].split(">")[0].strip()
assert f" {dep}" in out, f"Missing in dev config: {dep}"


Expand Down
31 changes: 16 additions & 15 deletions mne/utils/tests/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,28 +195,29 @@ def method_f3(self):

assert (
A.method_f1.__doc__
== """Docstring for f1.
Parameters
----------
a : int
Parameter a
b : int
Parameter b
"""
== """\
Docstring for f1.
Parameters
----------
a : int
Parameter a
b : int
Parameter b"""
)

assert (
A.method_f2.__doc__
== """Docstring for f2.
== """\
Docstring for f2.
Returns
-------
nothing.
method_f3 own docstring"""
Returns
-------
nothing.
method_f3 own docstring"""
)

assert A.method_f3.__doc__ == "Docstring for f3.\n\n "
assert A.method_f3.__doc__ == "Docstring for f3.\n\n"
pytest.raises(ValueError, copy_function_doc_to_method_doc(f5), A.method_f1)


Expand Down
2 changes: 1 addition & 1 deletion tools/azure_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
STD_ARGS="--progress-bar off --upgrade"
python -m pip install $STD_ARGS pip setuptools wheel
if [ "${TEST_MODE}" == "pip" ]; then
python -m pip install $STD_ARGS --only-binary="numba,llvmlite,numpy,scipy,vtk,dipy" -e .[test,full]
python -m pip install $STD_ARGS --only-binary="numba,llvmlite,numpy,scipy,vtk,dipy,openmeeg" -e .[test,full] "openmeeg==2.5.12"
elif [ "${TEST_MODE}" == "pip-pre" ]; then
${SCRIPT_DIR}/install_pre_requirements.sh
python -m pip install $STD_ARGS --pre -e .[test_extra]
Expand Down
2 changes: 1 addition & 1 deletion tools/circleci_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ python -m pip install --upgrade --progress-bar off \
mne-icalabel mne-lsl mne-microstates mne-nirs mne-rsa \
neurodsp neurokit2 niseq nitime openneuro-py pactools \
plotly pycrostates pyprep pyriemann python-picard sesameeg \
sleepecg tensorpac yasa meegkit
sleepecg tensorpac yasa meegkit eeg_positions
5 changes: 5 additions & 0 deletions tools/github_actions_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ if [ ! -z "$CONDA_ENV" ]; then
INSTALL_KIND="test"
STD_ARGS="--progress-bar off"
fi
elif [[ "${MNE_CI_KIND}" == "pip" ]]; then
# Only used for 3.13 at the moment, just get test deps plus a few extras
# that we know are available
INSTALL_ARGS="nibabel scikit-learn numpydoc PySide6 mne-qt-browser"
INSTALL_KIND="test"
else
test "${MNE_CI_KIND}" == "pip-pre"
STD_ARGS="$STD_ARGS --pre"
Expand Down
10 changes: 7 additions & 3 deletions tools/github_actions_env_vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ set -eo pipefail -x
# old and minimal use conda
if [[ "$MNE_CI_KIND" == "pip"* ]]; then
echo "Setting pip env vars for $MNE_CI_KIND"
echo "MNE_QT_BACKEND=PyQt6" >> $GITHUB_ENV
# We should test an eager import somewhere, might as well be here
echo "EAGER_IMPORT=true" >> $GITHUB_ENV
if [[ "$MNE_CI_KIND" == "pip-pre" ]]; then
echo "MNE_QT_BACKEND=PyQt6" >> $GITHUB_ENV
# We should test an eager import somewhere, might as well be here
echo "EAGER_IMPORT=true" >> $GITHUB_ENV
else
echo "MNE_QT_BACKEND=PySide6" >> $GITHUB_ENV
fi
else # conda-like
echo "Setting conda env vars for $MNE_CI_KIND"
if [[ "$MNE_CI_KIND" == "old" ]]; then
Expand Down

0 comments on commit 5b150aa

Please sign in to comment.