[Numpy-discussion] Masked arrays and pickle/unpickle
Thu Jul 17 11:14:46 CDT 2008
> 2008/7/16 Anthony Floyd <firstname.lastname@example.org>:
> > Unfortunately, when we try to unpickle the data saved with
> Numpy 1.0.3
> > in the new code using Numpy 1.1.0, it chokes because it can't import
> > numpy.core.ma for the masked arrays. A check of Numpy
> 1.1.0 shows that
> > this is now numpy.ma.core.
> The maskedarray functionality has been rewritten, and is now
> `numpy.ma`. For the time being, the old package is still available as
Yes, we're aware it's changed. The problem is that when pickle unpickles the data, it tries to assign the data back to its original class ... and the class type for masked arrays under 1.0.3 is numpy.core.ma.MaskedArray. This class type has changed in 1.1.0 to numpy.ma.core.MaskedArray. Since pickle can't find the old type, it fails to load the data.
What I need to know is how I can trick pickle or Numpy to put the old class into the new class.
The only thing we've come up with is to create our own numpy.core.ma.MaskedArray in 1.1.0 as a class that inherits numpy.ma.core.MaskedArray and doesn't make any changes to it.
It's extremely surprising to find a significant API change like this in a stable package.
Anthony Floyd, PhD
Convergent Manufacturing Technologies Inc.
6190 Agronomy Rd, Suite 403
Vancouver BC V6T 1Z3
Email: Anthony.Floyd@convergent.ca | Tel: 604-822-9682 x102
WWW: http://www.convergent.ca | Fax: 604-822-9659
CMT is hiring: See http://www.convergent.ca for details
More information about the Numpy-discussion