[Numpy-discussion] numarray-BUG in arr.maximum.reduce: negative axis returns "transpose"

Paul Barrett pebarrett at gmail.com
Wed Mar 22 05:33:09 CST 2006


On 3/21/06, Sebastian Haase <haase at msg.ucsf.edu> wrote:
>
> Hi,
> I think I discovered another "ugly" bug:
> If have an array with rank 4. I thought
> numarray.maximum.reduce(arr, 1)
> would be identical to
> .numarray.maximum.reduce(arr, -3)
> But instead I get something that looks more like the transpose of the
> first !
> I tried to check the documentation for the numarray.maximum function,
> but there is none at  [8. Array Functions
> http://stsdas.stsci.edu/numarray/numarray-1.5.html/node38.html]
>
> This is a test a ran afterwards:
> >>> q=na.arange(8)
> >>> q.shape = (2,2,2)
> >>> q
> [[[0 1]
>   [2 3]]
> [[4 5]
>   [6 7]]]
> >>> na.maximum.reduce(q)
> [[4 5]
> [6 7]]
> >>> na.maximum.reduce(q,0)
> [[4 5]
> [6 7]]
> >>> na.maximum.reduce(q,1)
> [[2 3]
> [6 7]]
> >>> na.maximum.reduce(q,-1)
> [[1 3]
> [5 7]]
>
> So its not really the transpose - but in any case it's something
> strange...
>

The above behavior for maximum.reduce looks consistent to me.

The reduce axis for examples 1 and 2 above is 0, so maximum is comparing
arrays [[0 1] [2 3]] and [[4 5] [6 7]], which gives [[4 5] [6 7]].  Example
3 is comparing arrays [[0 1] [4 5]] and [[2 3] [6 7]], giving [[2 3] [6
7]].  And the last example is comparing arrays [[0 2] [4 6]] and [[1 3] [5
7]], giving [[1 3] [5 7]].

I think it depends on how you look at the shape of the array.

 -- Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20060322/82599074/attachment.html 


More information about the Numpy-discussion mailing list