From: Bill B. <wb...@gm...> - 2006-07-12 06:09:57
|
> > And mark my words, if we make rand() polymorphic, > we will get just as many newbies coming to the list asking why ones(3, 4) > doesn't work. > I think you're probably right there, at least for Matlab converts. Matlab allows either way of calling for all of rand, ones, zeros, eye, and in general tries to make *every* function accept *any* possible combination of arguments that might make sense. So having rand() accept both, but not the others, will undoubtedly be unexpected to Matlab users. And the argument against funky overloading will be weaker since they'll be able to say "well rand() does it? why can't ones()?" Fortunately it's pretty easy to define one's own custom versions of these little helper functions to make them just the way you like them. Or for rand(), just "from numpy.random import uniform_sample as rand" if that's the version you like. This isn't a panacea, but you can then collect all these into a little customization module, say "mynum.py" which is somewhere on your PYTHONPATH, and then set up all your customizations with a "from mynum import *" You can even go further if you wish and define the PYTHONSTARTUP environment variable to point to a file that does "from mynum import *" so that every time you start up the interactive interpreter you have your definitions there already. I'm sure this is all well known to you long-time Python'ers out there, but I thought I'd mention it since there are probably other numpy users out there who, like me, are pretty new to Python. --bb |
From: Travis O. <oli...@ie...> - 2006-07-12 06:53:00
|
Bill Baxter wrote: > > And mark my words, if we make rand() polymorphic, > > we will get just as many newbies coming to the list asking why > ones(3, 4) > > doesn't work. > > > I think you're probably right there, at least for Matlab converts. > Matlab allows either way of calling for all of rand, ones, zeros, eye, > and in general tries to make *every* function accept *any* possible > combination of arguments that might make sense. So having rand() > accept both, but not the others, will undoubtedly be unexpected to > Matlab users. And the argument against funky overloading will be > weaker since they'll be able to say "well rand() does it? why can't > ones()?" > > Fortunately it's pretty easy to define one's own custom versions of > these little helper functions to make them just the way you like > them. Or for rand(), just "from numpy.random import uniform_sample > as rand" if that's the version you like. Because of this. I've removed the global_namespace functions (fft, ifft, rand, and randn) from numpy. They are *no longer* in the top-level name-space. If you want them, setup a startup-file appropriately. -Travis |
From: Sven S. <sve...@gm...> - 2006-07-12 10:21:30
|
Travis Oliphant schrieb: > > Because of this. I've removed the global_namespace functions (fft, > ifft, rand, and randn) from numpy. They are *no longer* in the > top-level name-space. If you want them, setup a startup-file > appropriately. > Ok I'm glad that's settled; however, do I understand correctly (after looking at the new numpy.matlib for the first time), that numpy.matlib.rand() still doesn't accept tuples, and that the tuple-accepting "full" version is not exposed in numpy.matlib? If so, it would be perfect if numpy.matlib could be augmented by a matrix analogue pointing to numpy.random.random() or whatever its full name is. Then the situation for matrix users is actually quite nice, just have to import everything from numpy.matlib. Thanks, Sven |
From: Bill B. <wb...@gm...> - 2006-07-12 08:47:21
|
On 7/12/06, Travis Oliphant <oli...@ie...> wrote: > > > Because of this. I've removed the global_namespace functions (fft, > ifft, rand, and randn) from numpy. They are *no longer* in the > top-level name-space. If you want them, setup a startup-file > appropriately. > Any hints as to where we can find them now? (more generally -- how is one supposed to find stuff in big python packages to begin with? Like -- "show me anything with 'rand' in the name".) Also, numpy.matlib.rand() needs to be updated to point to the new location as well. --bb |
From: Stefan v. d. W. <st...@su...> - 2006-07-12 09:01:11
|
On Wed, Jul 12, 2006 at 05:47:15PM +0900, Bill Baxter wrote: > On 7/12/06, Travis Oliphant <oli...@ie...> wrote: >=20 >=20 > Because of this. I've removed the global_namespace functions (fft, > ifft, rand, and randn) from numpy. They are *no longer* in the > top-level name-space. If you want them, setup a startup-file > appropriately. >=20 >=20 >=20 > Any hints as to where we can find them now? > (more generally -- how is one supposed to find stuff in big python pack= ages to > begin with? Like -- "show me anything with 'rand' in the name".) It is in numpy.random.rand. If you are using ipython, you can do import numpy numpy.*rand*? which will print out a list of all members that contain "rand". In this case numpy.random. To do a deeper search, use pydoc. You can start it with pydoc -g which should pop up a graphical interface, where you can type in a search term. Click on the results to open the appropriate documentation web page. > Also, numpy.matlib.rand() needs to be updated to point to the new locat= ion as > well. Already fixed in SVN. Cheers St=E9fan |