From: Robert K. <rob...@gm...> - 2006-06-02 18:51:36
|
Alan G Isaac wrote: > 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 My argument does not include the last two points. - They are in wide use because they are convenient and useful. - Changing rand() and randn() to accept a tuple like random.random() and random.standard_normal() does not improve anything. Instead, it adds confusion for users who are reading code and seeing the same function being called in two different ways. - Users who want to see numpy *only* expose a single calling scheme for top-level functions should instead ask for rand() and randn() to be removed from the top numpy namespace. * Backwards compatibility might prevent this. > 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. *Changing* the API of rand() and randn() doesn't solve any problem. *Removing* them might. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco |