jax.numpy.printoptions

jax.numpy.printoptions#

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

用于设置打印选项的上下文管理器。

设置 with 块范围内的打印选项,并在结束时恢复旧选项。有关可用选项的完整说明,请参阅 set_printoptions

示例

>>> import numpy as np
>>> from numpy.testing import assert_equal
>>> with np.printoptions(precision=2):
...     np.array([2.0]) / 3
array([0.67])

with 语句的 as 子句给出当前的打印选项

>>> with np.printoptions(precision=2) as opts:
...      assert_equal(opts, np.get_printoptions())