I'm trying to define a wrapper class having an attribute of type numpy.ndarray. That attribute must be initialised by calling __init__().
The script runs as expected for 1D arrays. However, in the case of multi-dimensionnal arrays, python returns the following error : only length-1 arrays can be converted to Python scalars
import numpy as np
class myArr(np.ndarray):
def __init__(self,Arr):
self.Arr = Arr
npArr = np.zeros((3)) # works
#npArr = np.zeros((3,5)) # does not work
print npArr
wrappedArr = myArr(npArr)
print wrappedArr.Arr
What is happening here ?
python 2.7.6, numpy 1.8.2