storage: Add 'load_config()' for those that don't want an AFM instance
authorW. Trevor King <wking@tremily.us>
Fri, 24 May 2013 19:54:13 +0000 (15:54 -0400)
committerW. Trevor King <wking@tremily.us>
Fri, 24 May 2013 19:54:13 +0000 (15:54 -0400)
For example, when setting up unfold-config, we may just want to load
the default configuration but don't need to control an experiment
quite yet.

pyafm/storage.py

index 9b1e0f8694a332d678ff689d2c18054cee023820..73b69eb9252f055257baf65e8990817792d8d7b3 100644 (file)
@@ -38,7 +38,7 @@ def save_afm(afm, filename=None, group=None):
     storage = _HDF5_Storage(filename=filename, group=group)
     storage.save(config=afm.config)
 
-def load_afm(filename=None, group=None):
+def load_config(filename=None, group=None):
     if filename is None:
         filename = DEFAULT_FILENAME
     if group is None:
@@ -47,6 +47,10 @@ def load_afm(filename=None, group=None):
     _LOG.info('loading AFM config from {} {}'.format(filename, group))
     config = _AFMConfig(storage=_HDF5_Storage(filename=filename, group=group))
     config.load()
+    return config
+
+def load_afm(filename=None, group=None):
+    config = load_config(filename=filename, group=group)
     _LOG.debug(
         'constructing AFM from configuration:\n{}'.format(config.dump()))
     return AFM(config=config)