Skip to content

Instantly share code, notes, and snippets.

@peace098beat
Created October 10, 2015 11:07
Show Gist options
  • Save peace098beat/619748aa2042aa65f523 to your computer and use it in GitHub Desktop.
Save peace098beat/619748aa2042aa65f523 to your computer and use it in GitHub Desktop.
[PrintNdarray] Numpy配列のPrint
# numpy配列をプリントした場合の表示桁数
np.set_printoptions(precision=3)
def ndprint(a, format_string='{0:.2f}'):
"""
ndarrayをprintする関数
:example: ndprint(x)
"""
return [format_string.format(v, i) for i, v in enumerate(a)]
def ndprints(s, a, format_string='{0:.2f}'):
"""
ndarrayをprintする関数
:example: ndprint(x)
"""
print s, [format_string.format(v, i) for i, v in enumerate(a)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment