pylab.load in 0.99

I just noticed pylab.load now points to np.load when it used to point
to mlab.load

In [17]: import pylab

In [18]: import numpy

In [19]: pylab.load is numpy.load
Out[19]: True

This may have been Eric's change to clean up the pylab imports -- all
the mlab imports come before the pylab imports. Was this intentional?
My guess is not, since np.loadtxt is the replacement for pylab.load.
I prefer to do what we are currently doing, which is issue the
deprecation warning, but I wanted to at least find out if this change
was intentional (I noticed it because it broke
docs/pyplot/plotmap.py), which tries to load some basemap data:

In [12]: x = pylab.load('/home/jdhunter/python/svn/matplotlib/trunk/htdocs/screenshots/data/etopo20data.gz')

···

---------------------------------------------------------------------------
IOError Traceback (most recent call last)

/home/jdhunter/mpl99/doc/api/<ipython console> in <module>()

/home/jdhunter/dev/lib/python2.5/site-packages/numpy/lib/io.pyc in
load(file, mmap_mode)
    199 except:
    200 raise IOError, \
--> 201 "Failed to interpret file %s as a pickle" % repr(file)
    202
    203 def save(file, arr):

JDH

Correction, I had confused myself for a minute thinking numpy.load was
the old numpy.load which handled plain text files, ie what became
loadtxt. np.load and np.save are too important as regular numpy
functions, so I think now would be a good time to remove the mlab
versions from the pylab namespace. The question is : how best to do
it? Unfortunately, a lot of people are still using the old load/save
and the deprecation warnings are only in 0.99 but not 0.98 so we have
not done the typical deprecation cycle.

We could create a special purpose deprecation function in pylab which
raises a deprecation error: 'use np.loadtxt for plain text, np.load
for binary numpy arrays, or mlab.load for old pylab.load
compatability'). Ie, not have a functional load/save in the pylab
namespace at all.

JDH

···

On Mon, Aug 3, 2009 at 2:15 PM, John Hunter<jdh2358@...149...> wrote:

This may have been Eric's change to clean up the pylab imports -- all
the mlab imports come before the pylab imports. Was this intentional?
My guess is not, since np.loadtxt is the replacement for pylab.load.
I prefer to do what we are currently doing, which is issue the
deprecation warning, but I wanted to at least find out if this change
was intentional (I noticed it because it broke
docs/pyplot/plotmap.py), which tries to load some basemap data:

John Hunter wrote:

This may have been Eric's change to clean up the pylab imports -- all
the mlab imports come before the pylab imports. Was this intentional?
My guess is not, since np.loadtxt is the replacement for pylab.load.
I prefer to do what we are currently doing, which is issue the
deprecation warning, but I wanted to at least find out if this change
was intentional (I noticed it because it broke
docs/pyplot/plotmap.py), which tries to load some basemap data:

Correction, I had confused myself for a minute thinking numpy.load was
the old numpy.load which handled plain text files, ie what became
loadtxt. np.load and np.save are too important as regular numpy
functions, so I think now would be a good time to remove the mlab
versions from the pylab namespace. The question is : how best to do
it? Unfortunately, a lot of people are still using the old load/save
and the deprecation warnings are only in 0.99 but not 0.98 so we have
not done the typical deprecation cycle.

We could create a special purpose deprecation function in pylab which
raises a deprecation error: 'use np.loadtxt for plain text, np.load
for binary numpy arrays, or mlab.load for old pylab.load
compatability'). Ie, not have a functional load/save in the pylab
namespace at all.

That is still making an abrupt break in functionality. It could be made more gentle by having the pylab wrapper do something like:

try:
     return np.load(*args, **kwargs)
except: # deliberately violate the rule against catching everything
     warnings.warn("deprecation etc.")
     return mlab.load(*args, **kwargs)

In the next release the warning could be changed to an error, and in the release after that pylab.load could simply be numpy.load

Eric

···

On Mon, Aug 3, 2009 at 2:15 PM, John Hunter<jdh2358@...149...> wrote:

JDH

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options

I thought about this but decided it would be better not to introduce
the additional complexity (yet another load), as it may lead to some
hard to diagnose bugs. I would prefer do one release cycle which
warns and calls mlab.load, but I think I prefer over that the a plain
ol error like

In [3]: load('jdh')

···

On Mon, Aug 3, 2009 at 2:40 PM, Eric Firing<efiring@...229...> wrote:

John Hunter wrote:

On Mon, Aug 3, 2009 at 2:15 PM, John Hunter<jdh2358@...149...> wrote:

This may have been Eric's change to clean up the pylab imports -- all
the mlab imports come before the pylab imports. Was this intentional?
My guess is not, since np.loadtxt is the replacement for pylab.load.
I prefer to do what we are currently doing, which is issue the
deprecation warning, but I wanted to at least find out if this change
was intentional (I noticed it because it broke
docs/pyplot/plotmap.py), which tries to load some basemap data:

Correction, I had confused myself for a minute thinking numpy.load was
the old numpy.load which handled plain text files, ie what became
loadtxt. np.load and np.save are too important as regular numpy
functions, so I think now would be a good time to remove the mlab
versions from the pylab namespace. The question is : how best to do
it? Unfortunately, a lot of people are still using the old load/save
and the deprecation warnings are only in 0.99 but not 0.98 so we have
not done the typical deprecation cycle.

