transforms.pyi 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. from .path import Path
  2. from .patches import Patch
  3. from .figure import Figure
  4. import numpy as np
  5. from numpy.typing import ArrayLike
  6. from collections.abc import Iterable, Sequence
  7. from typing import Literal
  8. DEBUG: bool
  9. class TransformNode:
  10. INVALID_NON_AFFINE: int
  11. INVALID_AFFINE: int
  12. INVALID: int
  13. is_bbox: bool
  14. # Implemented as a standard attr in base class, but functionally readonly and some subclasses implement as such
  15. @property
  16. def is_affine(self) -> bool: ...
  17. pass_through: bool
  18. def __init__(self, shorthand_name: str | None = ...) -> None: ...
  19. def __copy__(self) -> TransformNode: ...
  20. def invalidate(self) -> None: ...
  21. def set_children(self, *children: TransformNode) -> None: ...
  22. def frozen(self) -> TransformNode: ...
  23. class BboxBase(TransformNode):
  24. is_bbox: bool
  25. is_affine: bool
  26. def frozen(self) -> Bbox: ...
  27. def __array__(self, *args, **kwargs): ...
  28. @property
  29. def x0(self) -> float: ...
  30. @property
  31. def y0(self) -> float: ...
  32. @property
  33. def x1(self) -> float: ...
  34. @property
  35. def y1(self) -> float: ...
  36. @property
  37. def p0(self) -> tuple[float, float]: ...
  38. @property
  39. def p1(self) -> tuple[float, float]: ...
  40. @property
  41. def xmin(self) -> float: ...
  42. @property
  43. def ymin(self) -> float: ...
  44. @property
  45. def xmax(self) -> float: ...
  46. @property
  47. def ymax(self) -> float: ...
  48. @property
  49. def min(self) -> tuple[float, float]: ...
  50. @property
  51. def max(self) -> tuple[float, float]: ...
  52. @property
  53. def intervalx(self) -> tuple[float, float]: ...
  54. @property
  55. def intervaly(self) -> tuple[float, float]: ...
  56. @property
  57. def width(self) -> float: ...
  58. @property
  59. def height(self) -> float: ...
  60. @property
  61. def size(self) -> tuple[float, float]: ...
  62. @property
  63. def bounds(self) -> tuple[float, float, float, float]: ...
  64. @property
  65. def extents(self) -> tuple[float, float, float, float]: ...
  66. def get_points(self) -> np.ndarray: ...
  67. def containsx(self, x: float) -> bool: ...
  68. def containsy(self, y: float) -> bool: ...
  69. def contains(self, x: float, y: float) -> bool: ...
  70. def overlaps(self, other: BboxBase) -> bool: ...
  71. def fully_containsx(self, x: float) -> bool: ...
  72. def fully_containsy(self, y: float) -> bool: ...
  73. def fully_contains(self, x: float, y: float) -> bool: ...
  74. def fully_overlaps(self, other: BboxBase) -> bool: ...
  75. def transformed(self, transform: Transform) -> Bbox: ...
  76. coefs: dict[str, tuple[float, float]]
  77. def anchored(
  78. self,
  79. c: tuple[float, float] | Literal['C', 'SW', 'S', 'SE', 'E', 'NE', 'N', 'NW', 'W'],
  80. container: BboxBase,
  81. ) -> Bbox: ...
  82. def shrunk(self, mx: float, my: float) -> Bbox: ...
  83. def shrunk_to_aspect(
  84. self,
  85. box_aspect: float,
  86. container: BboxBase | None = ...,
  87. fig_aspect: float = ...,
  88. ) -> Bbox: ...
  89. def splitx(self, *args: float) -> list[Bbox]: ...
  90. def splity(self, *args: float) -> list[Bbox]: ...
  91. def count_contains(self, vertices: ArrayLike) -> int: ...
  92. def count_overlaps(self, bboxes: Iterable[BboxBase]) -> int: ...
  93. def expanded(self, sw: float, sh: float) -> Bbox: ...
  94. def padded(self, w_pad: float, h_pad: float | None = ...) -> Bbox: ...
  95. def translated(self, tx: float, ty: float) -> Bbox: ...
  96. def corners(self) -> np.ndarray: ...
  97. def rotated(self, radians: float) -> Bbox: ...
  98. @staticmethod
  99. def union(bboxes: Sequence[BboxBase]) -> Bbox: ...
  100. @staticmethod
  101. def intersection(bbox1: BboxBase, bbox2: BboxBase) -> Bbox | None: ...
  102. class Bbox(BboxBase):
  103. def __init__(self, points: ArrayLike, **kwargs) -> None: ...
  104. @staticmethod
  105. def unit() -> Bbox: ...
  106. @staticmethod
  107. def null() -> Bbox: ...
  108. @staticmethod
  109. def from_bounds(x0: float, y0: float, width: float, height: float) -> Bbox: ...
  110. @staticmethod
  111. def from_extents(*args: float, minpos: float | None = ...) -> Bbox: ...
  112. def __format__(self, fmt: str) -> str: ...
  113. def ignore(self, value: bool) -> None: ...
  114. def update_from_path(
  115. self,
  116. path: Path,
  117. ignore: bool | None = ...,
  118. updatex: bool = ...,
  119. updatey: bool = ...,
  120. ) -> None: ...
  121. def update_from_data_x(self, x: ArrayLike, ignore: bool | None = ...) -> None: ...
  122. def update_from_data_y(self, y: ArrayLike, ignore: bool | None = ...) -> None: ...
  123. def update_from_data_xy(
  124. self,
  125. xy: ArrayLike,
  126. ignore: bool | None = ...,
  127. updatex: bool = ...,
  128. updatey: bool = ...,
  129. ) -> None: ...
  130. @property
  131. def minpos(self) -> float: ...
  132. @property
  133. def minposx(self) -> float: ...
  134. @property
  135. def minposy(self) -> float: ...
  136. def get_points(self) -> np.ndarray: ...
  137. def set_points(self, points: ArrayLike) -> None: ...
  138. def set(self, other: Bbox) -> None: ...
  139. def mutated(self) -> bool: ...
  140. def mutatedx(self) -> bool: ...
  141. def mutatedy(self) -> bool: ...
  142. class TransformedBbox(BboxBase):
  143. def __init__(self, bbox: Bbox, transform: Transform, **kwargs) -> None: ...
  144. def get_points(self) -> np.ndarray: ...
  145. class LockableBbox(BboxBase):
  146. def __init__(
  147. self,
  148. bbox: BboxBase,
  149. x0: float | None = ...,
  150. y0: float | None = ...,
  151. x1: float | None = ...,
  152. y1: float | None = ...,
  153. **kwargs
  154. ) -> None: ...
  155. @property
  156. def locked_x0(self) -> float | None: ...
  157. @locked_x0.setter
  158. def locked_x0(self, x0: float | None) -> None: ...
  159. @property
  160. def locked_y0(self) -> float | None: ...
  161. @locked_y0.setter
  162. def locked_y0(self, y0: float | None) -> None: ...
  163. @property
  164. def locked_x1(self) -> float | None: ...
  165. @locked_x1.setter
  166. def locked_x1(self, x1: float | None) -> None: ...
  167. @property
  168. def locked_y1(self) -> float | None: ...
  169. @locked_y1.setter
  170. def locked_y1(self, y1: float | None) -> None: ...
  171. class Transform(TransformNode):
  172. # Implemented as a standard attrs in base class, but functionally readonly and some subclasses implement as such
  173. @property
  174. def input_dims(self) -> int | None: ...
  175. @property
  176. def output_dims(self) -> int | None: ...
  177. @property
  178. def is_separable(self) -> bool: ...
  179. @property
  180. def has_inverse(self) -> bool: ...
  181. def __add__(self, other: Transform) -> Transform: ...
  182. @property
  183. def depth(self) -> int: ...
  184. def contains_branch(self, other: Transform) -> bool: ...
  185. def contains_branch_seperately(
  186. self, other_transform: Transform
  187. ) -> Sequence[bool]: ...
  188. def __sub__(self, other: Transform) -> Transform: ...
  189. def __array__(self, *args, **kwargs) -> np.ndarray: ...
  190. def transform(self, values: ArrayLike) -> np.ndarray: ...
  191. def transform_affine(self, values: ArrayLike) -> np.ndarray: ...
  192. def transform_non_affine(self, values: ArrayLike) -> ArrayLike: ...
  193. def transform_bbox(self, bbox: BboxBase) -> Bbox: ...
  194. def get_affine(self) -> Transform: ...
  195. def get_matrix(self) -> np.ndarray: ...
  196. def transform_point(self, point: ArrayLike) -> np.ndarray: ...
  197. def transform_path(self, path: Path) -> Path: ...
  198. def transform_path_affine(self, path: Path) -> Path: ...
  199. def transform_path_non_affine(self, path: Path) -> Path: ...
  200. def transform_angles(
  201. self,
  202. angles: ArrayLike,
  203. pts: ArrayLike,
  204. radians: bool = ...,
  205. pushoff: float = ...,
  206. ) -> np.ndarray: ...
  207. def inverted(self) -> Transform: ...
  208. class TransformWrapper(Transform):
  209. pass_through: bool
  210. def __init__(self, child: Transform) -> None: ...
  211. def __eq__(self, other: object) -> bool: ...
  212. def frozen(self) -> Transform: ...
  213. def set(self, child: Transform) -> None: ...
  214. class AffineBase(Transform):
  215. is_affine: Literal[True]
  216. def __init__(self, *args, **kwargs) -> None: ...
  217. def __eq__(self, other: object) -> bool: ...
  218. class Affine2DBase(AffineBase):
  219. input_dims: Literal[2]
  220. output_dims: Literal[2]
  221. def frozen(self) -> Affine2D: ...
  222. def to_values(self) -> tuple[float, float, float, float, float, float]: ...
  223. class Affine2D(Affine2DBase):
  224. def __init__(self, matrix: ArrayLike | None = ..., **kwargs) -> None: ...
  225. @staticmethod
  226. def from_values(
  227. a: float, b: float, c: float, d: float, e: float, f: float
  228. ) -> Affine2D: ...
  229. def set_matrix(self, mtx: ArrayLike) -> None: ...
  230. def clear(self) -> Affine2D: ...
  231. def rotate(self, theta: float) -> Affine2D: ...
  232. def rotate_deg(self, degrees: float) -> Affine2D: ...
  233. def rotate_around(self, x: float, y: float, theta: float) -> Affine2D: ...
  234. def rotate_deg_around(self, x: float, y: float, degrees: float) -> Affine2D: ...
  235. def translate(self, tx: float, ty: float) -> Affine2D: ...
  236. def scale(self, sx: float, sy: float | None = ...) -> Affine2D: ...
  237. def skew(self, xShear: float, yShear: float) -> Affine2D: ...
  238. def skew_deg(self, xShear: float, yShear: float) -> Affine2D: ...
  239. class IdentityTransform(Affine2DBase): ...
  240. class _BlendedMixin:
  241. def __eq__(self, other: object) -> bool: ...
  242. def contains_branch_seperately(self, transform: Transform) -> Sequence[bool]: ...
  243. class BlendedGenericTransform(_BlendedMixin, Transform):
  244. input_dims: Literal[2]
  245. output_dims: Literal[2]
  246. pass_through: bool
  247. def __init__(
  248. self, x_transform: Transform, y_transform: Transform, **kwargs
  249. ) -> None: ...
  250. @property
  251. def depth(self) -> int: ...
  252. def contains_branch(self, other: Transform) -> Literal[False]: ...
  253. @property
  254. def is_affine(self) -> bool: ...
  255. class BlendedAffine2D(_BlendedMixin, Affine2DBase):
  256. def __init__(
  257. self, x_transform: Transform, y_transform: Transform, **kwargs
  258. ) -> None: ...
  259. def blended_transform_factory(
  260. x_transform: Transform, y_transform: Transform
  261. ) -> BlendedGenericTransform | BlendedAffine2D: ...
  262. class CompositeGenericTransform(Transform):
  263. pass_through: bool
  264. def __init__(self, a: Transform, b: Transform, **kwargs) -> None: ...
  265. class CompositeAffine2D(Affine2DBase):
  266. def __init__(self, a: Affine2DBase, b: Affine2DBase, **kwargs) -> None: ...
  267. @property
  268. def depth(self) -> int: ...
  269. def composite_transform_factory(a: Transform, b: Transform) -> Transform: ...
  270. class BboxTransform(Affine2DBase):
  271. def __init__(self, boxin: BboxBase, boxout: BboxBase, **kwargs) -> None: ...
  272. class BboxTransformTo(Affine2DBase):
  273. def __init__(self, boxout: BboxBase, **kwargs) -> None: ...
  274. class BboxTransformToMaxOnly(BboxTransformTo): ...
  275. class BboxTransformFrom(Affine2DBase):
  276. def __init__(self, boxin: BboxBase, **kwargs) -> None: ...
  277. class ScaledTranslation(Affine2DBase):
  278. def __init__(
  279. self, xt: float, yt: float, scale_trans: Affine2DBase, **kwargs
  280. ) -> None: ...
  281. class AffineDeltaTransform(Affine2DBase):
  282. def __init__(self, transform: Affine2DBase, **kwargs) -> None: ...
  283. class TransformedPath(TransformNode):
  284. def __init__(self, path: Path, transform: Transform) -> None: ...
  285. def get_transformed_points_and_affine(self) -> tuple[Path, Transform]: ...
  286. def get_transformed_path_and_affine(self) -> tuple[Path, Transform]: ...
  287. def get_fully_transformed_path(self) -> Path: ...
  288. def get_affine(self) -> Transform: ...
  289. class TransformedPatchPath(TransformedPath):
  290. def __init__(self, patch: Patch) -> None: ...
  291. def nonsingular(
  292. vmin: float,
  293. vmax: float,
  294. expander: float = ...,
  295. tiny: float = ...,
  296. increasing: bool = ...,
  297. ) -> tuple[float, float]: ...
  298. def interval_contains(interval: tuple[float, float], val: float) -> bool: ...
  299. def interval_contains_open(interval: tuple[float, float], val: float) -> bool: ...
  300. def offset_copy(
  301. trans: Transform,
  302. fig: Figure | None = ...,
  303. x: float = ...,
  304. y: float = ...,
  305. units: Literal["inches", "points", "dots"] = ...,
  306. ) -> Transform: ...
  307. class _ScaledRotation(Affine2DBase):
  308. def __init__(self, theta: float, trans_shift: Transform) -> None: ...
  309. def get_matrix(self) -> np.ndarray: ...