[Numpy-discussion] Putting some random back into the top-level?

Timothy Hochberg tim.hochberg at ieee.org
Wed Mar 14 13:21:34 EDT 2007


On 3/14/07, Sebastian Haase <haase at msg.ucsf.edu> wrote:
>
> Hi,
> Please remind me what's wrong with pylab's
> rand and randn !
> I just learned about their existence recently and thought
> they seem quite handy and should  go directly into (the top-level of)
> numpy.
> Functions that have the same name and do the same thing don't conflict
> either ;-)


I don't know what the problem, if any, is with rand and randn, but I can
tell you what the problem with stuffing stuff in the main namespace is: it's
allready much too crowded, which makes it difficult to find functions when
you need them. Have you tried dir(numpy) recently?

If all of the random number functions live in one package, it's easy to scan
them, see what's there and decide what is appropriate, if they are smeared
out across multiple packages. You might say that we should put these
functions in both the top level package and in the relevant subpackage, but
then it's difficult to find what packages exist since the top level package
is too crowded (a situation that already exists today to a certain extent).

Note that it's pretty easy for a downstream user to create a customized
package that pulls in all of the functions that they feel are deserving: a
file with just "from numpy import *; from numpy.random import randn" comes
to mind. It's considerably more difficult for such a user to trim the main
namespace in a sensible way. Thus, it's my opinion that we should be moving
stuff out of the main package, not putting stuff in.

Regards,


-Sebastian
>
>
>
> On 3/12/07, Rob Hetland <hetland at tamu.edu> wrote:
> >
> > I, for one, would also like this.  Perhaps it should not be called
> > 'rand', however, as that conflicts with the pylab rand.  (numpy load
> > and pylab load also conflict -- probably the only reason I ever use
> > import pylab as pl in my scripts).  'random' is already taken by the
> > whole package... What does this leave that is still sensible?
> >
> > -r
> >
> > On Mar 9, 2007, at 2:01 PM, Bill Baxter wrote:
> >
> > > Has enough time passed with no top level random function that we can
> > > now put one back in?
> > > If I recall, the former top level rand() was basically removed because
> > > it didn't adhere to the "shapes are always tuples" convention.
> > >
> > > Has enough time passed now that we can put something like it back in
> > > the top level, in tuple-taking form?
> > >
> > > I think this is a function people use pretty frequently when writing
> > > quick tests.
> > > And numpy.random.random_sample seems a rather long and not so obvious
> > > name for something that is used relatively frequently.
> > >
> > > --bb
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>



-- 

//=][=\\

tim.hochberg at ieee.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20070314/1c5ce8de/attachment.html>


More information about the NumPy-Discussion mailing list