We could create a special purpose deprecation function in pylab which
raises a deprecation error: 'use np.loadtxt for plain text, np.load
for binary numpy arrays, or mlab.load for old pylab.load
compatability'). Ie, not have a functional load/save in the pylab
namespace at all.

That is still making an abrupt break in functionality. It could be made
more gentle by having the pylab wrapper do something like:

try:
return np.load(*args, **kwargs)
except: # deliberately violate the rule against catching everything
warnings.warn("deprecation etc.")
return mlab.load(*args, **kwargs)

---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)

/home/jdhunter/<ipython console> in <module>()

/home/jdhunter/dev/lib/python2.5/site-packages/matplotlib/pylab.pyc in
load(*args, **kwargs)
    253
    254 def load(*args, **kwargs):
--> 255 raise NotImplementedError(load.__doc__)
    256 load.__doc__ = """\
    257 pylab no longer provides a load function, though the old pylab

NotImplementedError: pylab no longer provides a load function,
though the old pylab
    function is still available as matplotlib.mlab.load (you can refer
    to it in pylab as"mlab.load". However, for plain text files, we
    recommend numpy.loadtxt, which was inspired by the old pylab.load
    but now has more features. For loading numpy arrays, we recommend
    numpy.load, and its analog numpy.save, which are available in
    pylab as np.load and np.save.

In [4]: save('jdh')
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)

/home/jdhunter/<ipython console> in <module>()

/home/jdhunter/dev/lib/python2.5/site-packages/matplotlib/pylab.pyc in
save(*args, **kwargs)
    266
    267 def save(*args, **kwargs):
--> 268 raise NotImplementedError(save.__doc__)
    269 save.__doc__ = """\
    270 pylab no longer provides a save function, though the old pylab

NotImplementedError: pylab no longer provides a save function,
though the old pylab
    function is still available as matplotlib.mlab.save (you can still
    refer to it in pylab as "mlab.save". However, for plain text
    files, we recommend numpy.savetxt. For saving numpy arrays,
    we recommend numpy.save, and its analog numpy.load, which are
    available in pylab as np.save and np.load.

John Hunter wrote:

John Hunter wrote:

This may have been Eric's change to clean up the pylab imports -- all
the mlab imports come before the pylab imports. Was this intentional?
My guess is not, since np.loadtxt is the replacement for pylab.load.
I prefer to do what we are currently doing, which is issue the
deprecation warning, but I wanted to at least find out if this change
was intentional (I noticed it because it broke
docs/pyplot/plotmap.py), which tries to load some basemap data:

Correction, I had confused myself for a minute thinking numpy.load was
the old numpy.load which handled plain text files, ie what became
loadtxt. np.load and np.save are too important as regular numpy
functions, so I think now would be a good time to remove the mlab
versions from the pylab namespace. The question is : how best to do
it? Unfortunately, a lot of people are still using the old load/save
and the deprecation warnings are only in 0.99 but not 0.98 so we have
not done the typical deprecation cycle.

We could create a special purpose deprecation function in pylab which
raises a deprecation error: 'use np.loadtxt for plain text, np.load
for binary numpy arrays, or mlab.load for old pylab.load
compatability'). Ie, not have a functional load/save in the pylab
namespace at all.

That is still making an abrupt break in functionality. It could be made
more gentle by having the pylab wrapper do something like:

try:
   return np.load(*args, **kwargs)
except: # deliberately violate the rule against catching everything
   warnings.warn("deprecation etc.")
   return mlab.load(*args, **kwargs)

I thought about this but decided it would be better not to introduce
the additional complexity (yet another load), as it may lead to some
hard to diagnose bugs. I would prefer do one release cycle which
warns and calls mlab.load, but I think I prefer over that the a plain
ol error like

John,

Your solution is certainly fine with me.

Eric

···

On Mon, Aug 3, 2009 at 2:40 PM, Eric Firing<efiring@...229...> wrote:

On Mon, Aug 3, 2009 at 2:15 PM, John Hunter<jdh2358@...149...> wrote:

In [3]: load('jdh')
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)

/home/jdhunter/<ipython console> in <module>()

/home/jdhunter/dev/lib/python2.5/site-packages/matplotlib/pylab.pyc in
load(*args, **kwargs)
    253
    254 def load(*args, **kwargs):
--> 255 raise NotImplementedError(load.__doc__)
    256 load.__doc__ = """\
    257 pylab no longer provides a load function, though the old pylab

NotImplementedError: pylab no longer provides a load function,
though the old pylab
    function is still available as matplotlib.mlab.load (you can refer
    to it in pylab as"mlab.load". However, for plain text files, we
    recommend numpy.loadtxt, which was inspired by the old pylab.load
    but now has more features. For loading numpy arrays, we recommend
    numpy.load, and its analog numpy.save, which are available in
    pylab as np.load and np.save.

In [4]: save('jdh')
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)

/home/jdhunter/<ipython console> in <module>()

/home/jdhunter/dev/lib/python2.5/site-packages/matplotlib/pylab.pyc in
save(*args, **kwargs)
    266
    267 def save(*args, **kwargs):
--> 268 raise NotImplementedError(save.__doc__)
    269 save.__doc__ = """\
    270 pylab no longer provides a save function, though the old pylab

NotImplementedError: pylab no longer provides a save function,
though the old pylab
    function is still available as matplotlib.mlab.save (you can still
    refer to it in pylab as "mlab.save". However, for plain text
    files, we recommend numpy.savetxt. For saving numpy arrays,
    we recommend numpy.save, and its analog numpy.load, which are
    available in pylab as np.save and np.load.