Created
July 25, 2018 20:24
-
-
Save vinaykudari/df084a8a36155c024a8a3cf16846ca91 to your computer and use it in GitHub Desktop.
ufunc.at
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = np.random.randint(5,10,5) | |
>> a | |
[6 5 8 8 7] | |
np.add.at(a,np.flatnonzero(a>8),2) #flatnonzero returns the indices where values are >8 | |
>> a | |
[6 5 10 10 9] | |
np.maximum.at(a,[0,1,2],60) #checks the max value | |
>> a | |
[60 60 60 10 9] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment