transforms.pyi 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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. # anchored type can be s/str/Literal["C", "SW", "S", "SE", "E", "NE", "N", "NW", "W"]
  78. def anchored(
  79. self, c: tuple[float, float] | str, container: BboxBase | None = ...
  80. ) -> Bbox: ...
  81. def shrunk(self, mx: float, my: float) -> Bbox: ...
  82. def shrunk_to_aspect(
  83. self,
  84. box_aspect: float,
  85. container: BboxBase | None = ...,
  86. fig_aspect: float = ...,
  87. ) -> Bbox: ...
  88. def splitx(self, *args: float) -> list[Bbox]: ...
  89. def splity(self, *args: float) -> list[Bbox]: ...
  90. def count_contains(self, vertices: ArrayLike) -> int: ...
  91. def count_overlaps(self, bboxes: Iterable[BboxBase]) -> int: ...
  92. def expanded(self, sw: float, sh: float) -> Bbox: ...
  93. def padded(self, w_pad: float, h_pad: float | None = ...) -> Bbox: ...
  94. def translated(self, tx: float, ty: float) -> Bbox: ...
  95. def corners(self) -> np.ndarray: ...
  96. def rotated(self, radians: float) -> Bbox: ...
  97. @staticmethod
  98. def union(bboxes: Sequence[BboxBase]) -> Bbox: ...
  99. @staticmethod
  100. def intersection(bbox1: BboxBase, bbox2: BboxBase) -> Bbox | None: ...
  101. class Bbox(BboxBase):
  102. def __init__(self, points: ArrayLike, **kwargs) -> None: ...
  103. @staticmethod
  104. def unit() -> Bbox: ...
  105. @staticmethod
  106. def null() -> Bbox: ...
  107. @staticmethod
  108. def from_bounds(x0: float, y0: float, width: float, height: float) -> Bbox: ...
  109. @staticmethod
  110. def from_extents(*args: float, minpos: float | None = ...) -> Bbox: ...
  111. def __format__(self, fmt: str) -> str: ...
  112. def ignore(self, value: bool) -> None: ...
  113. def update_from_path(
  114. self,
  115. path: Path,
  116. ignore: bool | None = ...,
  117. updatex: bool = ...,
  118. updatey: bool = ...,
  119. ) -> None: ...
  120. def update_from_data_x(self, x: ArrayLike, ignore: bool | None = ...) -> None: ...
  121. def update_from_data_y(self, y: ArrayLike, ignore: bool | None = ...) -> None: ...
  122. def update_from_data_xy(
  123. self,
  124. xy: ArrayLike,
  125. ignore: bool | None = ...,
  126. updatex: bool = ...,
  127. updatey: bool = ...,
  128. ) -> None: ...
  129. @property
  130. def minpos(self) -> float: ...
  131. @property
  132. def minposx(self) -> float: ...
  133. @property
  134. def minposy(self) -> float: ...
  135. def get_points(self) -> np.ndarray: ...
  136. def set_points(self, points: ArrayLike) -> None: ...
  137. def set(self, other: Bbox) -> None: ...
  138. def mutated(self) -> bool: ...
  139. def mutatedx(self) -> bool: ...
  140. def mutatedy(self) -> bool: ...
  141. class TransformedBbox(BboxBase):
  142. def __init__(self, bbox: Bbox, transform: Transform, **kwargs) -> None: ...
  143. def get_points(self) -> np.ndarray: ...
  144. class LockableBbox(BboxBase):
  145. def __init__(
  146. self,
  147. bbox: BboxBase,
  148. x0: float | None = ...,
  149. y0: float | None = ...,
  150. x1: float | None = ...,
  151. y1: float | None = ...,
  152. **kwargs
  153. ) -> None: ...
  154. @property
  155. def locked_x0(self) -> float | None: ...
  156. @locked_x0.setter
  157. def locked_x0(self, x0: float | None) -> None: ...
  158. @property
  159. def locked_y0(self) -> float | None: ...
  160. @locked_y0.setter
  161. def locked_y0(self, y0: float | None) -> None: ...
  162. @property
  163. def locked_x1(self) -> float | None: ...
  164. @locked_x1.setter
  165. def locked_x1(self, x1: float | None) -> None: ...
  166. @property
  167. def locked_y1(self) -> float | None: ...
  168. @locked_y1.setter
  169. def locked_y1(self, y1: float | None) -> None: ...
  170. class Transform(TransformNode):
  171. # Implemented as a standard attrs in base class, but functionally readonly and some subclasses implement as such
  172. @property
  173. def input_dims(self) -> int | None: ...
  174. @property
  175. def output_dims(self) -> int | None: ...
  176. @property
  177. def is_separable(self) -> bool: ...
  178. @property
  179. def has_inverse(self) -> bool: ...
  180. def __add__(self, other: Transform) -> Transform: ...
  181. @property
  182. def depth(self) -> int: ...
  183. def contains_branch(self, other: Transform) -> bool: ...
  184. def contains_branch_seperately(
  185. self, other_transform: Transform
  186. ) -> Sequence[bool]: ...
  187. def __sub__(self, other: Transform) -> Transform: ...
  188. def __array__(self, *args, **kwargs) -> np.ndarray: ...
  189. def transform(self, values: ArrayLike) -> np.ndarray: ...
  190. def transform_affine(self, values: ArrayLike) -> np.ndarray: ...
  191. def transform_non_affine(self, values: ArrayLike) -> ArrayLike: ...
  192. def transform_bbox(self, bbox: BboxBase) -> Bbox: ...
  193. def get_affine(self) -> Transform: ...
  194. def get_matrix(self) -> np.ndarray: ...
  195. def transform_point(self, point: ArrayLike) -> np.ndarray: ...
  196. def transform_path(self, path: Path) -> Path: ...
  197. def transform_path_affine(self, path: Path) -> Path: ...
  198. def transform_path_non_affine(self, path: Path) -> Path: ...
  199. def transform_angles(
  200. self,
  201. angles: ArrayLike,
  202. pts: ArrayLike,
  203. radians: bool = ...,
  204. pushoff: float = ...,
  205. ) -> np.ndarray: ...
  206. def inverted(self) -> Transform: ...
  207. class TransformWrapper(Transform):
  208. pass_through: bool
  209. def __init__(self, child: Transform) -> None: ...
  210. def __eq__(self, other: object) -> bool: ...
  211. def frozen(self) -> Transform: ...
  212. def set(self, child: Transform) -> None: ...
  213. class AffineBase(Transform):
  214. is_affine: Literal[True]
  215. def __init__(self, *args, **kwargs) -> None: ...
  216. def __eq__(self, other: object) -> bool: ...
  217. class Affine2DBase(AffineBase):
  218. input_dims: Literal[2]
  219. output_dims: Literal[2]
  220. def frozen(self) -> Affine2D: ...
  221. def to_values(self) -> tuple[float, float, float, float, float, float]: ...
  222. class Affine2D(Affine2DBase):
  223. def __init__(self, matrix: ArrayLike | None = ..., **kwargs) -> None: ...
  224. @staticmethod
  225. def from_values(
  226. a: float, b: float, c: float, d: float, e: float, f: float
  227. ) -> Affine2D: ...
  228. def set_matrix(self, mtx: ArrayLike) -> None: ...
  229. def clear(self) -> Affine2D: ...
  230. def rotate(self, theta: float) -> Affine2D: ...
  231. def rotate_deg(self, degrees: float) -> Affine2D: ...
  232. def rotate_around(self, x: float, y: float, theta: float) -> Affine2D: ...
  233. def rotate_deg_around(self, x: float, y: float, degrees: float) -> Affine2D: ...
  234. def translate(self, tx: float, ty: float) -> Affine2D: ...
  235. def scale(self, sx: float, sy: float | None = ...) -> Affine2D: ...
  236. def skew(self, xShear: float, yShear: float) -> Affine2D: ...
  237. def skew_deg(self, xShear: float, yShear: float) -> Affine2D: ...
  238. class IdentityTransform(Affine2DBase): ...
  239. class _BlendedMixin:
  240. def __eq__(self, other: object) -> bool: ...
  241. def contains_branch_seperately(self, transform: Transform) -> Sequence[bool]: ...
  242. class BlendedGenericTransform(_BlendedMixin, Transform):
  243. input_dims: Literal[2]
  244. output_dims: Literal[2]
  245. pass_through: bool
  246. def __init__(
  247. self, x_transform: Transform, y_transform: Transform, **kwargs
  248. ) -> None: ...
  249. @property
  250. def depth(self) -> int: ...
  251. def contains_branch(self, other: Transform) -> Literal[False]: ...
  252. @property
  253. def is_affine(self) -> bool: ...
  254. class BlendedAffine2D(_BlendedMixin, Affine2DBase):
  255. def __init__(
  256. self, x_transform: Transform, y_transform: Transform, **kwargs
  257. ) -> None: ...
  258. def blended_transform_factory(
  259. x_transform: Transform, y_transform: Transform
  260. ) -> BlendedGenericTransform | BlendedAffine2D: ...
  261. class CompositeGenericTransform(Transform):
  262. pass_through: bool
  263. def __init__(self, a: Transform, b: Transform, **kwargs) -> None: ...
  264. class CompositeAffine2D(Affine2DBase):
  265. def __init__(self, a: Affine2DBase, b: Affine2DBase, **kwargs) -> None: ...
  266. @property
  267. def depth(self) -> int: ...
  268. def composite_transform_factory(a: Transform, b: Transform) -> Transform: ...
  269. class BboxTransform(Affine2DBase):
  270. def __init__(self, boxin: BboxBase, boxout: BboxBase, **kwargs) -> None: ...
  271. class BboxTransformTo(Affine2DBase):
  272. def __init__(self, boxout: BboxBase, **kwargs) -> None: ...
  273. class BboxTransformToMaxOnly(BboxTransformTo): ...
  274. class BboxTransformFrom(Affine2DBase):
  275. def __init__(self, boxin: BboxBase, **kwargs) -> None: ...
  276. class ScaledTranslation(Affine2DBase):
  277. def __init__(
  278. self, xt: float, yt: float, scale_trans: Affine2DBase, **kwargs
  279. ) -> None: ...
  280. class AffineDeltaTransform(Affine2DBase):
  281. def __init__(self, transform: Affine2DBase, **kwargs) -> None: ...
  282. class TransformedPath(TransformNode):
  283. def __init__(self, path: Path, transform: Transform) -> None: ...
  284. def get_transformed_points_and_affine(self) -> tuple[Path, Transform]: ...
  285. def get_transformed_path_and_affine(self) -> tuple[Path, Transform]: ...
  286. def get_fully_transformed_path(self) -> Path: ...
  287. def get_affine(self) -> Transform: ...
  288. class TransformedPatchPath(TransformedPath):
  289. def __init__(self, patch: Patch) -> None: ...
  290. def nonsingular(
  291. vmin: float,
  292. vmax: float,
  293. expander: float = ...,
  294. tiny: float = ...,
  295. increasing: bool = ...,
  296. ) -> tuple[float, float]: ...
  297. def interval_contains(interval: tuple[float, float], val: float) -> bool: ...
  298. def interval_contains_open(interval: tuple[float, float], val: float) -> bool: ...
  299. def offset_copy(
  300. trans: Transform,
  301. fig: Figure | None = ...,
  302. x: float = ...,
  303. y: float = ...,
  304. units: Literal["inches", "points", "dots"] = ...,
  305. ) -> Transform: ...