Convert numpy array to tuple
Here's a function that'll do it:
def totuple(a):
try:
return tuple(totuple(i) for i in a)
except TypeError:
return a
And an example:
>>> array = numpy.array(((2,2),(2,-2)))
>>> totuple(array)
((2, 2), (2, -2))
>>> arr = numpy.array(((2,2),(2,-2)))
>>> tuple(map(tuple, arr))
((2, 2), (2, -2))