[Numpy-discussion] Args for ones, zeros, rand, eye, ones, empty (possible 1.0 change?)

Alan G Isaac aisaac at american.edu
Sun Jul 2 23:24:47 CDT 2006

On Mon, 3 Jul 2006, Bill Baxter apparently wrote: 
> Here's another possible now or never change: 
> fix rand(), eye(), ones(), zeros(), and empty() to ALL take either a tuple 
> argument or plain list. 
> I know this has been discussed before, but I really don't 
> see why these methods can't be overloaded to accept either 
> one. 

I think the discussion has been slightly different than this.
The "numpy way" for array creation is generally to specify 
dimension as tuples.  A small number of functions violate 
this, which is an unhappy inconsistency.  Specifically, 
rand() and randn() violate this.  (Perhaps one could also 
say that eye() violates this; I do not yet have an opinion.)

I argue that rand and randn should accept a tuple as the 
first argument.  Whether the old behavior is also allowed, 
I have no opinion.  But the numpy-consistent behavior should 
definitely be allowed.  I perhaps wrongly understood Robert 
to argue that the current behavior of rand and randn is not 
a wart since i. alternative tuple-accepting functions are 
available and ii. the suprising behavior is documented.  
This seems quite wrong to me, and I am farily confident that 
such an argument would not be offered except in defence of 
legacy code.

In fact, I would argue that if rand and randn are not 
"fixed" to accept a tuple, then they should be moved into 
a compatability module and not be considered part of numpy.

Alan Isaac

More information about the Numpy-discussion mailing list