numpy.
array_repr
返回数组的字符串表示形式。
输入数组。
如果文本长度超过 max_line_width .默认为 numpy.get_printoptions()['linewidth'] .
numpy.get_printoptions()['linewidth']
浮点精度。默认为 numpy.get_printoptions()['precision'] .
numpy.get_printoptions()['precision']
将“非常接近”零的数字表示为零;默认值为False。非常接近是由精度定义的:如果精度是8,例如,小于5e-9的数字(绝对值)表示为零。默认为 numpy.get_printoptions()['suppress'] .
numpy.get_printoptions()['suppress']
数组的字符串表示形式。
参见
array_str
array2string
set_printoptions
实例
>>> np.array_repr(np.array([1,2])) 'array([1, 2])' >>> np.array_repr(np.ma.array([0.])) 'MaskedArray([0.])' >>> np.array_repr(np.array([], np.int32)) 'array([], dtype=int32)'
>>> x = np.array([1e-6, 4e-7, 2, 3]) >>> np.array_repr(x, precision=6, suppress_small=True) 'array([0.000001, 0. , 2. , 3. ])'