[SciPy-User] problem with loading data from data_store

Ryan Krauss ryanlists@gmail....
Mon Mar 26 12:28:13 CDT 2012


It seems like I am using code no one cares about or uses.  I also
worked around this by just using cPickle.  Is there a better approach
I should be using to save a collection of numpy arrays efficiently
with little hassle?

On Sun, Mar 25, 2012 at 3:55 PM, Ralf Gommers
<ralf.gommers@googlemail.com> wrote:
>
>
> On Thu, Mar 22, 2012 at 10:33 PM, Ryan Krauss <ryanlists@gmail.com> wrote:
>>
>> I have some data sets stored using scipy.io.save_as_module.  I
>> recently upgrade to 0.10 and I can no longer open this module.
>> Further, I tried to reprocess my data and resave it and I am still
>> getting the same error message.  Just a couple of lines are needed to
>> recreate my problem:
>>
>> mydict = {'a':12.34}
>> scipy.io.save_as_module('mymod',mydict)
>> import mymod
>>
>> The response to the last command (import) is
>>
>> In [18]: import mymod
>>
>> ---------------------------------------------------------------------------
>> AttributeError                            Traceback (most recent call
>> last)
>>
>> /home/ryan/siue/Research/modeling/SFLR/system_ID/TMM/TMM_SFLR_model1.py
>> in <module>()
>> ----> 1
>>      2
>>      3
>>      4
>>      5
>>
>> /home/ryan/siue/Research/modeling/SFLR/system_ID/TMM/mymod.py in
>> <module>()
>>      1 import scipy.io.data_store as data_store
>>      2 import mymod
>> ----> 3 data_store._load(mymod)
>>      4
>>      5
>>
>> AttributeError: 'module' object has no attribute '_load'
>>
>>
>> Can anyone help me with this?
>
>
> You can add this in scipy/io/data_store.py:
>
> def _load(module):
>     """ Load data into module from a shelf with
>         the same name as the module.
>     """
>     dir,filename = os.path.split(module.__file__)
>     filebase = filename.split('.')[0]
>     fn = os.path.join(dir, filebase)
>     f = dumb_shelve.open(fn, "r")
>     #exec( 'import ' + module.__name__)
>     for i in f.keys():
>         exec( 'import ' + module.__name__+ ';' +
>               module.__name__+'.'+i + '=' + 'f["' + i + '"]')
>
> This was caused by an incorrect removal of deprecated code in
> https://github.com/scipy/scipy/commit/329a5e2713. So apparently
> save_as_module() has been completely broken for 2 years without anyone
> noticing.....
>
> Proposal: fix save_as_module now so it can load data again, deprecate it for
> 0.11 and remove it for 0.12.
>
> Ralf
>
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>


More information about the SciPy-User mailing list