numpy.printoptions#

numpy.printoptions(*args,**kwargs)[source]#

Context manager for setting print options.

Set print options for the scope of thewith block, and restore the oldoptions at the end. Seeset_printoptions for the full description ofavailable options.

Notes

These print options apply only to NumPy ndarrays, not to scalars.

Concurrency note: seeText formatting options

Examples

>>>importnumpyasnp
>>>fromnumpy.testingimportassert_equal>>>withnp.printoptions(precision=2):...np.array([2.0])/3array([0.67])

Theas-clause of thewith-statement gives the current print options:

>>>withnp.printoptions(precision=2)asopts:...assert_equal(opts,np.get_printoptions())
On this page