[Numpy-discussion] bug in numarray.maximum.reduce ?
Todd Miller
jmiller at stsci.edu
Fri Jul 2 09:03:08 CDT 2004
On Fri, 2004-07-02 at 11:27, Sebastian Haase wrote:
> On Tuesday 29 June 2004 05:05 pm, Sebastian Haase wrote:
> > Hi,
> >
> > Is this a bug?:
> > >>> # (import numarray as na ; 'd' is a 3 dimensional array)
> > >>> d.type()
> >
> > Float32
> >
> > >>> d[80, 136, 122]
> >
> > 80.3997039795
> >
> > >>> na.maximum.reduce(d[:,136, 122])
> >
> > 85.8426361084
> >
> > >>> na.maximum.reduce(d) [136, 122]
> >
> > 37.3658103943
> >
> > >>> na.maximum.reduce(d,0)[136, 122]
> >
> > 37.3658103943
> >
> > >>> na.maximum.reduce(d,1)[136, 122]
> >
> > Traceback (most recent call last):
> > File "<input>", line 1, in ?
> > IndexError: Index out of range
> >
> > I was using na.maximum.reduce(d) to get a "pixelwise" maximum along Z
> > (axis 0). But as seen above it does not get it right. I then tried to
> > reproduce
> >
> > this with some simple arrays, but here it works just fine:
> > >>> a = na.arange(4*4*4)
> > >>> a.shape=(4,4,4)
> > >>> na.maximum.reduce(a)
> >
> > [[48 49 50 51]
> > [52 53 54 55]
> > [56 57 58 59]
> > [60 61 62 63]]
> >
> > >>> a = na.arange(4*4*4).astype(na.Float32)
> > >>> a.shape=(4,4,4)
> > >>> na.maximum.reduce(a)
> >
> > [[ 48. 49. 50. 51.]
> > [ 52. 53. 54. 55.]
> > [ 56. 57. 58. 59.]
> > [ 60. 61. 62. 63.]]
> >
> >
> > Any hint ?
> >
> > Regards,
> > Sebastian Haase
>
> Hi again,
> I think the reason that no one responded to this is that it just sounds to
> unbelievable ...
This just slipped through the cracks for me.
> Sorry for the missing piece of information, but 'd' is actually a memmapped
> array !
> >>> d.info()
> class: <class 'numarray.numarraycore.NumArray'>
> shape: (80, 150, 150)
> strides: (90000, 600, 4)
> byteoffset: 0
> bytestride: 4
> itemsize: 4
> aligned: 1
> contiguous: 1
> data: <MemmapSlice of length:7290000 readonly>
> byteorder: big
> byteswap: 1
> type: Float32
> >>> dd = d.copy()
> >>> na.maximum.reduce(dd[:,136, 122])
> 85.8426361084
> >>> na.maximum.reduce(dd)[136, 122]
> 85.8426361084
> >>>
>
> Apparently we are using memmap so frequently now that I didn't even think
> about that - which is good news for everyone, because it means that it works
> (mostly).
>
> I just see that 'byteorder' is 'big' - I'm running this on an Intel Linux PC.
> Could this be the problem?
I think byteorder is a good guess at this point. What version of Python
and numarray are you using?
Regards,
Todd
More information about the Numpy-discussion
mailing list