rougier / numpy-100

100 numpy exercises (with solutions)
MIT License
12.17k stars 5.74k forks source link

Question # 35 #194

Open areeb-h-qureshi opened 1 year ago

areeb-h-qureshi commented 1 year ago

With new casting rules, input arrays must be specified as a float inorder for np.divide to work. Otherwise casting of np.divide must be set to 'unsafe'

A = np.ones(3)1 A.astype('float') # Possible fix B = np.ones(3)2 B.astype('float') # Possible fix

np.divide(A,2,out=A, casting='unsafe') # Alternative Fix

rougier commented 1 year ago

Even with strict casting rules, all arrays are float arrays so I don't understand why np.divide would complain