bug?

Robert Kern robert.kern at gmail.com
Sun Oct 22 18:12:57 CDT 2006


humufr at yahoo.fr wrote:
> Hello, 
> 
> the docstring for compress in numpy give this
> 
> help(numpy.compress)
> 
> compress(condition, m, axis=None, out=None)
>     compress(condition, x, axis=None) = those elements of x corresponding
>     to those elements of condition that are "true".  condition must be the
>     same size as the given dimension of x.
> 
> 
> So (but perhaps I can misundertand the help due to my english) I don't 
> undersand the following error, for me a and c array does have the same 
> dimension and size. So someone can explain me the result please?

The docstring is a bit underspecified. The condition array *must* be a 1D array 
with the same size *as the given axis* of the other array (using the convention 
that axis=None implies operating over the flattened array).

There's simply no valid interpretation of this, for example:

   compress(array([[1, 0, 0],
                   [1, 1, 0]]), arange(6).reshape(2,3))

since numpy arrays cannot be "ragged".

-- 
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


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642




More information about the Numpy-discussion mailing list