Skip to content
This repository
Browse code

DEP: deprecate scipy.io.save_as_module for the 0.11 release. Also mak…

…e it work.
  • Loading branch information...
commit 12422e60cc93ee39361e909f6ad1f1035dff73f2 1 parent 404eb7f
Ralf Gommers authored
3  doc/release/0.11.0-notes.rst
Source Rendered
@@ -74,6 +74,9 @@ Deprecated features
74 74
 ``scipy.misc.radon`` has been deprecated.  A more full-featured radon transform
75 75
 can be found in scikits-image.
76 76
 
  77
+``scipy.io.save_as_module`` has been deprecated.  A better way to save multiple
  78
+Numpy arrays is the ``numpy.savez`` function.
  79
+
77 80
 
78 81
 Backwards incompatible changes
79 82
 ==============================
22  scipy/io/data_store.py
@@ -31,6 +31,8 @@
31 31
 import dumb_shelve
32 32
 import os
33 33
 
  34
+import numpy as np
  35
+
34 36
 
35 37
 def _create_module(file_name):
36 38
     """ Create the module file.
@@ -60,6 +62,8 @@ def save_as_module(file_name=None,data=None):
60 62
     """
61 63
     Save the dictionary "data" into a module and shelf named save.
62 64
 
  65
+    This function is deprecated in scipy 0.11 and will be removed for 0.12
  66
+
63 67
     Parameters
64 68
     ----------
65 69
     file_name : str, optional
@@ -70,3 +74,21 @@ def save_as_module(file_name=None,data=None):
70 74
     """
71 75
     _create_module(file_name)
72 76
     _create_shelf(file_name,data)
  77
+
  78
+
  79
+save_as_module = np.deprecate(save_as_module)
  80
+
  81
+
  82
+def _load(module):
  83
+    """ Load data into module from a shelf with
  84
+        the same name as the module.
  85
+    """
  86
+    dir,filename = os.path.split(module.__file__)
  87
+    filebase = filename.split('.')[0]
  88
+    fn = os.path.join(dir, filebase)
  89
+    f = dumb_shelve.open(fn, "r")
  90
+    #exec( 'import ' + module.__name__)
  91
+    for i in f.keys():
  92
+        exec( 'import ' + module.__name__+ ';' +
  93
+              module.__name__+'.'+i + '=' + 'f["' + i + '"]')
  94
+

0 notes on commit 12422e6

Please sign in to comment.
Something went wrong with that request. Please try again.