[Numpy-discussion] compress numpy vs .numarray

Robert Kern robert.kern at gmail.com
Thu Jan 4 19:06:52 CST 2007


Sebastian Haase wrote:
> Hi!
> when calling compress
> I get this error message after moving to numpy:
> 
> ValueError: 'condition must be 1-d array'
> 
> Is the reason for this the change of the default axis from
> axis=0
> to
> axis=None

Not really, it's just that N-d arrays don't make much sense as condition masks.
The only reasonable interpretation is that one takes the flattened form of both
the condition mask and the target array; however, this is an implicit
interpretation of what the user wants. As explicit is usually better than
implicit, just flatten the condition mask.

> What does axis=None mean in this case !?

That the condition mask applies to the flattened array.

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


More information about the Numpy-discussion mailing list