MCPcopy Index your code
hub / github.com/numpy/numpy / printoptions

Function printoptions

numpy/_core/arrayprint.py:398–435  ·  view source on GitHub ↗

Context manager for setting print options. Set print options for the scope of the `with` block, and restore the old options at the end. See `set_printoptions` for the full description of available options. Examples -------- >>> import numpy as np >>> from numpy.testing

(*args, **kwargs)

Source from the content-addressed store, hash-verified

396@set_module('numpy')
397@contextlib.contextmanager
398def printoptions(*args, **kwargs):
399 """Context manager for setting print options.
400
401 Set print options for the scope of the `with` block, and restore the old
402 options at the end. See `set_printoptions` for the full description of
403 available options.
404
405 Examples
406 --------
407 >>> import numpy as np
408
409 >>> from numpy.testing import assert_equal
410 >>> with np.printoptions(precision=2):
411 ... np.array([2.0]) / 3
412 array([0.67])
413
414 The `as`-clause of the `with`-statement gives the current print options:
415
416 >>> with np.printoptions(precision=2) as opts:
417 ... assert_equal(opts, np.get_printoptions())
418
419 See Also
420 --------
421 set_printoptions, get_printoptions
422
423 Notes
424 -----
425 These print options apply only to NumPy ndarrays, not to scalars.
426
427 **Concurrency note:** see :ref:`text_formatting_options`
428
429 """
430 token = _set_printoptions(*args, **kwargs)
431
432 try:
433 yield get_printoptions()
434 finally:
435 format_options.reset(token)
436
437
438def _leading_trailing(a, edgeitems, index=()):

Callers 6

test_strMethod · 0.90
test_latexMethod · 0.90
test_fixedMethod · 0.90
test_switch_to_expMethod · 0.90
test_non_finiteMethod · 0.90

Calls 2

_set_printoptionsFunction · 0.85
get_printoptionsFunction · 0.85

Tested by 6

test_strMethod · 0.72
test_latexMethod · 0.72
test_fixedMethod · 0.72
test_switch_to_expMethod · 0.72
test_non_finiteMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…