TypeError: 'NoneType' object does not support item assignment

Posted by R S John on Stack Overflow See other posts from Stack Overflow or by R S John
Published on 2013-10-26T09:46:56Z Indexed on 2013/10/26 9:53 UTC
Read the original article Hit count: 290

Filed under:
|

I am trying to do some mathematical calculation according to the values at particular index of a NumPy array with the following code

X = np.arange(9).reshape(3,3)
temp = X.copy().fill(5.446361E-01)
ind = np.where(X < 4.0)
temp[ind] = 0.5*X[ind]**2 - 1.0
ind = np.where(X >= 4.0 and X < 9.0)
temp[ind] = (5.699327E-1*(X[ind]-1)**4)/(X[ind]**4)
print temp

But I am getting the following error

Traceback (most recent call last):
File "test.py", line 7, in <module>
temp[ind] = 0.5*X[ind]**2 - 1.0 
TypeError: 'NoneType' object does not support item assignment

Would you please help me in solving this? Thanks

© Stack Overflow or respective owner

Related posts about python

Related posts about numpy