[Numpy-discussion] choose() broadcasting, and Trac

Roman Bertle bertle at smoerz.org
Fri Oct 3 09:14:02 EDT 2008


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:

/usr/lib/python2.5/site-packages/numpy/core/fromnumeric.pyc in choose(a, choices, out, mode)
    167         choose = a.choose
    168     except AttributeError:
--> 169         return _wrapit(a, 'choose', choices, out=out, mode=mode)
    170     return choose(choices, out=out, mode=mode)
    171 

/usr/lib/python2.5/site-packages/numpy/core/fromnumeric.pyc in _wrapit(obj, method, *args, **kwds)
     35     except AttributeError:
     36         wrap = None
---> 37     result = getattr(asarray(obj),method)(*args, **kwds)
     38     if wrap:
     39         if not isinstance(result, mu.ndarray):

ValueError: too many dimensions

I consider this as a bad regression from numarray to numpy, because the
failing broadcast examples seem to be more important than the working
one.

Best Regards, Roman



More information about the NumPy-Discussion mailing list