[Numpy-discussion] Masked arrays and pickle/unpickle

Hans Meine meine at informatik.uni-hamburg.de
Fri Nov 7 07:11:18 EST 2008


On Thursday 17 July 2008 19:41:51 Anthony Floyd wrote:
> > > What I need to know is how I can trick pickle or Numpy to
> >
> > put the old class into the new class.
> >
> > If you have an example data-file, send it to me off-list and I'll
> > figure out what to do.  Maybe it is as simple as
> >
> > np.core.ma = np.oldnumeric.ma
>
> Yes, pretty much.  We've put ma.py into numpy.core where ma.py is
> nothing more than:
>
> import numpy.oldnumeric.ma as ma
>
> class MaskedArray(ma.MaskedArray):
>     pass
>
> It works, but becomes a bit of a headache because we now have to
> maintain our own numpy package so that all the developers get these
> three lines when they install numpy.

Did you try changing the pickled data?  IIRC you could simply search&replace, 
since the class name is at the beginning of the representation in clear text.
(I see that this a hack, too but it saves you from having to maintain your own 
numpy.)

HTH,
  Hans



More information about the NumPy-Discussion mailing list