arrayprint.pyi 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. from types import TracebackType
  2. from collections.abc import Callable
  3. from typing import Any, Literal, TypedDict, SupportsIndex
  4. # Using a private class is by no means ideal, but it is simply a consequence
  5. # of a `contextlib.context` returning an instance of aforementioned class
  6. from contextlib import _GeneratorContextManager
  7. from numpy import (
  8. ndarray,
  9. generic,
  10. bool_,
  11. integer,
  12. timedelta64,
  13. datetime64,
  14. floating,
  15. complexfloating,
  16. void,
  17. str_,
  18. bytes_,
  19. longdouble,
  20. clongdouble,
  21. )
  22. from numpy._typing import ArrayLike, _CharLike_co, _FloatLike_co
  23. _FloatMode = Literal["fixed", "unique", "maxprec", "maxprec_equal"]
  24. class _FormatDict(TypedDict, total=False):
  25. bool: Callable[[bool_], str]
  26. int: Callable[[integer[Any]], str]
  27. timedelta: Callable[[timedelta64], str]
  28. datetime: Callable[[datetime64], str]
  29. float: Callable[[floating[Any]], str]
  30. longfloat: Callable[[longdouble], str]
  31. complexfloat: Callable[[complexfloating[Any, Any]], str]
  32. longcomplexfloat: Callable[[clongdouble], str]
  33. void: Callable[[void], str]
  34. numpystr: Callable[[_CharLike_co], str]
  35. object: Callable[[object], str]
  36. all: Callable[[object], str]
  37. int_kind: Callable[[integer[Any]], str]
  38. float_kind: Callable[[floating[Any]], str]
  39. complex_kind: Callable[[complexfloating[Any, Any]], str]
  40. str_kind: Callable[[_CharLike_co], str]
  41. class _FormatOptions(TypedDict):
  42. precision: int
  43. threshold: int
  44. edgeitems: int
  45. linewidth: int
  46. suppress: bool
  47. nanstr: str
  48. infstr: str
  49. formatter: None | _FormatDict
  50. sign: Literal["-", "+", " "]
  51. floatmode: _FloatMode
  52. legacy: Literal[False, "1.13", "1.21"]
  53. def set_printoptions(
  54. precision: None | SupportsIndex = ...,
  55. threshold: None | int = ...,
  56. edgeitems: None | int = ...,
  57. linewidth: None | int = ...,
  58. suppress: None | bool = ...,
  59. nanstr: None | str = ...,
  60. infstr: None | str = ...,
  61. formatter: None | _FormatDict = ...,
  62. sign: Literal[None, "-", "+", " "] = ...,
  63. floatmode: None | _FloatMode = ...,
  64. *,
  65. legacy: Literal[None, False, "1.13", "1.21"] = ...
  66. ) -> None: ...
  67. def get_printoptions() -> _FormatOptions: ...
  68. def array2string(
  69. a: ndarray[Any, Any],
  70. max_line_width: None | int = ...,
  71. precision: None | SupportsIndex = ...,
  72. suppress_small: None | bool = ...,
  73. separator: str = ...,
  74. prefix: str = ...,
  75. # NOTE: With the `style` argument being deprecated,
  76. # all arguments between `formatter` and `suffix` are de facto
  77. # keyworld-only arguments
  78. *,
  79. formatter: None | _FormatDict = ...,
  80. threshold: None | int = ...,
  81. edgeitems: None | int = ...,
  82. sign: Literal[None, "-", "+", " "] = ...,
  83. floatmode: None | _FloatMode = ...,
  84. suffix: str = ...,
  85. legacy: Literal[None, False, "1.13", "1.21"] = ...,
  86. ) -> str: ...
  87. def format_float_scientific(
  88. x: _FloatLike_co,
  89. precision: None | int = ...,
  90. unique: bool = ...,
  91. trim: Literal["k", ".", "0", "-"] = ...,
  92. sign: bool = ...,
  93. pad_left: None | int = ...,
  94. exp_digits: None | int = ...,
  95. min_digits: None | int = ...,
  96. ) -> str: ...
  97. def format_float_positional(
  98. x: _FloatLike_co,
  99. precision: None | int = ...,
  100. unique: bool = ...,
  101. fractional: bool = ...,
  102. trim: Literal["k", ".", "0", "-"] = ...,
  103. sign: bool = ...,
  104. pad_left: None | int = ...,
  105. pad_right: None | int = ...,
  106. min_digits: None | int = ...,
  107. ) -> str: ...
  108. def array_repr(
  109. arr: ndarray[Any, Any],
  110. max_line_width: None | int = ...,
  111. precision: None | SupportsIndex = ...,
  112. suppress_small: None | bool = ...,
  113. ) -> str: ...
  114. def array_str(
  115. a: ndarray[Any, Any],
  116. max_line_width: None | int = ...,
  117. precision: None | SupportsIndex = ...,
  118. suppress_small: None | bool = ...,
  119. ) -> str: ...
  120. def set_string_function(
  121. f: None | Callable[[ndarray[Any, Any]], str], repr: bool = ...
  122. ) -> None: ...
  123. def printoptions(
  124. precision: None | SupportsIndex = ...,
  125. threshold: None | int = ...,
  126. edgeitems: None | int = ...,
  127. linewidth: None | int = ...,
  128. suppress: None | bool = ...,
  129. nanstr: None | str = ...,
  130. infstr: None | str = ...,
  131. formatter: None | _FormatDict = ...,
  132. sign: Literal[None, "-", "+", " "] = ...,
  133. floatmode: None | _FloatMode = ...,
  134. *,
  135. legacy: Literal[None, False, "1.13", "1.21"] = ...
  136. ) -> _GeneratorContextManager[_FormatOptions]: ...