[Numpy-discussion] `out` argument to ufuncs
Robert Kern
robert.kern@gmail....
Thu Sep 4 02:16:19 CDT 2008
On Thu, Sep 4, 2008 at 02:03, Stéfan van der Walt <stefan@sun.ac.za> wrote:
> Hey all,
>
> Gael just asked me why `add`, `subtract` etc. didn't have out
> arguments like `cos` and `sin`. I couldn't give him a good answer.
>
> Could we come to an agreement to add a uniform interface to ufuncs for
> 1.3? Either all or none of them should support the out argument.
I am confused. add() and subtract() *do* take an out argument.
In [15]: from numpy import *
In [16]: x = arange(10, 20)
In [17]: y = arange(10)
In [18]: z = zeros(10, int)
In [19]: add(x,y,z)
Out[19]: array([10, 12, 14, 16, 18, 20, 22, 24, 26, 28])
In [20]: z
Out[20]: array([10, 12, 14, 16, 18, 20, 22, 24, 26, 28])
In [21]: subtract(x,y,z)
Out[21]: array([10, 10, 10, 10, 10, 10, 10, 10, 10, 10])
In [22]: z
Out[22]: array([10, 10, 10, 10, 10, 10, 10, 10, 10, 10])
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the Numpy-discussion
mailing list