numpy.printoptions(*args, **kwargs)
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
for the full description of available options.
Notes
These print options apply only to NumPy ndarrays, not to scalars.
Concurrency note: see
Examples
>>> importnumpyasnp>>> fromnumpy.testingimportassert_equal>>> withnp.printoptions(precision=2):... np.array([2.0])/3array([0.67])The as-clause of the with-statement gives the current print options:
>>> withnp.printoptions(precision=2)asopts:... assert_equal(opts,np.get_printoptions())