def _format_items(items):
formatter = lambda x: '%.3e' % x
last_large_output = None
for key, value in items:
value = np.asarray(value)
large_output = value.ndim >= 1
# If there was a previous output, print a separator.
if last_large_output is not None:
yield '\n' if large_output or last_large_output else ' '
format_string = '%s:\n%s' if large_output else '%s: %s'
yield format_string % (key,
np.array2string(value, style=formatter,
formatter={'float_kind': formatter}))
last_large_output = large_output
评论列表
文章目录