Skip to content

Instantly share code, notes, and snippets.

@ccorcos
Created April 22, 2014 23:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ccorcos/11197543 to your computer and use it in GitHub Desktop.
Save ccorcos/11197543 to your computer and use it in GitHub Desktop.
Python NumPy: pretty print multidimensional ndarray
from pylab import *
from pprint import pprint
def arrayToList(arr):
if type(arr) == type(array([])):
return arrayToList(arr.tolist())
elif type(arr) == type([]):
return [arrayToList(a) for a in arr]
else:
return arr
def prettyArray(arr):
pprint(arrayToList(arr))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment