Roman Bertle | 3 Oct 15:14

choose() broadcasting, and Trac

Hello,

I have found something I call a bug in the numpy choose() method and
wanted to report it in trac.
http://scipy.org/BugReport states that "SciPy and NumPy Developer Pages
use the same login/password". However, I (username "smoerz") can log in
with my Scipy account at the Scipy Developer Page
(http://projects.scipy.org/scipy/scipy/), but not at the Numpy Developer
Page (http://projects.scipy.org/scipy/numpy/).

Whatever, porting some code from numarray to numpy, I found a regression
in the broadcasting of choose():

import numarray, numpy

numarray.choose([[0,0,1], [0,0,1]], ([2,2,2], [3,3,3]))
array([[2, 2, 3],
       [2, 2, 3]])

numarray.choose([0,0,1], ([[2,2,2],[2,2,2]], [[3,3,3],[3,3,3]]))
array([[2, 2, 3],
       [2, 2, 3]])

numarray.choose([0,0,1], ([2,2,2], [[3,3,3],[3,3,3]]))
array([[2, 2, 3],
       [2, 2, 3]])

Of these 3 cases, only the first one works for numpy, for the other ones
I get:

(Continue reading)

Travis E. Oliphant | 3 Oct 16:52

Re: choose() broadcasting, and Trac

Roman Bertle wrote:
> Hello,
>
> I have found something I call a bug in the numpy choose() method and
> wanted to report it in trac.
>   
Thanks for your report.  I'm not sure why you are having trouble with 
Trac, but I've created a ticket for this problem.

-Travis
Roman Bertle | 17 Oct 15:58

Re: choose() broadcasting

* Travis E. Oliphant <oliphant <at> enthought.com> [081003 22:20]:
> Roman Bertle wrote:
> > Hello,
> >
> > I have found something I call a bug in the numpy choose() method and
> > wanted to report it in trac.
> >   
> Thanks for your report.  I'm not sure why you are having trouble with 
> Trac, but I've created a ticket for this problem.

Hello,

trac works for me know. And thank you for fixing the bug, the svn numpy
version works now for me. But there remains an issue I want to report.
choose is much slower in numpy than in numarray, and even more if an
output array is specified, as these tests show:

import timeit

setups = {
    'numarray': """
import numarray as N

n1, n2 = 4, 1000000
a1 = N.arange(n1*n2, type='Float64', shape=(n1,n2))
a2 = -N.arange(n1*n2, type='Float64', shape=(n1,n2))
a3 = -N.arange(n1*n2, type='Float64', shape=(n1,n2))
b1 = N.arange(n2, type='Float64')
b2 = -N.arange(n2, type='Float64')
b3 = -N.arange(n2, type='Float64')
(Continue reading)

Travis E. Oliphant | 17 Oct 23:31

Re: choose() broadcasting

Roman Bertle wrote:
> * Travis E. Oliphant <oliphant <at> enthought.com> [081003 22:20]:
>   
>> Roman Bertle wrote:
>>     
>>> Hello,
>>>
>>> I have found something I call a bug in the numpy choose() method and
>>> wanted to report it in trac.
>>>   
>>>       
>> Thanks for your report.  I'm not sure why you are having trouble with 
>> Trac, but I've created a ticket for this problem.
>>     
>
> Hello,
>
> trac works for me know. And thank you for fixing the bug, the svn numpy
> version works now for me. But there remains an issue I want to report.
> choose is much slower in numpy than in numarray, and even more if an
> output array is specified, as these tests show:
>   
Thanks for the report.   You should add another ticket for this case.  I 
suspect it might be a result of the extra copies that are done in the 
PyArray_Choose routine because the algorithm assumes contiguous arrays.

It deserves a look.   It probably wouldn't be too difficult to avoid the 
copy.

-Travis
(Continue reading)


Gmane