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

Add type hints to EpochsArray constructor and BaseRaw.get_data() #12740

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion mne/io/array/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
# License: BSD-3-Clause
# Copyright the MNE-Python contributors.

from __future__ import annotations

from typing import Literal

import numpy as np
from numpy.typing import NDArray

from ..._fiff.meas_info import Info
from ...utils import _check_option, _validate_type, fill_doc, logger, verbose
from ..base import BaseRaw

Expand Down Expand Up @@ -52,7 +58,14 @@ class RawArray(BaseRaw):
"""

@verbose
def __init__(self, data, info, first_samp=0, copy="auto", verbose=None):
def __init__(
self,
data: NDArray[np.float64],
info: Info,
first_samp: int = 0,
copy: Literal["data", "info", "both", "auto"] | None = "auto",
verbose=None,
):
_validate_type(info, "info", "info")
_check_option("copy", copy, ("data", "info", "both", "auto", None))
dtype = np.complex128 if np.any(np.iscomplex(data)) else np.float64
Expand Down
8 changes: 6 additions & 2 deletions mne/io/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
# License: BSD-3-Clause
# Copyright the MNE-Python contributors.

from __future__ import annotations

import os
import os.path as op
import shutil
Expand All @@ -22,11 +24,13 @@
from pathlib import Path

import numpy as np
from numpy.typing import NDArray

from .._fiff.compensator import make_compensator, set_current_comp
from .._fiff.constants import FIFF
from .._fiff.meas_info import (
ContainsMixin,
Info,
SetChannelsMixin,
_ensure_infos_match,
_unit2human,
Expand Down Expand Up @@ -194,7 +198,7 @@ class BaseRaw(
@verbose
def __init__(
self,
info,
info: Info,
preload=False,
first_samps=(0,),
last_samps=None,
Expand Down Expand Up @@ -890,7 +894,7 @@ def get_data(
tmin=None,
tmax=None,
verbose=None,
):
) -> NDArray[np.float64] | tuple[NDArray[np.float64], NDArray[np.float64]]:
"""Get data in the given range.

Parameters
Expand Down
Loading