On Mon, Aug 3, 2009 at 2:40 PM, Eric Firing<efir...@hawaii.edu> wrote: > John Hunter wrote: >> >> On Mon, Aug 3, 2009 at 2:15 PM, John Hunter<jdh2...@gmail.com> 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 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. ------------------------------------------------------------------------------ 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 https://lists.sourceforge.net/lists/listinfo/matplotlib-devel