printoptions.py 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. """
  2. Stores and defines the low-level format_options context variable.
  3. This is defined in its own file outside of the arrayprint module
  4. so we can import it from C while initializing the multiarray
  5. C module during import without introducing circular dependencies.
  6. """
  7. import sys
  8. from contextvars import ContextVar
  9. __all__ = ["format_options"]
  10. default_format_options_dict = {
  11. "edgeitems": 3, # repr N leading and trailing items of each dimension
  12. "threshold": 1000, # total items > triggers array summarization
  13. "floatmode": "maxprec",
  14. "precision": 8, # precision of floating point representations
  15. "suppress": False, # suppress printing small floating values in exp format
  16. "linewidth": 75,
  17. "nanstr": "nan",
  18. "infstr": "inf",
  19. "sign": "-",
  20. "formatter": None,
  21. # Internally stored as an int to simplify comparisons; converted from/to
  22. # str/False on the way in/out.
  23. 'legacy': sys.maxsize,
  24. 'override_repr': None,
  25. }
  26. format_options = ContextVar(
  27. "format_options", default=default_format_options_dict.copy())