confusion about what part of numpy pylab imports

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

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

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
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

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 <efiring@…202…> 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
Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Yes. This should be the default.
Backward compatability can be provided
via numpy's compatability module.

A user's view,
Alan Isaac

···

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.