Skip to content

Commit

Permalink
add docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
wmvanvliet committed Jan 7, 2025
1 parent 35437db commit 035726e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
13 changes: 13 additions & 0 deletions mne/fixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,3 +720,16 @@ def minimum_phase(h, method="homomorphic", n_fft=None, *, half=True):

n_out = (n_half + len(h) % 2) if half else len(h)
return h_minimum[:n_out]


# SciPy 1.15 deprecates sph_harm for sph_harm_y and using it will trigger a
# DeprecationWarning. This is a backport of the new function for older SciPy versions.
def sph_harm_y(n, m, theta, phi, *, diff_n=0):
"""Wrap scipy.special.sph_harm for sph_harm_y."""
# Can be removed once we no longer support scipy < 1.15.0
from scipy import special

if "sph_harm_y" in special.__dict__:
return special.sph_harm_y(n, m, theta, phi, diff_n=diff_n)
else:
return special.sph_harm(m, n, phi, theta)
4 changes: 2 additions & 2 deletions mne/preprocessing/maxwell.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import numpy as np
from scipy import linalg
from scipy.special import lpmv, sph_harm_y
from scipy.special import lpmv

from .. import __version__
from .._fiff.compensator import make_compensator
Expand All @@ -24,7 +24,7 @@
from ..annotations import _annotations_starts_stops
from ..bem import _check_origin
from ..channels.channels import _get_T1T2_mag_inds, fix_mag_coil_types
from ..fixes import _safe_svd, bincount
from ..fixes import _safe_svd, bincount, sph_harm_y
from ..forward import _concatenate_coils, _create_meg_coils, _prep_meg_channels
from ..io import BaseRaw, RawArray
from ..surface import _normalize_vectors
Expand Down
2 changes: 1 addition & 1 deletion mne/preprocessing/tests/test_maxwell.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
import pytest
from numpy.testing import assert_allclose, assert_array_equal
from scipy import sparse
from scipy.special import sph_harm_y

import mne
from mne import compute_raw_covariance, concatenate_raws, pick_info, pick_types
from mne._fiff.constants import FIFF
from mne.annotations import _annotations_starts_stops
from mne.chpi import filter_chpi, read_head_pos
from mne.datasets import testing
from mne.fixes import sph_harm_y
from mne.forward import _prep_meg_channels, use_coil_def
from mne.io import (
BaseRaw,
Expand Down
3 changes: 1 addition & 2 deletions mne/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
import numpy as np
from scipy import linalg
from scipy.spatial.distance import cdist
from scipy.special import sph_harm_y

from ._fiff.constants import FIFF
from ._fiff.open import fiff_open
from ._fiff.tag import read_tag
from ._fiff.write import start_and_end_file, write_coord_trans
from .defaults import _handle_default
from .fixes import _get_img_fdata, jit
from .fixes import _get_img_fdata, jit, sph_harm_y
from .utils import (
_check_fname,
_check_option,
Expand Down

0 comments on commit 035726e

Please sign in to comment.