From 5e3b810801568e4d390f1c73997b5fc14703f5aa Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 16 Jan 2024 03:11:33 +0000 Subject: [PATCH] deploy stub files [ci skip] --- pycrostates/_typing.pyi | 3 +- pycrostates/cluster/_base.pyi | 116 +++--------------- pycrostates/cluster/aahc.pyi | 38 ++---- pycrostates/cluster/kmeans.pyi | 48 ++------ pycrostates/cluster/utils/utils.pyi | 10 +- pycrostates/datasets/lemon/lemon.pyi | 2 +- pycrostates/io/ch_data.pyi | 45 +++---- pycrostates/io/fiff.pyi | 40 +----- pycrostates/io/meas_info.pyi | 19 +-- pycrostates/io/reader.pyi | 2 +- pycrostates/metrics/calinski_harabasz.pyi | 2 +- pycrostates/metrics/davies_bouldin.pyi | 2 +- pycrostates/metrics/dunn.pyi | 7 +- pycrostates/metrics/silhouette.pyi | 2 +- .../preprocessing/extract_gfp_peaks.pyi | 19 +-- pycrostates/preprocessing/resample.pyi | 32 ++--- pycrostates/preprocessing/spatial_filter.pyi | 13 +- pycrostates/segmentation/_base.pyi | 42 +++---- pycrostates/segmentation/segmentation.pyi | 32 ++--- pycrostates/segmentation/transitions.pyi | 34 ++--- pycrostates/utils/_checks.pyi | 22 ++-- pycrostates/utils/_config.pyi | 3 +- pycrostates/utils/_docs.pyi | 2 +- pycrostates/utils/_fixes.pyi | 3 +- pycrostates/utils/_imports.pyi | 4 +- pycrostates/utils/_logs.pyi | 32 +++-- pycrostates/utils/mixin.pyi | 8 +- pycrostates/utils/sys_info.pyi | 8 +- pycrostates/utils/utils.pyi | 6 +- pycrostates/viz/cluster_centers.pyi | 15 +-- pycrostates/viz/segmentation.pyi | 46 +------ 31 files changed, 188 insertions(+), 469 deletions(-) diff --git a/pycrostates/_typing.pyi b/pycrostates/_typing.pyi index 7417a49c..52aeca59 100644 --- a/pycrostates/_typing.pyi +++ b/pycrostates/_typing.pyi @@ -15,6 +15,5 @@ class Cluster(ABC): class Segmentation(ABC): """Typing for a clustering class.""" - RANDomState = Optional[Union[int, RandomState, Generator]] -Picks = Optional[Union[str, NDArray[int]]] +Picks = Optional[Union[str, NDArray[int]]] \ No newline at end of file diff --git a/pycrostates/cluster/_base.pyi b/pycrostates/cluster/_base.pyi index ee4bf7f0..8ca0bbbc 100644 --- a/pycrostates/cluster/_base.pyi +++ b/pycrostates/cluster/_base.pyi @@ -28,7 +28,6 @@ from .utils import optimize_order as optimize_order class _BaseCluster(Cluster, ChannelsMixin, ContainsMixin, MontageMixin): """Base Class for Microstates Clustering algorithms.""" - _n_clusters: Incomplete _cluster_names: Incomplete _cluster_centers_: Incomplete @@ -39,11 +38,13 @@ class _BaseCluster(Cluster, ChannelsMixin, ContainsMixin, MontageMixin): _fitted: bool @abstractmethod - def __init__(self): ... + def __init__(self): + ... + def __repr__(self) -> str: """String representation.""" - def _repr_html_(self, caption: Incomplete | None = None): + def _repr_html_(self, caption: Incomplete | None=None): """HTML representation.""" def __eq__(self, other: Any) -> bool: @@ -52,7 +53,7 @@ class _BaseCluster(Cluster, ChannelsMixin, ContainsMixin, MontageMixin): def __ne__(self, other: Any) -> bool: """Different != method.""" - def copy(self, deep: bool = True): + def copy(self, deep: bool=True): """Return a copy of the instance. Parameters @@ -68,16 +69,7 @@ class _BaseCluster(Cluster, ChannelsMixin, ContainsMixin, MontageMixin): """Check if the cluster is unfitted.""" @abstractmethod - def fit( - self, - inst: Union[BaseRaw, BaseEpochs, CHData], - picks: Picks = "eeg", - tmin: Optional[Union[int, float]] = None, - tmax: Optional[Union[int, float]] = None, - reject_by_annotation: bool = True, - *, - verbose: Optional[str] = None, - ) -> NDArray[float]: + def fit(self, inst: Union[BaseRaw, BaseEpochs, CHData], picks: Picks='eeg', tmin: Optional[Union[int, float]]=None, tmax: Optional[Union[int, float]]=None, reject_by_annotation: bool=True, *, verbose: Optional[str]=None) -> NDArray[float]: """Compute cluster centers. Parameters @@ -101,7 +93,7 @@ class _BaseCluster(Cluster, ChannelsMixin, ContainsMixin, MontageMixin): Whether to omit bad segments from the data before fitting. If ``True`` (default), annotated segments whose description begins with ``'bad'`` are omitted. If ``False``, no rejection based on annotations is performed. - + Has no effect if ``inst`` is not a :class:`mne.io.Raw` object. verbose : int | str | bool | None Sets the verbosity level. The verbosity increases gradually between ``"CRITICAL"``, @@ -110,11 +102,7 @@ class _BaseCluster(Cluster, ChannelsMixin, ContainsMixin, MontageMixin): ``"WARNING"`` for False and to ``"INFO"`` for True. """ - def rename_clusters( - self, - mapping: Optional[dict[str, str]] = None, - new_names: Optional[Union[list[str], tuple[str, ...]]] = None, - ) -> None: + def rename_clusters(self, mapping: Optional[dict[str, str]]=None, new_names: Optional[Union[list[str], tuple[str, ...]]]=None) -> None: """Rename the clusters. Parameters @@ -131,12 +119,7 @@ class _BaseCluster(Cluster, ChannelsMixin, ContainsMixin, MontageMixin): Operates in-place. """ - def reorder_clusters( - self, - mapping: Optional[dict[int, int]] = None, - order: Optional[Union[list[int], tuple[int, ...], NDArray[int]]] = None, - template: Optional[Cluster] = None, - ) -> None: + def reorder_clusters(self, mapping: Optional[dict[int, int]]=None, order: Optional[Union[list[int], tuple[int, ...], NDArray[int]]]=None, template: Optional[Cluster]=None) -> None: """ Reorder the clusters of the fitted model. @@ -166,9 +149,7 @@ class _BaseCluster(Cluster, ChannelsMixin, ContainsMixin, MontageMixin): Operates in-place. """ - def invert_polarity( - self, invert: Union[bool, list[bool], tuple[bool, ...], NDArray[bool]] - ) -> None: + def invert_polarity(self, invert: Union[bool, list[bool], tuple[bool, ...], NDArray[bool]]) -> None: """Invert map polarities. Parameters @@ -188,20 +169,7 @@ class _BaseCluster(Cluster, ChannelsMixin, ContainsMixin, MontageMixin): an article). """ - def plot( - self, - axes: Optional[Union[Axes, NDArray[Axes]]] = None, - show_gradient: Optional[bool] = False, - gradient_kwargs: dict[str, Any] = { - "color": "black", - "linestyle": "-", - "marker": "P", - }, - *, - block: bool = False, - verbose: Optional[str] = None, - **kwargs, - ): + def plot(self, axes: Optional[Union[Axes, NDArray[Axes]]]=None, show_gradient: Optional[bool]=False, gradient_kwargs: dict[str, Any]={'color': 'black', 'linestyle': '-', 'marker': 'P'}, *, block: bool=False, verbose: Optional[str]=None, **kwargs): """ Plot cluster centers as topographic maps. @@ -243,19 +211,7 @@ class _BaseCluster(Cluster, ChannelsMixin, ContainsMixin, MontageMixin): Path to the ``.fif`` file where the clustering solution is saved. """ - def predict( - self, - inst: Union[BaseRaw, BaseEpochs], - picks: Picks = None, - factor: int = 0, - half_window_size: int = 1, - tol: Union[int, float] = 1e-05, - min_segment_length: int = 0, - reject_edges: bool = True, - reject_by_annotation: bool = True, - *, - verbose: Optional[str] = None, - ): + def predict(self, inst: Union[BaseRaw, BaseEpochs], picks: Picks=None, factor: int=0, half_window_size: int=1, tol: Union[int, float]=1e-05, min_segment_length: int=0, reject_edges: bool=True, reject_by_annotation: bool=True, *, verbose: Optional[str]=None): """Segment `~mne.io.Raw` or `~mne.Epochs` into microstate sequence. Segment instance into microstate sequence using the segmentation smoothing @@ -293,7 +249,7 @@ class _BaseCluster(Cluster, ChannelsMixin, ContainsMixin, MontageMixin): Whether to omit bad segments from the data before fitting. If ``True`` (default), annotated segments whose description begins with ``'bad'`` are omitted. If ``False``, no rejection based on annotations is performed. - + Has no effect if ``inst`` is not a :class:`mne.io.Raw` object. verbose : int | str | bool | None Sets the verbosity level. The verbosity increases gradually between ``"CRITICAL"``, @@ -313,50 +269,18 @@ class _BaseCluster(Cluster, ChannelsMixin, ContainsMixin, MontageMixin): .. footbibliography:: """ - def _predict_raw( - self, - raw: BaseRaw, - picks_data: NDArray[int], - factor: int, - tol: Union[int, float], - half_window_size: int, - min_segment_length: int, - reject_edges: bool, - reject_by_annotation: bool, - ) -> RawSegmentation: + def _predict_raw(self, raw: BaseRaw, picks_data: NDArray[int], factor: int, tol: Union[int, float], half_window_size: int, min_segment_length: int, reject_edges: bool, reject_by_annotation: bool) -> RawSegmentation: """Create segmentation for raw.""" - def _predict_epochs( - self, - epochs: BaseEpochs, - picks_data: NDArray[int], - factor: int, - tol: Union[int, float], - half_window_size: int, - min_segment_length: int, - reject_edges: bool, - ) -> EpochsSegmentation: + def _predict_epochs(self, epochs: BaseEpochs, picks_data: NDArray[int], factor: int, tol: Union[int, float], half_window_size: int, min_segment_length: int, reject_edges: bool) -> EpochsSegmentation: """Create segmentation for epochs.""" @staticmethod - def _segment( - data: NDArray[float], - states: NDArray[float], - factor: int, - tol: Union[int, float], - half_window_size: int, - ) -> NDArray[int]: + def _segment(data: NDArray[float], states: NDArray[float], factor: int, tol: Union[int, float], half_window_size: int) -> NDArray[int]: """Create segmentation. Must operate on a copy of states.""" @staticmethod - def _smooth_segmentation( - data: NDArray[float], - states: NDArray[float], - labels: NDArray[int], - factor: int, - tol: Union[int, float], - half_window_size: int, - ) -> NDArray[int]: + def _smooth_segmentation(data: NDArray[float], states: NDArray[float], labels: NDArray[int], factor: int, tol: Union[int, float], half_window_size: int) -> NDArray[int]: """Apply smoothing. Adapted from [1]. @@ -372,9 +296,7 @@ class _BaseCluster(Cluster, ChannelsMixin, ContainsMixin, MontageMixin): """ @staticmethod - def _reject_short_segments( - segmentation: NDArray[int], data: NDArray[float], min_segment_length: int - ) -> NDArray[int]: + def _reject_short_segments(segmentation: NDArray[int], data: NDArray[float], min_segment_length: int) -> NDArray[int]: """Reject segments that are too short. Reject segments that are too short by replacing the labels with the adjacent @@ -452,4 +374,4 @@ class _BaseCluster(Cluster, ChannelsMixin, ContainsMixin, MontageMixin): @staticmethod def _check_n_clusters(n_clusters: int) -> int: - """Check that the number of clusters is a positive integer.""" + """Check that the number of clusters is a positive integer.""" \ No newline at end of file diff --git a/pycrostates/cluster/aahc.pyi b/pycrostates/cluster/aahc.pyi index 72f416f0..79d06077 100644 --- a/pycrostates/cluster/aahc.pyi +++ b/pycrostates/cluster/aahc.pyi @@ -30,15 +30,18 @@ class AAHCluster(_BaseCluster): ---------- .. footbibliography:: """ - _n_clusters: Incomplete _cluster_names: Incomplete _ignore_polarity: bool _normalize_input: Incomplete _GEV_: Incomplete - def __init__(self, n_clusters: int, normalize_input: bool = False) -> None: ... - def _repr_html_(self, caption: Incomplete | None = None): ... + def __init__(self, n_clusters: int, normalize_input: bool=False) -> None: + ... + + def _repr_html_(self, caption: Incomplete | None=None): + ... + def __eq__(self, other: Any) -> bool: """Equality == method.""" @@ -51,16 +54,7 @@ class AAHCluster(_BaseCluster): _labels_: Incomplete _fitted: bool - def fit( - self, - inst: Union[BaseRaw, BaseEpochs], - picks: Picks = "eeg", - tmin: Optional[Union[int, float]] = None, - tmax: Optional[Union[int, float]] = None, - reject_by_annotation: bool = True, - *, - verbose: Optional[str] = None, - ) -> None: + def fit(self, inst: Union[BaseRaw, BaseEpochs], picks: Picks='eeg', tmin: Optional[Union[int, float]]=None, tmax: Optional[Union[int, float]]=None, reject_by_annotation: bool=True, *, verbose: Optional[str]=None) -> None: """Compute cluster centers. Parameters @@ -84,7 +78,7 @@ class AAHCluster(_BaseCluster): Whether to omit bad segments from the data before fitting. If ``True`` (default), annotated segments whose description begins with ``'bad'`` are omitted. If ``False``, no rejection based on annotations is performed. - + Has no effect if ``inst`` is not a :class:`mne.io.Raw` object. verbose : int | str | bool | None Sets the verbosity level. The verbosity increases gradually between ``"CRITICAL"``, @@ -103,21 +97,11 @@ class AAHCluster(_BaseCluster): """ @staticmethod - def _aahc( - data: NDArray[float], - n_clusters: int, - ignore_polarity: bool, - normalize_input: bool, - ) -> tuple[float, NDArray[float], NDArray[int]]: + def _aahc(data: NDArray[float], n_clusters: int, ignore_polarity: bool, normalize_input: bool) -> tuple[float, NDArray[float], NDArray[int]]: """Run the AAHC algorithm.""" @staticmethod - def _compute_maps( - data: NDArray[float], - n_clusters: int, - ignore_polarity: bool, - normalize_input: bool, - ) -> tuple[NDArray[float], NDArray[int]]: + def _compute_maps(data: NDArray[float], n_clusters: int, ignore_polarity: bool, normalize_input: bool) -> tuple[NDArray[float], NDArray[int]]: """Compute microstates maps.""" @property @@ -147,4 +131,4 @@ class AAHCluster(_BaseCluster): @staticmethod def _check_normalize_input(normalize_input: bool) -> bool: - """Check that normalize_input is a boolean.""" + """Check that normalize_input is a boolean.""" \ No newline at end of file diff --git a/pycrostates/cluster/kmeans.pyi b/pycrostates/cluster/kmeans.pyi index 8d173412..6b65f95c 100644 --- a/pycrostates/cluster/kmeans.pyi +++ b/pycrostates/cluster/kmeans.pyi @@ -49,7 +49,6 @@ class ModKMeans(_BaseCluster): ---------- .. footbibliography:: """ - _n_clusters: Incomplete _cluster_names: Incomplete _n_init: Incomplete @@ -58,15 +57,12 @@ class ModKMeans(_BaseCluster): _random_state: Incomplete _GEV_: Incomplete - def __init__( - self, - n_clusters: int, - n_init: int = 100, - max_iter: int = 300, - tol: Union[int, float] = 1e-06, - random_state: RANDomState = None, - ) -> None: ... - def _repr_html_(self, caption: Incomplete | None = None): ... + def __init__(self, n_clusters: int, n_init: int=100, max_iter: int=300, tol: Union[int, float]=1e-06, random_state: RANDomState=None) -> None: + ... + + def _repr_html_(self, caption: Incomplete | None=None): + ... + def __eq__(self, other: Any) -> bool: """Equality == method.""" @@ -80,17 +76,7 @@ class ModKMeans(_BaseCluster): _fitted: bool _ignore_polarity: bool - def fit( - self, - inst: Union[BaseRaw, BaseEpochs, CHData], - picks: Picks = "eeg", - tmin: Optional[Union[int, float]] = None, - tmax: Optional[Union[int, float]] = None, - reject_by_annotation: bool = True, - n_jobs: int = 1, - *, - verbose: Optional[str] = None, - ) -> None: + def fit(self, inst: Union[BaseRaw, BaseEpochs, CHData], picks: Picks='eeg', tmin: Optional[Union[int, float]]=None, tmax: Optional[Union[int, float]]=None, reject_by_annotation: bool=True, n_jobs: int=1, *, verbose: Optional[str]=None) -> None: """Compute cluster centers. Parameters @@ -114,7 +100,7 @@ class ModKMeans(_BaseCluster): Whether to omit bad segments from the data before fitting. If ``True`` (default), annotated segments whose description begins with ``'bad'`` are omitted. If ``False``, no rejection based on annotations is performed. - + Has no effect if ``inst`` is not a :class:`mne.io.Raw` object. n_jobs : int | None The number of jobs to run in parallel. If ``-1``, it is set @@ -140,23 +126,11 @@ class ModKMeans(_BaseCluster): """ @staticmethod - def _kmeans( - data: NDArray[float], - n_clusters: int, - max_iter: int, - random_state: Union[RandomState, Generator], - tol: Union[int, float], - ) -> tuple[float, NDArray[float], NDArray[int], bool]: + def _kmeans(data: NDArray[float], n_clusters: int, max_iter: int, random_state: Union[RandomState, Generator], tol: Union[int, float]) -> tuple[float, NDArray[float], NDArray[int], bool]: """Run the k-means algorithm.""" @staticmethod - def _compute_maps( - data: NDArray[float], - n_clusters: int, - max_iter: int, - random_state: Union[RandomState, Generator], - tol: Union[int, float], - ) -> tuple[NDArray[float], bool]: + def _compute_maps(data: NDArray[float], n_clusters: int, max_iter: int, random_state: Union[RandomState, Generator], tol: Union[int, float]) -> tuple[NDArray[float], bool]: """Compute microstates maps. Based on mne_microstates by Marijn van Vliet @@ -215,4 +189,4 @@ class ModKMeans(_BaseCluster): @staticmethod def _check_tol(tol: Union[int, float]) -> Union[int, float]: - """Check that tol is a positive number.""" + """Check that tol is a positive number.""" \ No newline at end of file diff --git a/pycrostates/cluster/utils/utils.pyi b/pycrostates/cluster/utils/utils.pyi index 44a00fd8..c15ab1c7 100644 --- a/pycrostates/cluster/utils/utils.pyi +++ b/pycrostates/cluster/utils/utils.pyi @@ -4,11 +4,9 @@ from ..._typing import Cluster as Cluster from ...utils._checks import _check_type as _check_type from ...utils._docs import fill_doc as fill_doc -def _optimize_order( - centers: NDArray[float], - template_centers: NDArray[float], - ignore_polarity: bool = True, -): ... +def _optimize_order(centers: NDArray[float], template_centers: NDArray[float], ignore_polarity: bool=True): + ... + def optimize_order(inst: Cluster, template_inst: Cluster): """Optimize the order of cluster centers between two cluster instances. @@ -28,4 +26,4 @@ def optimize_order(inst: Cluster, template_inst: Cluster): ------- order : list of int The new order to apply to inst to maximize auto-correlation of cluster centers. - """ + """ \ No newline at end of file diff --git a/pycrostates/datasets/lemon/lemon.pyi b/pycrostates/datasets/lemon/lemon.pyi index c9be379d..61ba39ca 100644 --- a/pycrostates/datasets/lemon/lemon.pyi +++ b/pycrostates/datasets/lemon/lemon.pyi @@ -68,4 +68,4 @@ def standardize(raw: BaseRaw): If you don't want to interpolate missing channels, you can use :func:`mne.channels.equalize_channels` instead to have the same electrodes across different recordings. - """ + """ \ No newline at end of file diff --git a/pycrostates/io/ch_data.pyi b/pycrostates/io/ch_data.pyi index d1dd8332..d920412f 100644 --- a/pycrostates/io/ch_data.pyi +++ b/pycrostates/io/ch_data.pyi @@ -27,15 +27,16 @@ class ChData(CHData, ChannelsMixin, ContainsMixin, MontageMixin): Atemporal measurement information. If a `mne.Info` is provided, it is converted to a `~pycrostates.io.ChInfo`. """ - _data: Incomplete _info: Incomplete - def __init__(self, data: NDArray[float], info: Union[Info, CHInfo]) -> None: ... + def __init__(self, data: NDArray[float], info: Union[Info, CHInfo]) -> None: + ... + def __repr__(self) -> str: """String representation.""" - def _repr_html_(self, caption: Incomplete | None = None): + def _repr_html_(self, caption: Incomplete | None=None): """HTML representation.""" def __eq__(self, other: Any) -> bool: @@ -44,7 +45,7 @@ class ChData(CHData, ChannelsMixin, ContainsMixin, MontageMixin): def __ne__(self, other: Any) -> bool: """Different != method.""" - def copy(self, deep: bool = True): + def copy(self, deep: bool=True): """Return a copy of the instance. Parameters @@ -53,19 +54,19 @@ class ChData(CHData, ChannelsMixin, ContainsMixin, MontageMixin): If True, `~copy.deepcopy` is used instead of `~copy.copy`. """ - def get_data(self, picks: Incomplete | None = None) -> NDArray[float]: + def get_data(self, picks: Incomplete | None=None) -> NDArray[float]: """Retrieve the data array. Parameters ---------- picks : str | array-like | slice | None - Channels to include. Slices and lists of integers will be interpreted as - channel indices. In lists, channel *type* strings (e.g., ``['meg', - 'eeg']``) will pick channels of those types, channel *name* strings (e.g., - ``['MEG0111', 'MEG2623']`` will pick the given channels. Can also be the - string values "all" to pick all channels, or "data" to pick :term:`data - channels`. None (default) will pick all channels. Note that channels in - ``info['bads']`` *will be included* if their names or indices are + Channels to include. Slices and lists of integers will be interpreted as + channel indices. In lists, channel *type* strings (e.g., ``['meg', + 'eeg']``) will pick channels of those types, channel *name* strings (e.g., + ``['MEG0111', 'MEG2623']`` will pick the given channels. Can also be the + string values "all" to pick all channels, or "data" to pick :term:`data + channels`. None (default) will pick all channels. Note that channels in + ``info['bads']`` *will be included* if their names or indices are explicitly provided. Returns @@ -74,19 +75,19 @@ class ChData(CHData, ChannelsMixin, ContainsMixin, MontageMixin): Data array of shape ``(n_channels, n_samples)``. """ - def pick(self, picks, exclude: str = "bads"): + def pick(self, picks, exclude: str='bads'): """Pick a subset of channels. Parameters ---------- picks : str | array-like | slice | None - Channels to include. Slices and lists of integers will be interpreted as - channel indices. In lists, channel *type* strings (e.g., ``['meg', - 'eeg']``) will pick channels of those types, channel *name* strings (e.g., - ``['MEG0111', 'MEG2623']`` will pick the given channels. Can also be the - string values "all" to pick all channels, or "data" to pick :term:`data - channels`. None (default) will pick all channels. Note that channels in - ``info['bads']`` *will be included* if their names or indices are + Channels to include. Slices and lists of integers will be interpreted as + channel indices. In lists, channel *type* strings (e.g., ``['meg', + 'eeg']``) will pick channels of those types, channel *name* strings (e.g., + ``['MEG0111', 'MEG2623']`` will pick the given channels. Can also be the + string values "all" to pick all channels, or "data" to pick :term:`data + channels`. None (default) will pick all channels. Note that channels in + ``info['bads']`` *will be included* if their names or indices are explicitly provided. exclude : list | str Set of channels to exclude, only used when picking based on types (e.g., @@ -98,7 +99,7 @@ class ChData(CHData, ChannelsMixin, ContainsMixin, MontageMixin): The instance modified in-place. """ - def _get_channel_positions(self, picks: Incomplete | None = None): + def _get_channel_positions(self, picks: Incomplete | None=None): """Get channel locations from info. Parameters @@ -125,4 +126,4 @@ class ChData(CHData, ChannelsMixin, ContainsMixin, MontageMixin): @property def preload(self): - """Preload required by some MNE functions.""" + """Preload required by some MNE functions.""" \ No newline at end of file diff --git a/pycrostates/io/fiff.pyi b/pycrostates/io/fiff.pyi index b3bacbaf..bc7bee9e 100644 --- a/pycrostates/io/fiff.pyi +++ b/pycrostates/io/fiff.pyi @@ -13,16 +13,7 @@ from ..utils._checks import _check_value as _check_value from ..utils._docs import fill_doc as fill_doc from ..utils._logs import logger as logger -def _write_cluster( - fname: Union[str, Path], - cluster_centers_: NDArray[float], - chinfo: Union[CHInfo, Info], - algorithm: str, - cluster_names: list[str], - fitted_data: NDArray[float], - labels_: NDArray[int], - **kwargs, -): +def _write_cluster(fname: Union[str, Path], cluster_centers_: NDArray[float], chinfo: Union[CHInfo, Info], algorithm: str, cluster_names: list[str], fitted_data: NDArray[float], labels_: NDArray[int], **kwargs): """Save clustering solution to disk. Parameters @@ -66,29 +57,10 @@ def _read_cluster(fname: Union[str, Path]): def _check_fit_parameters_and_variables(fit_parameters: dict, fit_variables: dict): """Check that we have all the keys we are looking for and return algo.""" -def _create_ModKMeans( - cluster_centers_: NDArray[float], - info: CHInfo, - cluster_names: list[str], - fitted_data: NDArray[float], - labels_: NDArray[int], - n_init: int, - max_iter: int, - tol: Union[int, float], - GEV_: float, -): +def _create_ModKMeans(cluster_centers_: NDArray[float], info: CHInfo, cluster_names: list[str], fitted_data: NDArray[float], labels_: NDArray[int], n_init: int, max_iter: int, tol: Union[int, float], GEV_: float): """Create a ModKMeans cluster.""" -def _create_AAHCluster( - cluster_centers_: NDArray[float], - info: CHInfo, - cluster_names: list[str], - fitted_data: NDArray[float], - labels_: NDArray[int], - ignore_polarity: bool, - normalize_input: bool, - GEV_: float, -): +def _create_AAHCluster(cluster_centers_: NDArray[float], info: CHInfo, cluster_names: list[str], fitted_data: NDArray[float], labels_: NDArray[int], ignore_polarity: bool, normalize_input: bool, GEV_: float): """Create a AAHCluster object.""" def _write_meas_info(fid, info: CHInfo): @@ -118,8 +90,8 @@ def _read_meas_info(fid, tree): Channel information instance. """ -def _serialize(dict_: dict, outer_sep: str = ";", inner_sep: str = ":"): +def _serialize(dict_: dict, outer_sep: str=';', inner_sep: str=':'): """Aux function.""" -def _deserialize(str_: str, outer_sep: str = ";", inner_sep: str = ":"): - """Aux Function.""" +def _deserialize(str_: str, outer_sep: str=';', inner_sep: str=':'): + """Aux Function.""" \ No newline at end of file diff --git a/pycrostates/io/meas_info.pyi b/pycrostates/io/meas_info.pyi index 73b9834b..2a9a9543 100644 --- a/pycrostates/io/meas_info.pyi +++ b/pycrostates/io/meas_info.pyi @@ -130,21 +130,14 @@ class ChInfo(CHInfo, Info): The coordinate frame used, e.g. ``FIFFV_COORD_HEAD``. """ - def __init__( - self, - info: Optional[Info] = None, - ch_names: Optional[Union[int, list[str], tuple[str, ...]]] = None, - ch_types: Optional[Union[str, list[str], tuple[str, ...]]] = None, - ) -> None: ... + def __init__(self, info: Optional[Info]=None, ch_names: Optional[Union[int, list[str], tuple[str, ...]]]=None, ch_types: Optional[Union[str, list[str], tuple[str, ...]]]=None) -> None: + ... + def _init_from_info(self, info: Info): """Init instance from mne Info.""" _unlocked: bool - def _init_from_channels( - self, - ch_names: Union[int, list[str], tuple[str, ...]], - ch_types: Union[str, list[str], tuple[str, ...]], - ): + def _init_from_channels(self, ch_names: Union[int, list[str], tuple[str, ...]], ch_types: Union[str, list[str], tuple[str, ...]]): """Init instance from channel names and types.""" def __getattribute__(self, name): @@ -159,5 +152,5 @@ class ChInfo(CHInfo, Info): def __deepcopy__(self, memodict): """Make a deepcopy.""" - def _check_consistency(self, prepend_error: str = ""): - """Do some self-consistency checks and datatype tweaks.""" + def _check_consistency(self, prepend_error: str=''): + """Do some self-consistency checks and datatype tweaks.""" \ No newline at end of file diff --git a/pycrostates/io/reader.pyi b/pycrostates/io/reader.pyi index b39bab4b..029be484 100644 --- a/pycrostates/io/reader.pyi +++ b/pycrostates/io/reader.pyi @@ -17,4 +17,4 @@ def read_cluster(fname: Union[str, Path]): ------- cluster : :ref:`Clustering` Fitted clustering instance. - """ + """ \ No newline at end of file diff --git a/pycrostates/metrics/calinski_harabasz.pyi b/pycrostates/metrics/calinski_harabasz.pyi index 1e3c5cd4..f7aa9ea6 100644 --- a/pycrostates/metrics/calinski_harabasz.pyi +++ b/pycrostates/metrics/calinski_harabasz.pyi @@ -29,4 +29,4 @@ def calinski_harabasz_score(cluster): References ---------- .. footbibliography:: - """ + """ \ No newline at end of file diff --git a/pycrostates/metrics/davies_bouldin.pyi b/pycrostates/metrics/davies_bouldin.pyi index ee1cb124..b229521f 100644 --- a/pycrostates/metrics/davies_bouldin.pyi +++ b/pycrostates/metrics/davies_bouldin.pyi @@ -49,4 +49,4 @@ def _davies_bouldin_score(X, labels): ------- score: float The resulting Davies-Bouldin score. - """ + """ \ No newline at end of file diff --git a/pycrostates/metrics/dunn.pyi b/pycrostates/metrics/dunn.pyi index a55a740f..20697f85 100644 --- a/pycrostates/metrics/dunn.pyi +++ b/pycrostates/metrics/dunn.pyi @@ -45,5 +45,8 @@ def _dunn_score(X, labels): Based on https://github.com/jqmviegas/jqm_cvi """ -def _delta_fast(ck, cl, distances): ... -def _big_delta_fast(ci, distances): ... +def _delta_fast(ck, cl, distances): + ... + +def _big_delta_fast(ci, distances): + ... \ No newline at end of file diff --git a/pycrostates/metrics/silhouette.pyi b/pycrostates/metrics/silhouette.pyi index 092ab805..0c5b6ee4 100644 --- a/pycrostates/metrics/silhouette.pyi +++ b/pycrostates/metrics/silhouette.pyi @@ -31,4 +31,4 @@ def silhouette_score(cluster): References ---------- .. footbibliography:: - """ + """ \ No newline at end of file diff --git a/pycrostates/preprocessing/extract_gfp_peaks.pyi b/pycrostates/preprocessing/extract_gfp_peaks.pyi index b7ac9075..29aa19b1 100644 --- a/pycrostates/preprocessing/extract_gfp_peaks.pyi +++ b/pycrostates/preprocessing/extract_gfp_peaks.pyi @@ -14,16 +14,7 @@ from ..utils._checks import _check_type as _check_type from ..utils._docs import fill_doc as fill_doc from ..utils._logs import logger as logger -def extract_gfp_peaks( - inst: Union[BaseRaw, BaseEpochs], - picks: Picks = "eeg", - return_all: bool = False, - min_peak_distance: int = 1, - tmin: Optional[float] = None, - tmax: Optional[float] = None, - reject_by_annotation: bool = True, - verbose: Incomplete | None = None, -) -> CHData: +def extract_gfp_peaks(inst: Union[BaseRaw, BaseEpochs], picks: Picks='eeg', return_all: bool=False, min_peak_distance: int=1, tmin: Optional[float]=None, tmax: Optional[float]=None, reject_by_annotation: bool=True, verbose: Incomplete | None=None) -> CHData: """:term:`Global Field Power` (:term:`GFP`) peaks extraction. Extract :term:`Global Field Power` (:term:`GFP`) peaks from :class:`~mne.Epochs` or @@ -57,7 +48,7 @@ def extract_gfp_peaks( Whether to omit bad segments from the data before fitting. If ``True`` (default), annotated segments whose description begins with ``'bad'`` are omitted. If ``False``, no rejection based on annotations is performed. - + Has no effect if ``inst`` is not a :class:`mne.io.Raw` object. verbose : int | str | bool | None Sets the verbosity level. The verbosity increases gradually between ``"CRITICAL"``, @@ -78,9 +69,7 @@ def extract_gfp_peaks( default values. """ -def _extract_gfp_peaks( - data: NDArray[float], min_peak_distance: int = 2 -) -> NDArray[float]: +def _extract_gfp_peaks(data: NDArray[float], min_peak_distance: int=2) -> NDArray[float]: """Extract GFP peaks from input data. Parameters @@ -96,4 +85,4 @@ def _extract_gfp_peaks( ------- peaks : array of shape (n_picks,) The indices when peaks occur. - """ + """ \ No newline at end of file diff --git a/pycrostates/preprocessing/resample.pyi b/pycrostates/preprocessing/resample.pyi index d68f3146..11e3762c 100644 --- a/pycrostates/preprocessing/resample.pyi +++ b/pycrostates/preprocessing/resample.pyi @@ -14,19 +14,7 @@ from ..utils._checks import _check_type as _check_type from ..utils._docs import fill_doc as fill_doc from ..utils._logs import logger as logger -def resample( - inst: Union[BaseRaw, BaseEpochs, CHData], - picks: Picks = None, - tmin: Optional[float] = None, - tmax: Optional[float] = None, - reject_by_annotation: bool = True, - n_resamples: int = None, - n_samples: int = None, - coverage: float = None, - replace: bool = True, - random_state: RANDomState = None, - verbose: Incomplete | None = None, -) -> list[CHData]: +def resample(inst: Union[BaseRaw, BaseEpochs, CHData], picks: Picks=None, tmin: Optional[float]=None, tmax: Optional[float]=None, reject_by_annotation: bool=True, n_resamples: int=None, n_samples: int=None, coverage: float=None, replace: bool=True, random_state: RANDomState=None, verbose: Incomplete | None=None) -> list[CHData]: """Resample a recording into epochs of random samples. Resample :class:`~mne.io.Raw`. :class:`~mne.Epochs` or @@ -38,13 +26,13 @@ def resample( inst : Raw | Epochs | ChData Instance to resample. picks : str | array-like | slice | None - Channels to include. Slices and lists of integers will be interpreted as - channel indices. In lists, channel *type* strings (e.g., ``['meg', - 'eeg']``) will pick channels of those types, channel *name* strings (e.g., - ``['MEG0111', 'MEG2623']`` will pick the given channels. Can also be the - string values "all" to pick all channels, or "data" to pick :term:`data - channels`. None (default) will pick all channels. Note that channels in - ``info['bads']`` *will be included* if their names or indices are + Channels to include. Slices and lists of integers will be interpreted as + channel indices. In lists, channel *type* strings (e.g., ``['meg', + 'eeg']``) will pick channels of those types, channel *name* strings (e.g., + ``['MEG0111', 'MEG2623']`` will pick the given channels. Can also be the + string values "all" to pick all channels, or "data" to pick :term:`data + channels`. None (default) will pick all channels. Note that channels in + ``info['bads']`` *will be included* if their names or indices are explicitly provided. tmin : float Start time of the raw data to use in seconds (must be >= 0). @@ -54,7 +42,7 @@ def resample( Whether to omit bad segments from the data before fitting. If ``True`` (default), annotated segments whose description begins with ``'bad'`` are omitted. If ``False``, no rejection based on annotations is performed. - + Has no effect if ``inst`` is not a :class:`mne.io.Raw` object. n_resamples : int Number of resamples to draw. Each epoch can be used to fit a separate clustering @@ -88,4 +76,4 @@ def resample( ----- Only two of ``n_resamples``, ``n_samples`` and ``coverage`` parameters must be defined, the non-defined one will be determine at runtime by the 2 other parameters. - """ + """ \ No newline at end of file diff --git a/pycrostates/preprocessing/spatial_filter.pyi b/pycrostates/preprocessing/spatial_filter.pyi index e49fe3a0..ee8f0ba5 100644 --- a/pycrostates/preprocessing/spatial_filter.pyi +++ b/pycrostates/preprocessing/spatial_filter.pyi @@ -16,15 +16,7 @@ from ..utils._logs import logger as logger def _check_adjacency(adjacency, info, ch_type): """Check adjacency matrix.""" -def apply_spatial_filter( - inst: Union[BaseRaw, BaseEpochs, CHData], - ch_type: str = "eeg", - exclude_bads: bool = True, - origin: Union[str, NDArray[float]] = "auto", - adjacency: Union[csr_matrix, str] = "auto", - n_jobs: int = 1, - verbose: Incomplete | None = None, -): +def apply_spatial_filter(inst: Union[BaseRaw, BaseEpochs, CHData], ch_type: str='eeg', exclude_bads: bool=True, origin: Union[str, NDArray[float]]='auto', adjacency: Union[csr_matrix, str]='auto', n_jobs: int=1, verbose: Incomplete | None=None): """Apply a spatial filter. Adapted from \\ :footcite:t:`michel2019eeg`. Apply an instantaneous filter which @@ -90,4 +82,5 @@ def apply_spatial_filter( .. footbibliography:: """ -def _channel_spatial_filter(index, data, adjacency_vector, interpolate_matrix): ... +def _channel_spatial_filter(index, data, adjacency_vector, interpolate_matrix): + ... \ No newline at end of file diff --git a/pycrostates/segmentation/_base.pyi b/pycrostates/segmentation/_base.pyi index b4387401..8342710c 100644 --- a/pycrostates/segmentation/_base.pyi +++ b/pycrostates/segmentation/_base.pyi @@ -33,7 +33,6 @@ class _BaseSegmentation(Segmentation): predict_parameters : dict | None The prediction parameters. """ - _labels: Incomplete _inst: Incomplete _cluster_centers_: Incomplete @@ -41,17 +40,16 @@ class _BaseSegmentation(Segmentation): _predict_parameters: Incomplete @abstractmethod - def __init__( - self, - labels: NDArray[int], - inst: Union[BaseRaw, BaseEpochs], - cluster_centers_: NDArray[float], - cluster_names: Optional[list[str]] = None, - predict_parameters: Optional[dict] = None, - ): ... - def __repr__(self) -> str: ... - def _repr_html_(self, caption: Incomplete | None = None): ... - def compute_parameters(self, norm_gfp: bool = True, return_dist: bool = False): + def __init__(self, labels: NDArray[int], inst: Union[BaseRaw, BaseEpochs], cluster_centers_: NDArray[float], cluster_names: Optional[list[str]]=None, predict_parameters: Optional[dict]=None): + ... + + def __repr__(self) -> str: + ... + + def _repr_html_(self, caption: Incomplete | None=None): + ... + + def compute_parameters(self, norm_gfp: bool=True, return_dist: bool=False): """Compute microstate parameters. .. warning:: @@ -97,9 +95,7 @@ class _BaseSegmentation(Segmentation): expressed in seconds (s). """ - def compute_transition_matrix( - self, stat: str = "probability", ignore_repetitions: bool = True - ): + def compute_transition_matrix(self, stat: str='probability', ignore_repetitions: bool=True): """Compute the observed transition matrix. Count the number of transitions from one state to another and aggregate the @@ -123,9 +119,7 @@ class _BaseSegmentation(Segmentation): ``reject_edges`` parameter to ``True`` when predicting the segmentation. """ - def compute_expected_transition_matrix( - self, stat: str = "probability", ignore_repetitions: bool = True - ): + def compute_expected_transition_matrix(self, stat: str='probability', ignore_repetitions: bool=True): """Compute the expected transition matrix. Compute the theoretical transition matrix as if time course was ignored, but @@ -139,7 +133,7 @@ class _BaseSegmentation(Segmentation): ---------- stat : str Aggregate statistic to compute transitions. Can be: - + * ``probability`` or ``proportion``: normalize count such as the probabilities along the first axis is always equal to ``1``. * ``percent``: normalize count such as the probabilities along the first axis is @@ -157,9 +151,7 @@ class _BaseSegmentation(Segmentation): First axis indicates state ``"from"``. Second axis indicates state ``"to"``. """ - def plot_cluster_centers( - self, axes: Optional[Union[Axes, NDArray[Axes]]] = None, block: bool = False - ): + def plot_cluster_centers(self, axes: Optional[Union[Axes, NDArray[Axes]]]=None, block: bool=False): """Plot cluster centers as topographic maps. Parameters @@ -178,9 +170,7 @@ class _BaseSegmentation(Segmentation): """ @staticmethod - def _check_cluster_names( - cluster_names: list[str], cluster_centers_: NDArray[float] - ): + def _check_cluster_names(cluster_names: list[str], cluster_centers_: NDArray[float]): """Check that the argument 'cluster_names' is valid.""" @staticmethod @@ -214,4 +204,4 @@ class _BaseSegmentation(Segmentation): """Name of the cluster centers. :type: `list` - """ + """ \ No newline at end of file diff --git a/pycrostates/segmentation/segmentation.pyi b/pycrostates/segmentation/segmentation.pyi index d20f8147..e243079f 100644 --- a/pycrostates/segmentation/segmentation.pyi +++ b/pycrostates/segmentation/segmentation.pyi @@ -29,18 +29,10 @@ class RawSegmentation(_BaseSegmentation): The prediction parameters. """ - def __init__(self, *args, **kwargs) -> None: ... - def plot( - self, - tmin: Optional[Union[int, float]] = None, - tmax: Optional[Union[int, float]] = None, - cmap: Optional[str] = None, - axes: Optional[Axes] = None, - cbar_axes: Optional[Axes] = None, - *, - block: bool = False, - verbose: Optional[str] = None, - ): + def __init__(self, *args, **kwargs) -> None: + ... + + def plot(self, tmin: Optional[Union[int, float]]=None, tmax: Optional[Union[int, float]]=None, cmap: Optional[str]=None, axes: Optional[Axes]=None, cbar_axes: Optional[Axes]=None, *, block: bool=False, verbose: Optional[str]=None): """Plot the segmentation. Parameters @@ -92,16 +84,10 @@ class EpochsSegmentation(_BaseSegmentation): The prediction parameters. """ - def __init__(self, *args, **kwargs) -> None: ... - def plot( - self, - cmap: Optional[str] = None, - axes: Optional[Axes] = None, - cbar_axes: Optional[Axes] = None, - *, - block: bool = False, - verbose: Incomplete | None = None, - ): + def __init__(self, *args, **kwargs) -> None: + ... + + def plot(self, cmap: Optional[str]=None, axes: Optional[Axes]=None, cbar_axes: Optional[Axes]=None, *, block: bool=False, verbose: Incomplete | None=None): """Plot segmentation. Parameters @@ -130,4 +116,4 @@ class EpochsSegmentation(_BaseSegmentation): @property def epochs(self) -> BaseEpochs: - """`~mne.Epochs` instance from which the segmentation was computed.""" + """`~mne.Epochs` instance from which the segmentation was computed.""" \ No newline at end of file diff --git a/pycrostates/segmentation/transitions.pyi b/pycrostates/segmentation/transitions.pyi index 8f8ff1bd..a14c68f6 100644 --- a/pycrostates/segmentation/transitions.pyi +++ b/pycrostates/segmentation/transitions.pyi @@ -4,12 +4,7 @@ from ..utils._checks import _check_type as _check_type from ..utils._checks import _check_value as _check_value from ..utils._docs import fill_doc as fill_doc -def compute_transition_matrix( - labels: NDArray[int], - n_clusters: int, - stat: str = "probability", - ignore_repetitions: bool = True, -) -> NDArray[float]: +def compute_transition_matrix(labels: NDArray[int], n_clusters: int, stat: str='probability', ignore_repetitions: bool=True) -> NDArray[float]: """Compute the observed transition matrix. Count the number of transitions from one state to another and aggregate the result @@ -23,7 +18,7 @@ def compute_transition_matrix( The number of clusters, i.e. the number of microstates. stat : str Aggregate statistic to compute transitions. Can be: - + * ``count``: show the number of observations of each transition. * ``probability`` or ``proportion``: normalize count such as the probabilities along the first axis is always equal to ``1``. @@ -42,20 +37,10 @@ def compute_transition_matrix( First axis indicates state ``"from"``. Second axis indicates state ``"to"``. """ -def _compute_transition_matrix( - labels: NDArray[int], - n_clusters: int, - stat: str = "probability", - ignore_repetitions: bool = True, -) -> NDArray[float]: +def _compute_transition_matrix(labels: NDArray[int], n_clusters: int, stat: str='probability', ignore_repetitions: bool=True) -> NDArray[float]: """Compute observed transition.""" -def compute_expected_transition_matrix( - labels: NDArray[int], - n_clusters: int, - stat: str = "probability", - ignore_repetitions: bool = True, -) -> NDArray[float]: +def compute_expected_transition_matrix(labels: NDArray[int], n_clusters: int, stat: str='probability', ignore_repetitions: bool=True) -> NDArray[float]: """Compute the expected transition matrix. Compute the theoretical transition matrix as if time course was ignored, but @@ -73,7 +58,7 @@ def compute_expected_transition_matrix( The number of clusters, i.e. the number of microstates. stat : str Aggregate statistic to compute transitions. Can be: - + * ``probability`` or ``proportion``: normalize count such as the probabilities along the first axis is always equal to ``1``. * ``percent``: normalize count such as the probabilities along the first axis is @@ -91,16 +76,11 @@ def compute_expected_transition_matrix( First axis indicates state ``"from"``. Second axis indicates state ``"to"``. """ -def _compute_expected_transition_matrix( - labels: NDArray[int], - n_clusters: int, - stat: str = "probability", - ignore_repetitions: bool = True, -) -> NDArray[float]: +def _compute_expected_transition_matrix(labels: NDArray[int], n_clusters: int, stat: str='probability', ignore_repetitions: bool=True) -> NDArray[float]: """Compute theoretical transition matrix. The theoretical transition matrix takes into account the time coverage. """ def _check_labels_n_clusters(labels: NDArray[int], n_clusters: int) -> None: - """Checker for labels and n_clusters.""" + """Checker for labels and n_clusters.""" \ No newline at end of file diff --git a/pycrostates/utils/_checks.pyi b/pycrostates/utils/_checks.pyi index 7afa9228..d40c5740 100644 --- a/pycrostates/utils/_checks.pyi +++ b/pycrostates/utils/_checks.pyi @@ -4,7 +4,7 @@ from _typeshed import Incomplete from ._docs import fill_doc as fill_doc -def _ensure_int(item, item_name: Incomplete | None = None): +def _ensure_int(item, item_name: Incomplete | None=None): """ Ensure a variable is an integer. @@ -22,16 +22,19 @@ def _ensure_int(item, item_name: Incomplete | None = None): """ class _IntLike: + @classmethod - def __instancecheck__(cls, other): ... + def __instancecheck__(cls, other): + ... class _Callable: - @classmethod - def __instancecheck__(cls, other): ... + @classmethod + def __instancecheck__(cls, other): + ... _types: Incomplete -def _check_type(item, types, item_name: Incomplete | None = None): +def _check_type(item, types, item_name: Incomplete | None=None): """ Check that item is an instance of types. @@ -52,12 +55,7 @@ def _check_type(item, types, item_name: Incomplete | None = None): When the type of the item is not one of the valid options. """ -def _check_value( - item, - allowed_values, - item_name: Incomplete | None = None, - extra: Incomplete | None = None, -): +def _check_value(item, allowed_values, item_name: Incomplete | None=None, extra: Incomplete | None=None): """ Check the value of a parameter against a list of valid options. @@ -115,4 +113,4 @@ def _check_verbose(verbose: Any) -> int: ------- verbose : int The verbosity level as an integer. - """ + """ \ No newline at end of file diff --git a/pycrostates/utils/_config.pyi b/pycrostates/utils/_config.pyi index 5e614283..464c9f1d 100644 --- a/pycrostates/utils/_config.pyi +++ b/pycrostates/utils/_config.pyi @@ -11,7 +11,6 @@ def _get_config_path(): def _get_data_path(): """Get pycrostates data directory.""" - default_config: Incomplete def _save_config(config) -> None: @@ -35,4 +34,4 @@ def set_config(key, value) -> None: The preference key to set. Must be a valid key. value : str | None The value to assign to the preference key. - """ + """ \ No newline at end of file diff --git a/pycrostates/utils/_docs.pyi b/pycrostates/utils/_docs.pyi index 0cf2b0fa..7deb289f 100644 --- a/pycrostates/utils/_docs.pyi +++ b/pycrostates/utils/_docs.pyi @@ -67,4 +67,4 @@ def copy_doc(source: Callable) -> Callable: ... pass >>> print(B.m1.__doc__) Docstring for m1 this gets appended - """ + """ \ No newline at end of file diff --git a/pycrostates/utils/_fixes.pyi b/pycrostates/utils/_fixes.pyi index 08a8ce6f..7b1dd3e8 100644 --- a/pycrostates/utils/_fixes.pyi +++ b/pycrostates/utils/_fixes.pyi @@ -5,4 +5,5 @@ class _WrapStdOut: properly. """ - def __getattr__(self, name): ... + def __getattr__(self, name): + ... \ No newline at end of file diff --git a/pycrostates/utils/_imports.pyi b/pycrostates/utils/_imports.pyi index 96572acc..7de6b417 100644 --- a/pycrostates/utils/_imports.pyi +++ b/pycrostates/utils/_imports.pyi @@ -2,7 +2,7 @@ from ._logs import logger as logger _INSTALL_MAPPING: dict[str, str] -def import_optional_dependency(name: str, extra: str = "", raise_error: bool = True): +def import_optional_dependency(name: str, extra: str='', raise_error: bool=True): """ Import an optional dependency. @@ -27,4 +27,4 @@ def import_optional_dependency(name: str, extra: str = "", raise_error: bool = T maybe_module : Optional[ModuleType] The imported module when found. None is returned when the package is not found and raise_error is False. - """ + """ \ No newline at end of file diff --git a/pycrostates/utils/_logs.pyi b/pycrostates/utils/_logs.pyi index 05bff187..687db359 100644 --- a/pycrostates/utils/_logs.pyi +++ b/pycrostates/utils/_logs.pyi @@ -9,7 +9,7 @@ from ._checks import _check_verbose as _check_verbose from ._docs import fill_doc as fill_doc from ._fixes import _WrapStdOut as _WrapStdOut -def _init_logger(*, verbose: Optional[Union[bool, str, int]] = None) -> logging.Logger: +def _init_logger(*, verbose: Optional[Union[bool, str, int]]=None) -> logging.Logger: """Initialize a logger. Assigns sys.stdout as the first handler of the logger. @@ -28,13 +28,7 @@ def _init_logger(*, verbose: Optional[Union[bool, str, int]] = None) -> logging. The initialized logger. """ -def add_file_handler( - fname: Union[str, Path], - mode: str = "a", - encoding: Optional[str] = None, - *, - verbose: Optional[Union[bool, str, int]] = None, -) -> None: +def add_file_handler(fname: Union[str, Path], mode: str='a', encoding: Optional[str]=None, *, verbose: Optional[Union[bool, str, int]]=None) -> None: """Add a file handler to the logger. Parameters @@ -52,9 +46,7 @@ def add_file_handler( ``"WARNING"`` for False and to ``"INFO"`` for True. """ -def set_log_level( - verbose: Union[bool, str, int, None], apply_to_mne: bool = True -) -> None: +def set_log_level(verbose: Union[bool, str, int, None], apply_to_mne: bool=True) -> None: """Set the log level for the logger and the first handler ``sys.stdout``. Parameters @@ -70,10 +62,11 @@ def set_log_level( class _LoggerFormatter(logging.Formatter): """Format string Syntax for pycrostates.""" - _formatters: Incomplete - def __init__(self) -> None: ... + def __init__(self) -> None: + ... + def format(self, record): """ Format the received log record. @@ -108,12 +101,15 @@ class _use_log_level: verbosity is set to ``"WARNING"``. If a bool is provided, the verbosity is set to ``"WARNING"`` for False and to ``"INFO"`` for True. """ - _old_level: Incomplete _level: Incomplete - def __init__(self, verbose: Optional[Union[bool, str, int]] = None) -> None: ... - def __enter__(self) -> None: ... - def __exit__(self, *args) -> None: ... + def __init__(self, verbose: Optional[Union[bool, str, int]]=None) -> None: + ... + + def __enter__(self) -> None: + ... -logger: Incomplete + def __exit__(self, *args) -> None: + ... +logger: Incomplete \ No newline at end of file diff --git a/pycrostates/utils/mixin.pyi b/pycrostates/utils/mixin.pyi index b0198197..c2f8716d 100644 --- a/pycrostates/utils/mixin.pyi +++ b/pycrostates/utils/mixin.pyi @@ -7,10 +7,14 @@ class ChannelsMixin: """Channels Mixin for futur implementation.""" class ContainsMixin(MNEContainsMixin): - def __contains__(self, ch_type) -> bool: ... + + def __contains__(self, ch_type) -> bool: + ... + def __getattribute__(self, name): """Attribute getter.""" class MontageMixin(MNEMontageMixin): + def __getattribute__(self, name): - """Attribute getter.""" + """Attribute getter.""" \ No newline at end of file diff --git a/pycrostates/utils/sys_info.pyi b/pycrostates/utils/sys_info.pyi index 7b9374a5..bd53f3af 100644 --- a/pycrostates/utils/sys_info.pyi +++ b/pycrostates/utils/sys_info.pyi @@ -4,7 +4,7 @@ from packaging.requirements import Requirement from ._checks import _check_type as _check_type -def sys_info(fid: Optional[IO] = None, developer: bool = False): +def sys_info(fid: Optional[IO]=None, developer: bool=False): """Print the system information for debugging. Parameters @@ -16,7 +16,5 @@ def sys_info(fid: Optional[IO] = None, developer: bool = False): If True, display information about optional dependencies. """ -def _list_dependencies_info( - out: Callable, ljust: int, package: str, dependencies: list[Requirement] -): - """List dependencies names and versions.""" +def _list_dependencies_info(out: Callable, ljust: int, package: str, dependencies: list[Requirement]): + """List dependencies names and versions.""" \ No newline at end of file diff --git a/pycrostates/utils/utils.pyi b/pycrostates/utils/utils.pyi index 24ca6443..3c34489a 100644 --- a/pycrostates/utils/utils.pyi +++ b/pycrostates/utils/utils.pyi @@ -2,7 +2,7 @@ from _typeshed import Incomplete from ._logs import logger as logger -def _corr_vectors(A, B, axis: int = 0): +def _corr_vectors(A, B, axis: int=0): """Compute pairwise correlation of multiple pairs of vectors. Fast way to compute correlation of multiple pairs of vectors without computing all @@ -26,8 +26,8 @@ def _corr_vectors(A, B, axis: int = 0): For each pair of vectors, the correlation between them. """ -def _distance_matrix(X, Y: Incomplete | None = None): +def _distance_matrix(X, Y: Incomplete | None=None): """Distance matrix used in metrics.""" def _compare_infos(cluster_info, inst_info): - """Check that channels in cluster_info are all present in inst_info.""" + """Check that channels in cluster_info are all present in inst_info.""" \ No newline at end of file diff --git a/pycrostates/viz/cluster_centers.pyi b/pycrostates/viz/cluster_centers.pyi index 40d64698..96324034 100644 --- a/pycrostates/viz/cluster_centers.pyi +++ b/pycrostates/viz/cluster_centers.pyi @@ -12,18 +12,7 @@ from ..utils._logs import logger as logger _GRADIENT_KWARGS_DEFAULTS: dict[str, str] -def plot_cluster_centers( - cluster_centers: NDArray[float], - info: Union[Info, CHInfo], - cluster_names: list[str] = None, - axes: Optional[Union[Axes, NDArray[Axes]]] = None, - show_gradient: Optional[bool] = False, - gradient_kwargs: dict[str, Any] = ..., - *, - block: bool = False, - verbose: Optional[str] = None, - **kwargs, -): +def plot_cluster_centers(cluster_centers: NDArray[float], info: Union[Info, CHInfo], cluster_names: list[str]=None, axes: Optional[Union[Axes, NDArray[Axes]]]=None, show_gradient: Optional[bool]=False, gradient_kwargs: dict[str, Any]=..., *, block: bool=False, verbose: Optional[str]=None, **kwargs): """Create topographic maps for cluster centers. Parameters @@ -57,4 +46,4 @@ def plot_cluster_centers( ------- fig : Figure Matplotlib figure(s) on which topographic maps are plotted. - """ + """ \ No newline at end of file diff --git a/pycrostates/viz/segmentation.pyi b/pycrostates/viz/segmentation.pyi index 7790751d..466ada87 100644 --- a/pycrostates/viz/segmentation.pyi +++ b/pycrostates/viz/segmentation.pyi @@ -10,21 +10,7 @@ from ..utils._checks import _check_type as _check_type from ..utils._docs import fill_doc as fill_doc from ..utils._logs import logger as logger -def plot_raw_segmentation( - labels: NDArray[int], - raw: BaseRaw, - n_clusters: int, - cluster_names: list[str] = None, - tmin: Optional[Union[int, float]] = None, - tmax: Optional[Union[int, float]] = None, - cmap: Optional[str] = None, - axes: Optional[Axes] = None, - cbar_axes: Optional[Axes] = None, - *, - block: bool = False, - verbose: Optional[str] = None, - **kwargs, -): +def plot_raw_segmentation(labels: NDArray[int], raw: BaseRaw, n_clusters: int, cluster_names: list[str]=None, tmin: Optional[Union[int, float]]=None, tmax: Optional[Union[int, float]]=None, cmap: Optional[str]=None, axes: Optional[Axes]=None, cbar_axes: Optional[Axes]=None, *, block: bool=False, verbose: Optional[str]=None, **kwargs): """Plot raw segmentation. Parameters @@ -65,19 +51,7 @@ def plot_raw_segmentation( Matplotlib figure(s) on which topographic maps are plotted. """ -def plot_epoch_segmentation( - labels: NDArray[int], - epochs: BaseEpochs, - n_clusters: int, - cluster_names: list[str] = None, - cmap: Optional[str] = None, - axes: Optional[Axes] = None, - cbar_axes: Optional[Axes] = None, - *, - block: bool = False, - verbose: Optional[str] = None, - **kwargs, -): +def plot_epoch_segmentation(labels: NDArray[int], epochs: BaseEpochs, n_clusters: int, cluster_names: list[str]=None, cmap: Optional[str]=None, axes: Optional[Axes]=None, cbar_axes: Optional[Axes]=None, *, block: bool=False, verbose: Optional[str]=None, **kwargs): """ Plot epochs segmentation. @@ -115,19 +89,7 @@ def plot_epoch_segmentation( Matplotlib figure on which topographic maps are plotted. """ -def _plot_segmentation( - labels: NDArray[int], - gfp: NDArray[float], - times: NDArray[float], - n_clusters: int, - cluster_names: list[str] = None, - cmap: Optional[Union[str, colors.Colormap]] = None, - axes: Optional[Axes] = None, - cbar_axes: Optional[Axes] = None, - *, - verbose: Optional[str] = None, - **kwargs, -): +def _plot_segmentation(labels: NDArray[int], gfp: NDArray[float], times: NDArray[float], n_clusters: int, cluster_names: list[str]=None, cmap: Optional[Union[str, colors.Colormap]]=None, axes: Optional[Axes]=None, cbar_axes: Optional[Axes]=None, *, verbose: Optional[str]=None, **kwargs): """Code snippet to plot segmentation for raw and epochs.""" def _compatibility_cmap(cmap: Optional[Union[str, colors.Colormap]], n_colors: int): @@ -135,4 +97,4 @@ def _compatibility_cmap(cmap: Optional[Union[str, colors.Colormap]], n_colors: i Matplotlib 3.6 introduced a deprecation of plt.cm.get_cmap(). When support for the 3.6 version is dropped, this checker can be removed. - """ + """ \ No newline at end of file