[SciPy-dev] pickling problem

Travis Oliphant oliphant.travis at ieee.org
Wed Nov 30 16:03:02 EST 2005


Darren Dale wrote:

>On Wednesday 30 November 2005 03:12 pm, Travis Oliphant wrote:
>  
>
>>Darren Dale wrote:
>>    
>>
>>>I'm having some trouble with unpickled scipy arrays. The issue shows up
>>>when I try to plot in matplotlib, but I think it is a scipy problem.
>>>      
>>>
>>Can you reproduce the problem just using Numeric and scipy and pickle?
>>    
>>
>
>I just ran the same script again with Numeric, and was not able to reproduce 
>the problem.
>
>  
>
>>What version of Numeric are you using?
>>    
>>
>
>24.2
>
>  
>
>>This looks like an array protocol issue.  But, for me, not using pylab,
>>I can create the scipy array, pickle it, unpickle it and convert it to a
>>Numeric array just fine.
>>    
>>
>
>The following gives me the same error:
>
>import pickle
>import scipy
>import Numeric
>
>a = scipy.arange(10)
>pickle.dump(a,file('temp.p','w'))
>b = pickle.load(file('temp.p'))
>c = Numeric.array(b)
>
>Traceback (most recent call last):
>  File "pickletest.py", line 8, in ?
>    c = Numeric.array(b)
>ValueError: cannot handle misaligned or not writeable arrays.
>  
>
Which platform are you on?  Do you have an old version of Numeric 
getting picked up by accident?

I can't seem to reproduce this error.

This error will only show up in the array_fromstructinterface code which 
parses the array_struct interface information. 

What is the result of b.flags on your system?  To find out insert print 
b.flags right before you call Numeric.array.

Mine is

{'WRITEABLE': True, 'UPDATEIFCOPY': False, 'NOTSWAPPED': True, 
'CONTIGUOUS': True, 'FORTRAN': True, 'ALIGNED': True, 'OWNDATA': False}

In particular you are looking for WRITEABLE and ALIGNED to both be True.

-Travis




More information about the SciPy-Dev mailing list