This is the expected behavior. It is not a bug. NumPy arrays after pickling are views into the String that is created by the pickling machinery. Thus, the base is set. This was done to avoid an additional memcpy.
This avoids a copy, but yes, it does mean that you can't resize the array until you make another copy. Best regards, -Travis On Jun 30, 2012, at 5:33 PM, Daniel Hyams wrote: > Hmmm, I wouldn't think that it is correct behavior; I would think that *any* > ndarray arising from pickling would have its .base attribute set to None. If > not, then who is really the one that owns the data? > > It was my understanding that .base should hold a reference to another ndarray > that the data is really coming from, or it's None. It certainly shouldn't be > some random string, should it? > > And yes, it is causing a problem for me, which is why I noticed it. In my > application, ndarrays can come from various sources, pickling being one of > them. Later in the app, I was wanting to resize the array, which you cannot > do if the data is not really owned by that array...I had explicit check for > myarray.base==None, which it is not when I get the ndarray from a pickle. > > > -- > Daniel Hyams > [email protected] > _______________________________________________ > NumPy-Discussion mailing list > [email protected] > http://mail.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
