Hello,<div><br></div><div>Could you help me to clarify the following idlsave data accessing issue?</div><div>Quick update: This seems to be an issue with IPython. s1['dn'] call works fine within regular python shell.</div>
<div><div><br></div><div><div>I1 from scipy import io</div><div><span style="background-color: transparent; ">I2 s1 = io.idl.readsav('test.sav')</span></div><div><br></div><div><div>I3 s1?</div><div>Type: AttrDict</div>
<div>Base Class: <class 'scipy.io.idl.AttrDict'></div><div>String Form:</div><div>{'dn': array([ 1.02282184e+07, 1.05383408e+07, 1.08758739e+07,</div><div> 1.12449965e+07, 1. <...> (('r', 'R'), '>f8'), (('v', 'V'), '>f8')]), 'tfit': array([ 4.82394886e+02, 4.18176107e-01])}</div>
<div><span style="background-color: transparent; ">Namespace: Interactive</span></div><div>Length: 11</div><div>File: /usr/lib64/python2.7/site-packages/scipy/io/idl.py</div><div>Definition: s1(self, name)</div>
</div><div><br></div><div><br></div><div>### Why is the following call failing? ###</div><div><br></div><div><br></div><div><div>I4 s1['dn']</div><div>---------------------------------------------------------------------------</div>
<div>KeyError Traceback (most recent call last)</div><div>/home/gsever/Desktop/python-repo/ipython/IPython/core/prefilter.pyc in prefilter_lines(self, lines, continue_prompt)</div><div> 358 for lnum, line in enumerate(llines) ])</div>
<div> 359 else:</div><div>--> 360 out = self.prefilter_line(llines[0], continue_prompt)</div><div> 361 </div><div> 362 return out</div><div><br></div><div>/home/gsever/Desktop/python-repo/ipython/IPython/core/prefilter.pyc in prefilter_line(self, line, continue_prompt)</div>
<div> 333 return normal_handler.handle(line_info)</div><div> 334 </div><div>--> 335 prefiltered = self.prefilter_line_info(line_info)</div><div> 336 # print "prefiltered line: %r" % prefiltered</div>
<div><br></div><div> 337 return prefiltered</div><div><br></div><div>/home/gsever/Desktop/python-repo/ipython/IPython/core/prefilter.pyc in prefilter_line_info(self, line_info)</div><div> 273 # print "prefilter_line_info: ", line_info</div>
<div><br></div><div> 274 handler = self.find_handler(line_info)</div><div>--> 275 return handler.handle(line_info)</div><div> 276 </div><div> 277 def find_handler(self, line_info):</div><div>
<br></div><div>/home/gsever/Desktop/python-repo/ipython/IPython/core/prefilter.pyc in handle(self, line_info)</div><div> 813 </div><div> 814 force_auto = isinstance(obj, IPyAutocall)</div><div>--> 815 auto_rewrite = getattr(obj, 'rewrite', True)</div>
<div> 816 </div><div> 817 if esc == ESC_QUOTE:</div><div><br></div><div>/usr/lib64/python2.7/site-packages/scipy/io/idl.pyc in __getitem__(self, name)</div><div> 657 </div><div> 658 def __getitem__(self, name):</div>
<div>--> 659 return super(AttrDict, self).__getitem__(name.lower())</div><div> 660 </div><div> 661 def __setitem__(self, key, value):</div><div><br></div><div>KeyError: 'rewrite'</div></div><div>
<br></div><div><br></div><div>Back then I was accessing this key via (when idlsave was a separate module):</div><div>s1.variables['dn']</div><div><span style="background-color: transparent; ">but it is long gone in the scipy.</span></div>
<div><br></div><div><br></div><div>The following works. Is this the correct way to access variables from this dictionary?</div><div><br></div><div><br></div><div><div>I14 s1.get('dn')</div><div>O14 </div><div>array([ 1.02282184e+07, 1.05383408e+07, 1.08758739e+07,</div>
<div> 1.12449965e+07, 1.16508267e+07, 1.20997100e+07,</div></div><div><br></div><div>Thanks.</div><div><br></div><div><br></div><div><br></div><div><br></div>-- <br>Gökhan<br>
</div></div>