Created
October 10, 2015 11:07
-
-
Save peace098beat/619748aa2042aa65f523 to your computer and use it in GitHub Desktop.
[PrintNdarray] Numpy配列のPrint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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