inplace unary operations?
![](https://secure.gravatar.com/avatar/ad13088a623822caf74e635a68a55eae.jpg?s=120&d=mm&r=g)
Is there a way to negate a boolean, or to change the sign of a float inplace ? Josef random thoughts
![](https://secure.gravatar.com/avatar/97c543aca1ac7bbcfb5279d0300c8330.jpg?s=120&d=mm&r=g)
On Sat, Aug 30, 2014 at 6:43 PM, <josef.pktd@gmail.com> wrote:
Is there a way to negate a boolean, or to change the sign of a float inplace ?
np.logical_not(arr, out=arr) np.negative(arr, out=arr) -n -- Nathaniel J. Smith Postdoctoral researcher - Informatics - University of Edinburgh http://vorpus.org
![](https://secure.gravatar.com/avatar/09939f25b639512a537ce2c90f77f958.jpg?s=120&d=mm&r=g)
Random thoughts are the best kinds of thoughts! I didn't even know there was a np.negative() function! I will keep this card up my sleeve at work for one of those save-the-day moments in optimization. Cheers! Ben Root On Sat, Aug 30, 2014 at 1:45 PM, Nathaniel Smith <njs@pobox.com> wrote:
![](https://secure.gravatar.com/avatar/97c543aca1ac7bbcfb5279d0300c8330.jpg?s=120&d=mm&r=g)
On Sat, Aug 30, 2014 at 7:39 PM, Benjamin Root <ben.root@ou.edu> wrote:
Random thoughts are the best kinds of thoughts! I didn't even know there was a np.negative() function!
Me neither, I had to look it up :-) -n -- Nathaniel J. Smith Postdoctoral researcher - Informatics - University of Edinburgh http://vorpus.org
![](https://secure.gravatar.com/avatar/400c17499a145ded79f144644966cb88.jpg?s=120&d=mm&r=g)
Just to point out another solution to change the sign:
arr *= -1
Both solutions take the same time on my computer. However, the boolean equivalent:
arr ^= True
is a lot slower than using negative. My two cents ... -- Dr. Barbier de Reuille, Pierre Institute of Plant Sciences Altenbergrain 21, CH-3013 Bern, Switzerland http://www.botany.unibe.ch/associated/systemsx/index.php On 31 August 2014 15:31, <josef.pktd@gmail.com> wrote:
![](https://secure.gravatar.com/avatar/97c543aca1ac7bbcfb5279d0300c8330.jpg?s=120&d=mm&r=g)
On Sat, Aug 30, 2014 at 6:43 PM, <josef.pktd@gmail.com> wrote:
Is there a way to negate a boolean, or to change the sign of a float inplace ?
np.logical_not(arr, out=arr) np.negative(arr, out=arr) -n -- Nathaniel J. Smith Postdoctoral researcher - Informatics - University of Edinburgh http://vorpus.org
![](https://secure.gravatar.com/avatar/09939f25b639512a537ce2c90f77f958.jpg?s=120&d=mm&r=g)
Random thoughts are the best kinds of thoughts! I didn't even know there was a np.negative() function! I will keep this card up my sleeve at work for one of those save-the-day moments in optimization. Cheers! Ben Root On Sat, Aug 30, 2014 at 1:45 PM, Nathaniel Smith <njs@pobox.com> wrote:
![](https://secure.gravatar.com/avatar/97c543aca1ac7bbcfb5279d0300c8330.jpg?s=120&d=mm&r=g)
On Sat, Aug 30, 2014 at 7:39 PM, Benjamin Root <ben.root@ou.edu> wrote:
Random thoughts are the best kinds of thoughts! I didn't even know there was a np.negative() function!
Me neither, I had to look it up :-) -n -- Nathaniel J. Smith Postdoctoral researcher - Informatics - University of Edinburgh http://vorpus.org
![](https://secure.gravatar.com/avatar/400c17499a145ded79f144644966cb88.jpg?s=120&d=mm&r=g)
Just to point out another solution to change the sign:
arr *= -1
Both solutions take the same time on my computer. However, the boolean equivalent:
arr ^= True
is a lot slower than using negative. My two cents ... -- Dr. Barbier de Reuille, Pierre Institute of Plant Sciences Altenbergrain 21, CH-3013 Bern, Switzerland http://www.botany.unibe.ch/associated/systemsx/index.php On 31 August 2014 15:31, <josef.pktd@gmail.com> wrote:
participants (4)
-
Benjamin Root
-
josef.pktd@gmail.com
-
Nathaniel Smith
-
Pierre Barbier de Reuille