[Scipy-tickets] [SciPy] #1584: scipy.io.savemat fails to create a struct when passed a dict

SciPy Trac scipy-tickets@scipy....
Thu Jan 12 21:16:53 CST 2012


#1584: scipy.io.savemat fails to create a struct when passed a dict
-------------------------+--------------------------------------------------
 Reporter:  ali-ebrahim  |       Owner:  somebody   
     Type:  defect       |      Status:  new        
 Priority:  high         |   Milestone:  Unscheduled
Component:  scipy.io     |     Version:  0.10.0     
 Keywords:               |  
-------------------------+--------------------------------------------------
 Attempting to do so raises an Attribute error:
 {{{
 AttributeError: 'dict' object has no attribute 'iter
 }}}

 The culprit is line 449 in the file io/matlab/mio5.py
 {{{
         for field, value in source.iter():
 }}}
 Replacing that line with the following code fixes the problem
 {{{
         if hasattr(source, "iter"):
             iterfunc = source.iter
         elif hasattr(source, "iteritems"):
             iterfunc = source.iteritems
         else:
             raise AttributeError("no appropriate iterator found")
         for field, value in iterfunc():
 }}}

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


More information about the Scipy-tickets mailing list