1himan
(1himan)
March 6, 2026, 9:19am
1
Would it be better to add ArrayLike from Typing (numpy.typing) — NumPy v2.4 Manual
Probably in the conf.py file under mne-python/doc/conf.py at 219e8a16f993b7ed6b0b453d41d38750a4cea3f8 · mne-tools/mne-python · GitHub - for better type hinting.
I see that we currently have array-like which can’t be used for type hint and it only used for documenting purposes. When I try to use ArrayLike in function definitions(something like this):
def score_sources(
self,
inst: BaseRaw | BaseEpochs | Evoked,
target: ArrayLike | str | None = None,
score_func: Callable[..., float] | str = "pearsonr",
start: int | float | None = None,
stop: int | float | None = None,
l_freq: float | None = None,
h_freq: float | None = None,
reject_by_annotation: bool = True,
verbose: bool | str | int | None = None,
):
.
.
.
rest of the function
Then building documentation throws errors:
writing output... [100%] sg_api_usage
/home/himan/projects/mne-python-issue13597/mne/preprocessing/ica.py:docstring of mne.preprocessing.ica.ICA
:128: WARNING: py:class reference target not found: numpy:typing.ArrayLike [ref.class]
<unknown>:1: WARNING: py:class reference target not found: numpy._typing.ArrayLike [ref.class]
<unknown>:1: WARNING: py:class reference target not found: numpy._typing.ArrayLike [ref.class]
<unknown>:1: WARNING: py:class reference target not found: numpy._typing.ArrayLike [ref.class]
richard
(Richard Höchenberger)
March 6, 2026, 8:11pm
2
Hi, I appreciate adding type hints everywhere. If you could get the documentation to build, that’d be great.
Best wishes,
Richard
drammock
(Dan McCloy)
March 9, 2026, 3:01pm
3
I’d say: look and see how they’re doing it in NumPy, SciPy, and matplotlib, and emulate.
EDIT sorry, I misread the question, I see you’re proposing to adopt NumPy’s solution. +1
1himan
(1himan)
March 10, 2026, 10:16am
4
Do anyone have any idea that why this error occurs? Any possible idea?
writing output... [100%] sg_execution_times
<unknown>:1: WARNING: py:class reference target not found: numpy._typing.ArrayLike [ref.class]
<unknown>:1: WARNING: py:class reference target not found: numpy._typing.ArrayLike [ref.class]
<unknown>:1: WARNING: py:class reference target not found: numpy._typing.ArrayLike [ref.class]
I just added a typehint in the preprocessing/ica.py file, something like this:
def score_sources(
self,
inst: BaseRaw | BaseEpochs | Evoked,
target: ArrayLike | str | None = None,
score_func: Callable[..., float] | str = "pearsonr",
start: int | float | None = None,
stop: int | float | None = None,
l_freq: float | None = None,
h_freq: float | None = None,
reject_by_annotation: bool = True,
verbose: bool | str | int | None = None,
):
And from then on I’m getting this error, when I build the docs using the make html-noplot command
1himan
(1himan)
March 10, 2026, 10:18am
5
Even after adding this in conf.py file, under the numpydoc_xref_aliases:
"ArrayLike": ":ref:`ArrayLike <numpy:typing.ArrayLike>`", - I get the same error.
richard
(Richard Höchenberger)
March 10, 2026, 11:30am
6
Hi, could you provide your changes in a draft PR, and what exactly needs to be run to reproduce this? This would make it easier for others to take a look. Thanks!
Also I believe this discussion is better suited for GitHub anyway
1himan
(1himan)
March 10, 2026, 12:51pm
7
here it is - GitHub - 1himan/mne-python at fix#13597 · GitHub
Till then I’ll look into the detes too.
In short the main concern was to add better type hints in the ica.py file, but adding ArrayLike from np.typing.ArraLike to the functions, causes doc build errors. Sphinx is unable to parse this, or maybe that’s a numpydoc issue.
Thanks in advance sir!!!