[Scipy-tickets] [SciPy] #661: cPickle protocol 2 fails for sparse.dok_matrix

SciPy scipy-tickets@scipy....
Sat May 3 09:12:55 CDT 2008


#661: cPickle protocol 2 fails for sparse.dok_matrix
--------------------------+-------------------------------------------------
 Reporter:  robince       |       Owner:  wnbell                             
     Type:  defect        |      Status:  new                                
 Priority:  normal        |   Milestone:  0.7                                
Component:  scipy.sparse  |     Version:                                     
 Severity:  normal        |    Keywords:  pickle, cPickle, sparse, dok_matrix
--------------------------+-------------------------------------------------
 I found that trying to load a protocol 2 binary pickle of a dok_matrix
 results in an error:

 Protocol 1 binary and protocol 0 seem to work OK.

 In [37]: Ad = sparse.dok_matrix((10,10),dtype=int8)

 In [38]: Ad[2,array([1,2,3,4])]=1

 In [39]: fd = open('test.pkl','wb')

 In [40]: cPickle.dump(Ad,fd,2)

 In [41]: fd.close()

 In [42]: fd = open('test.pkl','rb')

 In [43]: cPickle.load(fd)
 ---------------------------------------------------------------------------
 <type 'exceptions.AttributeError'>        Traceback (most recent call
 last)

 /Users/robince/phd/maxent/python/<ipython console> in <module>()

 /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-
 packages/scipy/sparse/dok.py in __setitem__(self, key, value)
     192                 j += self.shape[1]
     193
 --> 194             if i < 0 or i >= self.shape[0] or j < 0 or j >=
 self.shape[1]:
     195                 raise IndexError, "index out of bounds"
     196             if isintlike(value) and value == 0:

 /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-
 packages/scipy/sparse/base.py in __getattr__(self, attr)
     314             return self.getnnz()
     315         else:
 --> 316             raise AttributeError, attr + " not found"
     317
     318     def transpose(self):

 <type 'exceptions.AttributeError'>: shape not found

 In [44]: numpy.__version__
 Out[44]: '1.0.5.dev4987'

 In [45]: scipy.__version__
 Out[45]: '0.7.0.dev4114'

 In [46]: cPickle.__version__
 Out[46]: '1.71'

-- 
Ticket URL: <http://scipy.org/scipy/scipy/ticket/661>
SciPy <http://www.scipy.org/>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list