On Sun, Mar 16, 2008 at 4:11 AM, Sebastian Haase <[EMAIL PROTECTED]> wrote:

> On Sun, Mar 16, 2008 at 1:08 AM, Charles R Harris
> <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I want to fix up the average function. I note that the return dtype is
> not
> > specified, nor is the precision of the accumulator. Both of these can be
> > specified for the mean method and I wonder what should be the case for
> > average. Or should we just use double precision? That would seem
> appropriate
> > to me most of the time, but wouldn't match what happens with mean and
> would
> > lose precision in the case of extended precision doubles. There is also
> no
> > out keyword, do we want one?
> >
>
> Hi,
> I'm starting to forget... but faintly I'm remembering that there might
> have been some extended discussion about this on this list.
> We work with large multi-dimensional image data, so if, for example, I
> have n (small) 50x512x512 3D-images that I want to average into one
> 50x512x512 image, the most memory I can afford is single precession
> float32. (Also the original dynamic range is 16bit at best anyway)
>
> I was just checking my archives:
> http://projects.scipy.org/scipy/numpy/ticket/465#comment:2 (by
> oliphant) actually already says this.


What I ended up with is double for integer input types and preservation of
float types. Thus float32 will be preserved but int8 will return double.
These are the same rules one gets with A + 0.0, which is how I did it. That
isn't really the most space efficient, however, as in your case a copy of
the data cube will be made.

As to accumulator type and an out variable, there are already so many
parameters in the function that I have become loath to add more at this
point, but it would be easy to specify an accumulator type and specifying an
out variable shouldn't be much worse.

Chuck
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to