Commit 438aa036 authored by Thomas Vincent's avatar Thomas Vincent

convert string when saving

parent 2e335384
......@@ -36,6 +36,9 @@ from contextlib import contextmanager
import h5py as _h5py
import numpy as _np
from ..util import text_type
from ._utils import str_to_h5_utf8
# We have to work around a limitation of the h5py.Group.copy method
# that fails when a group already exists in the destination file.
......@@ -173,6 +176,14 @@ class XsocsH5Base(object):
return [s.decode() if hasattr(s, 'decode') else s for s in strings]
def _set_scalar_data(self, path, value):
"""Write a scalar or string value to a given dataset
:param str path: Dataset path
:param Union[float,int,str] value:
"""
if isinstance(value, text_type):
value = str_to_h5_utf8(value)
with self._get_file() as h5_f:
value_np = _np.array(value)
dset = h5_f.require_dataset(path,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment