[python-hdf5storage] 07/13: Fixed bug where empty string arrays aren't read back with the same dtypes.

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Feb 29 08:25:24 UTC 2016


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to annotated tag 0.1.12
in repository python-hdf5storage.

commit d9236630d3aa67e48b17ad3b0cc6eb13ef5718fd
Author: Freja Nordsiek <fnordsie at gmail.com>
Date:   Sat Feb 13 21:23:09 2016 +0100

    Fixed bug where empty string arrays aren't read back with the same dtypes.
---
 hdf5storage/Marshallers.py | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/hdf5storage/Marshallers.py b/hdf5storage/Marshallers.py
index 55541f0..8ee56cf 100644
--- a/hdf5storage/Marshallers.py
+++ b/hdf5storage/Marshallers.py
@@ -1208,9 +1208,23 @@ class NumpyScalarArrayMarshaller(TypeMarshaller):
             # figured out the dtype for, that needs to be used.
             if python_empty == 1:
                 if underlying_type.startswith('bytes'):
-                    data = np.zeros(tuple(shape), dtype='S1')
+                    if underlying_type == 'bytes':
+                        nchars = 1
+                    else:
+                        nchars = int(int(
+                                     underlying_type[len('bytes'):])
+                                     / 8)
+                    data = np.zeros(tuple(shape),
+                                    dtype='S' + str(nchars))
                 elif underlying_type.startswith('str'):
-                    data = np.zeros(tuple(shape), dtype='U1')
+                    if underlying_type == 'str':
+                        nchars = 1
+                    else:
+                        nchars = int(int(
+                                     underlying_type[len('str'):])
+                                     / 32)
+                    data = np.zeros(tuple(shape),
+                                    dtype='U' + str(nchars))
                 elif struct_dtype is not None:
                     data = np.zeros(tuple(shape),
                                     dtype=struct_dtype)

-- 
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