cbook.pyi 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. import collections.abc
  2. from collections.abc import Callable, Collection, Generator, Iterable, Iterator
  3. import contextlib
  4. import os
  5. from pathlib import Path
  6. from matplotlib.artist import Artist
  7. import numpy as np
  8. from numpy.typing import ArrayLike
  9. from typing import (
  10. Any,
  11. Generic,
  12. IO,
  13. Literal,
  14. TypeVar,
  15. overload,
  16. )
  17. _T = TypeVar("_T")
  18. def _get_running_interactive_framework() -> str | None: ...
  19. class CallbackRegistry:
  20. exception_handler: Callable[[Exception], Any]
  21. callbacks: dict[Any, dict[int, Any]]
  22. def __init__(
  23. self,
  24. exception_handler: Callable[[Exception], Any] | None = ...,
  25. *,
  26. signals: Iterable[Any] | None = ...,
  27. ) -> None: ...
  28. def connect(self, signal: Any, func: Callable) -> int: ...
  29. def disconnect(self, cid: int) -> None: ...
  30. def process(self, s: Any, *args, **kwargs) -> None: ...
  31. def blocked(
  32. self, *, signal: Any | None = ...
  33. ) -> contextlib.AbstractContextManager[None]: ...
  34. class silent_list(list[_T]):
  35. type: str | None
  36. def __init__(self, type: str | None, seq: Iterable[_T] | None = ...) -> None: ...
  37. def strip_math(s: str) -> str: ...
  38. def is_writable_file_like(obj: Any) -> bool: ...
  39. def file_requires_unicode(x: Any) -> bool: ...
  40. @overload
  41. def to_filehandle(
  42. fname: str | os.PathLike | IO,
  43. flag: str = ...,
  44. return_opened: Literal[False] = ...,
  45. encoding: str | None = ...,
  46. ) -> IO: ...
  47. @overload
  48. def to_filehandle(
  49. fname: str | os.PathLike | IO,
  50. flag: str,
  51. return_opened: Literal[True],
  52. encoding: str | None = ...,
  53. ) -> tuple[IO, bool]: ...
  54. @overload
  55. def to_filehandle(
  56. fname: str | os.PathLike | IO,
  57. *, # if flag given, will match previous sig
  58. return_opened: Literal[True],
  59. encoding: str | None = ...,
  60. ) -> tuple[IO, bool]: ...
  61. def open_file_cm(
  62. path_or_file: str | os.PathLike | IO,
  63. mode: str = ...,
  64. encoding: str | None = ...,
  65. ) -> contextlib.AbstractContextManager[IO]: ...
  66. def is_scalar_or_string(val: Any) -> bool: ...
  67. @overload
  68. def get_sample_data(
  69. fname: str | os.PathLike, asfileobj: Literal[True] = ..., *, np_load: Literal[True]
  70. ) -> np.ndarray: ...
  71. @overload
  72. def get_sample_data(
  73. fname: str | os.PathLike,
  74. asfileobj: Literal[True] = ...,
  75. *,
  76. np_load: Literal[False] = ...,
  77. ) -> IO: ...
  78. @overload
  79. def get_sample_data(
  80. fname: str | os.PathLike, asfileobj: Literal[False], *, np_load: bool = ...
  81. ) -> str: ...
  82. def _get_data_path(*args: Path | str) -> Path: ...
  83. def flatten(
  84. seq: Iterable[Any], scalarp: Callable[[Any], bool] = ...
  85. ) -> Generator[Any, None, None]: ...
  86. class Stack(Generic[_T]):
  87. def __init__(self, default: _T | None = ...) -> None: ...
  88. def __call__(self) -> _T: ...
  89. def __len__(self) -> int: ...
  90. def __getitem__(self, ind: int) -> _T: ...
  91. def forward(self) -> _T: ...
  92. def back(self) -> _T: ...
  93. def push(self, o: _T) -> _T: ...
  94. def home(self) -> _T: ...
  95. def empty(self) -> bool: ...
  96. def clear(self) -> None: ...
  97. def bubble(self, o: _T) -> _T: ...
  98. def remove(self, o: _T) -> None: ...
  99. def safe_masked_invalid(x: ArrayLike, copy: bool = ...) -> np.ndarray: ...
  100. def print_cycles(
  101. objects: Iterable[Any], outstream: IO = ..., show_progress: bool = ...
  102. ) -> None: ...
  103. class Grouper(Generic[_T]):
  104. def __init__(self, init: Iterable[_T] = ...) -> None: ...
  105. def __contains__(self, item: _T) -> bool: ...
  106. def clean(self) -> None: ...
  107. def join(self, a: _T, *args: _T) -> None: ...
  108. def joined(self, a: _T, b: _T) -> bool: ...
  109. def remove(self, a: _T) -> None: ...
  110. def __iter__(self) -> Iterator[list[_T]]: ...
  111. def get_siblings(self, a: _T) -> list[_T]: ...
  112. class GrouperView(Generic[_T]):
  113. def __init__(self, grouper: Grouper[_T]) -> None: ...
  114. def __contains__(self, item: _T) -> bool: ...
  115. def __iter__(self) -> Iterator[list[_T]]: ...
  116. def joined(self, a: _T, b: _T) -> bool: ...
  117. def get_siblings(self, a: _T) -> list[_T]: ...
  118. def simple_linear_interpolation(a: ArrayLike, steps: int) -> np.ndarray: ...
  119. def delete_masked_points(*args): ...
  120. def boxplot_stats(
  121. X: ArrayLike,
  122. whis: float | tuple[float, float] = ...,
  123. bootstrap: int | None = ...,
  124. labels: ArrayLike | None = ...,
  125. autorange: bool = ...,
  126. ) -> list[dict[str, Any]]: ...
  127. ls_mapper: dict[str, str]
  128. ls_mapper_r: dict[str, str]
  129. def contiguous_regions(mask: ArrayLike) -> list[np.ndarray]: ...
  130. def is_math_text(s: str) -> bool: ...
  131. def violin_stats(
  132. X: ArrayLike, method: Callable, points: int = ..., quantiles: ArrayLike | None = ...
  133. ) -> list[dict[str, Any]]: ...
  134. def pts_to_prestep(x: ArrayLike, *args: ArrayLike) -> np.ndarray: ...
  135. def pts_to_poststep(x: ArrayLike, *args: ArrayLike) -> np.ndarray: ...
  136. def pts_to_midstep(x: np.ndarray, *args: np.ndarray) -> np.ndarray: ...
  137. STEP_LOOKUP_MAP: dict[str, Callable]
  138. def index_of(y: float | ArrayLike) -> tuple[np.ndarray, np.ndarray]: ...
  139. def safe_first_element(obj: Collection[_T]) -> _T: ...
  140. def sanitize_sequence(data): ...
  141. def normalize_kwargs(
  142. kw: dict[str, Any],
  143. alias_mapping: dict[str, list[str]] | type[Artist] | Artist | None = ...,
  144. ) -> dict[str, Any]: ...
  145. def _lock_path(path: str | os.PathLike) -> contextlib.AbstractContextManager[None]: ...
  146. def _str_equal(obj: Any, s: str) -> bool: ...
  147. def _setattr_cm(obj: Any, **kwargs) -> contextlib.AbstractContextManager[None]: ...
  148. class _OrderedSet(collections.abc.MutableSet):
  149. def __init__(self) -> None: ...
  150. def __contains__(self, key) -> bool: ...
  151. def __iter__(self): ...
  152. def __len__(self) -> int: ...
  153. def add(self, key) -> None: ...
  154. def discard(self, key) -> None: ...
  155. def _backend_module_name(name: str) -> str: ...
  156. def _format_approx(number: float, precision: int) -> str: ...