[Numpy-discussion] Counting array elements

Peter Verveer verveer at embl-heidelberg.de
Mon Oct 25 01:37:05 CDT 2004

On 25 Oct 2004, at 04:17, Stephen Walton wrote:

> On Fri, 2004-10-22 at 14:47, Fernando Perez wrote:
>> silly, minor nit: can we avoid mixed case names? Either sum_all or 
>> SumAll? I'm
>> not too fond of CamelCase, but camelCase looks even worse to me :)
> I agree with Fernando about CamelCase (which among other things
> seriously bites one when moving from case-sensitive to case-insensitive
> OS's).  But I want to make a broader point:
> I don't think we need sumall.  The methods and the functions should
> simply work the same way.  If one wants sumall, use A.flat.sum() or, if
> you can't use the methods or attributes on your old version of Python,
> sum(ravel(A)).  If you start writing sumall, then you'll need meanall,
> stdall, prodall, etc, etc.  The flat attribute and ravel 
> function/method
> already provide all the needed functionality.

I think this may be inefficient, because ravel and flat may make a copy 
of the data. Also I think using flat/ravel in such a way is plain ugly 
and a complex way to do it.

But I do agree that it is not a good idea to introduce another set of 
names. In my opinion functions that calculate a statistic like sum 
should return the total in the first place, rather then over a single 
axis. But I guess it is too late to change that for sum, because of 
backward compatibility.

Cheers, Peter

More information about the Numpy-discussion mailing list