numpy.printoptions — NumPy v1.15 Manual (original) (raw)
numpy. printoptions(*args, **kwargs)[source]¶
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.
See also
set_printoptions, get_printoptions
Examples
with np.printoptions(precision=2): ... print(np.array([2.0])) / 3 [0.67]
The _as_-clause of the _with_-statement gives the current print options:
with np.printoptions(precision=2) as opts: ... assert_equal(opts, np.get_printoptions())