[python-hdf5storage] 41/152: Added ability to pass an Options object to the high level functions directly.
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Mon Feb 29 08:24:32 UTC 2016
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to annotated tag 0.1
in repository python-hdf5storage.
commit 92093765aa091a326a5187ed6cb6b5bf9edda05f
Author: Freja Nordsiek <fnordsie at gmail.com>
Date: Sun Jan 26 22:02:28 2014 -0500
Added ability to pass an Options object to the high level functions directly.
---
hdf5storage/core.py | 50 +++++++++++++++++++++++++++-----------------------
1 file changed, 27 insertions(+), 23 deletions(-)
diff --git a/hdf5storage/core.py b/hdf5storage/core.py
index dc117d7..a8d65b3 100644
--- a/hdf5storage/core.py
+++ b/hdf5storage/core.py
@@ -646,6 +646,7 @@ class MarshallerCollection(object):
def write(filename='data.h5', name='/data', data=None,
+ options=None,
store_type_information=True, MATLAB_compatible=True,
delete_unused_variables=False,
convert_scalars_to_arrays=False,
@@ -655,17 +656,18 @@ def write(filename='data.h5', name='/data', data=None,
store_shape_for_empty=False,
complex_names=('r', 'i'),
marshaller_collection=None):
- # Pack the different options into an Options class. The easiest way
- # to do this is to get all the arguments (locals() gets them since
- # they are the only symbols in the local table at this point) and
- # remove filename, name, and data.
-
- args = locals().copy()
- del args['filename']
- del args['name']
- del args['data']
-
- options = Options(**args)
+ # Pack the different options into an Options class if an Options was
+ # not given. The easiest way to do this is to get all the arguments
+ # (locals() gets them since they are the only symbols in the local
+ # table at this point) and remove filename, name, and data.
+
+ if not isinstance(options, Options):
+ args = locals().copy()
+ del args['filename']
+ del args['name']
+ del args['data']
+ del args['options']
+ options = Options(**args)
# Remove double slashes and a non-root trailing slash.
@@ -765,18 +767,20 @@ def write(filename='data.h5', name='/data', data=None,
fd.close()
-def read(filename='data.h5', name='/data', MATLAB_compatible=False,
- reverse_dimension_order=False, marshaller_collection=None):
- # Pack the different options into an Options class. The easiest way
- # to do this is to get all the arguments (locals() gets them since
- # they are the only symbols in the local table at this point) and
- # remove filename, name, and data.
-
- args = locals().copy()
- del args['filename']
- del args['name']
-
- options = Options(**args)
+def read(filename='data.h5', name='/data', options=None,
+ MATLAB_compatible=False, reverse_dimension_order=False,
+ marshaller_collection=None):
+ # Pack the different options into an Options class if an Options was
+ # not given. The easiest way to do this is to get all the arguments
+ # (locals() gets them since they are the only symbols in the local
+ # table at this point) and remove filename, name, and data.
+
+ if not isinstance(options, Options):
+ args = locals().copy()
+ del args['filename']
+ del args['name']
+ del args['options']
+ options = Options(**args)
# Remove double slashes and a non-root trailing slash.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/python-hdf5storage.git
More information about the debian-science-commits
mailing list