python - Apply formula to specific numpy array values -


i have 2 dimensional array in numpy , need apply mathematical formula values of array match criteria. can made using loop , if conditions think using numpy where() method works faster.

my code far doesn't work

cond2 = np.where((spn >= -alpha) & (spn <= 0)) spn[cond2] = -1*math.cos((spn[cond2]*math.pi)/(2*alpha)) 

the values in orginal array need replaced corresponding value after applying formula.

any ideas of how make work? i'm working big arrays need , efficient way of doing it. thanks

try this:

cond2 = (spn >= -alpha) & (spn <= 0) spn[cond2] = -np.cos(spn[cond2]*np.pi/(2*alpha)) 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -