It seems to me that these are strings ndarray.
>>> numpy.array(['1', '2', '3']) * numpy.array(['1', '2', '3'])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for *: 'numpy.ndarray' and 'numpy.ndarray'
You need to convert them to floatsor intif you want to propagate them:
>>> numpy.array([1, 2, 3]) * numpy.array([1, 2, 3])
array([1, 4, 9])
One way to do this could be something like this. (But it depends on what you switch to the function.)
Istack1 = np.array(map(float, Istack1))
Or using a list comprehension:
Istack1 = np.array([float(i) for i in Istack1])
Or, stealing from HYRY (I forgot about the obvious approach):
Istack1 = np.array(Istack1, dtype='f8')
source
share