|
From: Mark B. <ma...@gm...> - 2007-04-24 07:32:07
|
Hello list - I am confused about the part of numpy that pylab imports. Apparently, pylab imports 'zeros', but not the 'zeros' from numpy, as it returns integers by default, rather than floats. The same holds for 'ones' and 'empty'. Example: >>> from pylab import * >>> zeros(3) array([0, 0, 0]) >>> from numpy import * >>> zeros(3) array([ 0., 0., 0.]) Can this be fixed? Any explanation how this happens? Pylab just imports part of numpy, doesn't it? Thanks, Mark |
|
From: <jk...@ik...> - 2007-04-24 08:22:44
|
"Mark Bakker" <ma...@gm...> writes: > Can this be fixed? Any explanation how this happens? Pylab just > imports part of numpy, doesn't it? It imports numerix, a compatibility layer for numeric, numarray and numpy. I think the plan is to remove numerix soon and just use numpy, but in the meantime, I suggest adding "from numpy import *" after "from pylab import *". -- Jouni K. Seppänen http://www.iki.fi/jks |
|
From: Gary R. <gr...@bi...> - 2007-04-24 09:41:10
|
Hi Mark, this thread may help: http://thread.gmane.org/gmane.comp.python.numeric.general/13399/focus=13421 Essentially, pylab uses a compatibility layer to ease the task of supporting the three array packages - currently this uses the Numeric version of the ones and zeros functions giving the behaviour you observe - this will be fixed when pylab drops support for the older packages, which should be soon. Gary R. Mark Bakker wrote: > Hello list - > > I am confused about the part of numpy that pylab imports. > Apparently, pylab imports 'zeros', but not the 'zeros' from numpy, as it > returns integers by default, rather than floats. > The same holds for 'ones' and 'empty'. > Example: > >>> from pylab import * > >>> zeros(3) > array([0, 0, 0]) > >>> from numpy import * > >>> zeros(3) > array([ 0., 0., 0.]) > > Can this be fixed? Any explanation how this happens? Pylab just imports > part of numpy, doesn't it? > > Thanks, > > Mark |
|
From: Mark B. <ma...@gm...> - 2007-04-25 13:54:31
|
Well, if I can cast a vote, it would make a lot of sense if pylab functions do the same thing as numpy functions. Right now it is exceedingly confusing when I teach, that zeros() could be integers or floats. An rc parameter where we would import straight from numpy would be most excellent. Can't wait! Thanks for the explanations, Mark On 4/24/07, Eric Firing <ef...@ha...> wrote: > > Gary Ruben wrote: > > Hi Mark, > > this thread may help: > > > http://thread.gmane.org/gmane.comp.python.numeric.general/13399/focus=13421 > > > > Essentially, pylab uses a compatibility layer to ease the task of > > supporting the three array packages - currently this uses the Numeric > > version of the ones and zeros functions giving the behaviour you observe > > - this will be fixed when pylab drops support for the older packages, > > which should be soon. > > What we will do is drop the use of numerix internally, but the numerix > module will almost certainly remain, presumably with the Numeric and > numarray support removed; so numerix will still use numpy's own > "oldnumeric" compatibility layer, and I expect pylab will still import > from it--at least, by default. The intention is to avoid breaking > things unnecessarily. I can imagine possible variations, such as using > an rc param to tell pylab whether to import from plain numpy or from > oldnumeric, and splitting pylab into core pylab functions (figure, show, > etc.) versus the convenience all-in-one namespace (mostly from numpy); > but we will take one step at a time. > > Eric > > > > > Gary R. > > > > Mark Bakker wrote: > >> Hello list - > >> > >> I am confused about the part of numpy that pylab imports. > >> Apparently, pylab imports 'zeros', but not the 'zeros' from numpy, as > it > >> returns integers by default, rather than floats. > >> The same holds for 'ones' and 'empty'. > >> Example: > >> >>> from pylab import * > >> >>> zeros(3) > >> array([0, 0, 0]) > >> >>> from numpy import * > >> >>> zeros(3) > >> array([ 0., 0., 0.]) > >> > >> Can this be fixed? Any explanation how this happens? Pylab just imports > >> part of numpy, doesn't it? > >> > >> Thanks, > >> > >> Mark > > > > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by DB2 Express > > Download DB2 Express C - the FREE version of DB2 express and take > > control of your XML. No limits. Just data. Click to get it now. > > http://sourceforge.net/powerbar/db2/ > > _______________________________________________ > > Matplotlib-users mailing list > > Mat...@li... > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > |
|
From: Alan G I. <ai...@am...> - 2007-04-25 14:27:52
|
On Wed, 25 Apr 2007, Mark Bakker apparently wrote: > it would make a lot of sense if pylab functions > do the same thing as numpy functions. Yes. This should be the default. Backward compatability can be provided via numpy's compatability module. A user's view, Alan Isaac |
|
From: Eric F. <ef...@ha...> - 2007-04-24 19:10:53
|
Gary Ruben wrote: > Hi Mark, > this thread may help: > http://thread.gmane.org/gmane.comp.python.numeric.general/13399/focus=13421 > > Essentially, pylab uses a compatibility layer to ease the task of > supporting the three array packages - currently this uses the Numeric > version of the ones and zeros functions giving the behaviour you observe > - this will be fixed when pylab drops support for the older packages, > which should be soon. What we will do is drop the use of numerix internally, but the numerix module will almost certainly remain, presumably with the Numeric and numarray support removed; so numerix will still use numpy's own "oldnumeric" compatibility layer, and I expect pylab will still import from it--at least, by default. The intention is to avoid breaking things unnecessarily. I can imagine possible variations, such as using an rc param to tell pylab whether to import from plain numpy or from oldnumeric, and splitting pylab into core pylab functions (figure, show, etc.) versus the convenience all-in-one namespace (mostly from numpy); but we will take one step at a time. Eric > > Gary R. > > Mark Bakker wrote: >> Hello list - >> >> I am confused about the part of numpy that pylab imports. >> Apparently, pylab imports 'zeros', but not the 'zeros' from numpy, as it >> returns integers by default, rather than floats. >> The same holds for 'ones' and 'empty'. >> Example: >> >>> from pylab import * >> >>> zeros(3) >> array([0, 0, 0]) >> >>> from numpy import * >> >>> zeros(3) >> array([ 0., 0., 0.]) >> >> Can this be fixed? Any explanation how this happens? Pylab just imports >> part of numpy, doesn't it? >> >> Thanks, >> >> Mark > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users |