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