[Numpy-discussion] sum and mean methods behaviour

Robert Kern kern at caltech.edu
Tue Sep 2 14:32:03 EDT 2003


On Tue, Sep 02, 2003 at 01:20:17PM -0600, Fernando Perez wrote:
> Todd Miller wrote:
> 
> >I thought about this a lot yesterday and today talked it over with
> >Perry.   There are several ways to fix the problem with mean() and
> >sum(), and I'm hoping that you and the rest of the community will help
> >sort them out.
> 
> [snip]
> 
> Just a thought: why not make the upcasting an optional parameter?
> 
> I've found that python's arguments with default values provide a very 
> convenient way of giving the user fine control with minimal conceptual 
> overhead.
> 
> I'd rather write:
> 
> arr = array([255, 255], Int8)
> ... later
> arr.sum(use_double=1)  # or some similar way of tuning sum()

+1, but

arr.sum(typecode=Float64)

would be my choice of spelling. Not sure what the default typecode
should be, though. Probably Perry's suggestion: the largest type of the
family.

-- 
Robert Kern
kern at caltech.edu

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter




More information about the NumPy-Discussion mailing list