Re: [Numpy-discussion] Profiling (was GSoC : Performance parity between numpy arrays and Python scalars)

2013-06-07 Thread Arink Verma
I did profiling for $python -m timeit -n 100 -s 'import numpy as np;x = np.asarray(1.0)' 'x+x' with oprofilier, and used gprof2dot.py to create callgraph, but I got graph[1] which doesn't create any meaning. I tried to use pprof, but I can not find profiles to be used. like ls.prof in "pprof /

Re: [Numpy-discussion] adding booleans

2013-06-07 Thread josef . pktd
On Fri, Jun 7, 2013 at 8:08 PM, wrote: > On Fri, Jun 7, 2013 at 7:48 PM, Nathaniel Smith wrote: >> On 7 Jun 2013 21:58, wrote: >>> >>> Interesting observation, (while lurking on a pull request) >>> >>> >>> np.add.reduce(np.arange(5)<3) >>> 3 >>> >>> np.add((np.arange(5)<3), (np.arange(5)<3)) >>

Re: [Numpy-discussion] adding booleans

2013-06-07 Thread josef . pktd
On Fri, Jun 7, 2013 at 7:48 PM, Nathaniel Smith wrote: > On 7 Jun 2013 21:58, wrote: >> >> Interesting observation, (while lurking on a pull request) >> >> >>> np.add.reduce(np.arange(5)<3) >> 3 >> >>> np.add((np.arange(5)<3), (np.arange(5)<3)) >> array([ True, True, True, False, False], dtype=

Re: [Numpy-discussion] adding booleans

2013-06-07 Thread Nathaniel Smith
On 7 Jun 2013 21:58, wrote: > > Interesting observation, (while lurking on a pull request) > > >>> np.add.reduce(np.arange(5)<3) > 3 > >>> np.add((np.arange(5)<3), (np.arange(5)<3)) > array([ True, True, True, False, False], dtype=bool) > > > I often use summing of an array of boolean but didn't

[Numpy-discussion] adding booleans

2013-06-07 Thread josef . pktd
Interesting observation, (while lurking on a pull request) >>> np.add.reduce(np.arange(5)<3) 3 >>> np.add((np.arange(5)<3), (np.arange(5)<3)) array([ True, True, True, False, False], dtype=bool) I often use summing of an array of boolean but didn't know the second behavior Josef _

Re: [Numpy-discussion] What's the difference between calling __mul__ and *?

2013-06-07 Thread Will Lee
I think I've figured this out. It seems like the rule in the "Note" box is the problem. Since a matrix is not a subclass of my custom class, the __rmul__ of the matrix is not being called. Thanks for the info. Will On Fri, Jun 7, 2013 at 11:40 AM, Alan G Isaac wrote: > On 6/7/2013 12:30 PM,

Re: [Numpy-discussion] What's the difference between calling __mul__ and *?

2013-06-07 Thread Alan G Isaac
On 6/7/2013 12:30 PM, Will Lee wrote: > Can somebody tell me why these operations are not the same in numpy? http://docs.python.org/2/reference/datamodel.html#object.__rmul__ hth, Alan Isaac ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org

Re: [Numpy-discussion] What's the difference between calling __mul__ and *?

2013-06-07 Thread Toder, Evgeny
That's how it works in python: """ Note: If the right operand's type is a subclass of the left operand's type and that subclass provides the reflected method for the operation, this method will be called before the left operand's non-reflected method. This behavior allows subclasses to override

[Numpy-discussion] What's the difference between calling __mul__ and *?

2013-06-07 Thread Will Lee
Can somebody tell me why these operations are not the same in numpy? In [2]: a = numpy.array([1, 2, 3.]) In [4]: matrix = numpy.matrix([[1, 2, 3.], [4, 5, 6], [7, 8, 9]]) In [5]: a.__mul__(matrix) matrix([[ 1., 4., 9.], [ 4., 10., 18.], [ 7., 16., 27.]]) In [6]: a