Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Three doctests fail with Python 3.13 #13013

Closed
penguinpee opened this issue Dec 7, 2024 · 1 comment · Fixed by #13021
Closed

Three doctests fail with Python 3.13 #13013

penguinpee opened this issue Dec 7, 2024 · 1 comment · Fixed by #13021
Labels
Milestone

Comments

@penguinpee
Copy link

Description of the problem

While updating MNE to version 1.8.0 for Fedora, I ran into three failing tests using Python 3.13 - the default in Fedora 41+.

Those tests succeed when run with Python 3.12.

Steps to reproduce

python3.13 -m pytest -v -m 'not (slowtest or pgtest)' -W ignore::DeprecationWarning

Link to data

No response

Expected results

Tests succeed regardless of Python version. Python 3.13 has officially launched now. I noticed that it has not been added to the CI matrix yet.

Actual results

=================================== FAILURES ===================================
______________________ [doctest] mne.utils.docs.copy_doc _______________________
5093 >>> class A:
5094 ...     def m1():
5095 ...         '''Docstring for m1'''
5096 ...         pass
5097 >>> class B (A):
5098 ...     @copy_doc(A.m1)
5099 ...     def m1():
5100 ...         ''' this gets appended'''
5101 ...         pass
5102 >>> print(B.m1.__doc__)
Expected:
    Docstring for m1 this gets appended
Got:
    Docstring for m1this gets appended
/builddir/build/BUILD/python-mne-1.8.0-build/mne-python-1.8.0/mne/utils/docs.py:5102: DocTestFailure
___________ [doctest] mne.utils.docs.copy_function_doc_to_method_doc ___________
5162 >>> class A:
5163 ...     @copy_function_doc_to_method_doc(plot_function)
5164 ...     def plot(self, a, b):
5165 ...         '''
5166 ...         Notes
5167 ...         -----
5168 ...         .. versionadded:: 0.13.0
5169 ...         '''
5170 ...         plot_function(self, a, b)
5171 >>> print(A.plot.__doc__)
Differences (unified diff with -expected +actual):
    @@ -1,13 +1,13 @@
     Docstring for plotting function.
     <BLANKLINE>
    -    Parameters
    -    ----------
    -    a : int
    -        Some parameter
    -    b : int
    -        Some parameter
    +Parameters
    +----------
    +a : int
    +    Some parameter
    +b : int
    +    Some parameter
     <BLANKLINE>
    -        Notes
    -        -----
    -        .. versionadded:: 0.13.0
    +Notes
    +-----
    +.. versionadded:: 0.13.0
     <BLANKLINE>
/builddir/build/BUILD/python-mne-1.8.0-build/mne-python-1.8.0/mne/utils/docs.py:5171: DocTestFailure
_____________________ test_copy_function_doc_to_method_doc _____________________
mne/utils/tests/test_docs.py:196: in test_copy_function_doc_to_method_doc
    assert (
E   AssertionError: assert 'Docstring fo...Parameter b\n' == 'Docstring fo...r b\n        '
E     
E       Docstring for f1.
E       
E     + Parameters
E     + ----------
E     + a : int
E     -         Parameters...
E     
E     ...Full output truncated (12 lines hidden), use '-vv' to show

Additional information

Platform Linux-6.11.7-100.fc39.x86_64-x86_64-with-glibc2.40.9000
Python 3.13.0 (main, Oct 8 2024, 00:00:00) [GCC 14.2.1 20240912 (Red Hat 14.2.1-4)]
Executable /usr/bin/python3
CPU (8 cores)
Memory Unavailable (requires "psutil" package)
Core
├☑ mne 1.8.0 (unable to check for latest version on GitHub, unknown error: <urlopen error [Errno -3] Temporary failure in name resolution>)
├☑ numpy 1.26.4 (OpenBLAS 0.3.28 with 8 threads)
├☑ scipy 1.14.1
└☑ matplotlib 3.9.1 (backend=agg)

Numerical (optional)
├☑ sklearn 1.5.2
├☑ nibabel 5.3.2
├☑ nilearn 0.11.0
├☑ dipy 1.9.0
├☑ pandas 2.2.1
├☑ h5io 0.2.4
├☑ h5py 3.12.1
└☐ unavailable numba, openmeeg, cupy

Visualization (optional)
├☑ vtk 9.2.6
└☐ unavailable pyvista, pyvistaqt, qtpy, ipympl, pyqtgraph, mne-qt-browser, ipywidgets, trame_client, trame_server, trame_vtk, trame_vuetify

Ecosystem (optional)
└☐ unavailable mne-bids, mne-nirs, mne-features, mne-connectivity, mne-icalabel, mne-bids-pipeline, neo, eeglabio, edfio, mffpy, pybv

@penguinpee penguinpee added the BUG label Dec 7, 2024
@musicinmybrain
Copy link
Contributor

These failures appear to be because docstrings differ (in Python 3.13) from their expected values due to “Automatically dedent docstring constants by default,” python/cpython#81283.

@larsoner larsoner modified the milestones: 1.10, 1.9 Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants