From: Robert K. <rob...@gm...> - 2006-10-22 23:13:19
|
hu...@ya... 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 |