[Numpy-discussion] rand argument question

Alan G Isaac aisaac at american.edu
Fri Jun 2 13:41:27 EDT 2006

On Fri, 02 Jun 2006, Sven Schreiber apparently wrote: 
> why doesn't rand accept a shape tuple as argument?  I find 
> the difference between the argument types of rand and (for 
> example) zeros somewhat confusing.  ... Can anybody offer 
> an intuition/explanation? 

Backward compatability, I believe.  You are not alone in 
finding this odd and inconsistent.  I am hoping for a change 
by 1.0, but I am not very hopeful.

Robert always points out that if you want the consistent 
interface, you can always import functions from the 'random' 
module.  I have never been able to understand this as 
a response to the point you are making.

I take it the core argument goes something like this:
- rand and randn are convenience functions
        * if you do not find them convenient, don't use them
- they are in wide use, so it is too late to change them
- testing the first argument to see whether it is a tuple or 
  an int so aesthetically objectionable that its ugliness 
  outweighs the benefits users might get from access to 
  a more consistent interface

This is one place where I believe a forward looking (i.e., 
think about new users) vision would force a small change in 
these *convenience* functions that will have payoffs both in 
ease of use and in eliminating this recurrent question from 
discussion lists.

Alan Isaac

More information about the NumPy-Discussion mailing list