Skip to content

Commit 7db6609

Browse files
authored
Merge pull request #238 from boutproject/string
Ensure data is converted to strings
2 parents 9f8e094 + 45b640e commit 7db6609

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

xbout/load.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,10 @@ def attrs_to_dict(obj, section):
185185
sectionlength = len(section)
186186
for key in list(obj.attrs):
187187
if key[:sectionlength] == section:
188-
result[key[sectionlength:]] = obj.attrs.pop(key)
188+
val = obj.attrs.pop(key)
189+
if isinstance(val, bytes):
190+
val = val.decode()
191+
result[key[sectionlength:]] = val
189192
return result
190193

191194
def attrs_remove_section(obj, section):

xbout/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def _separate_metadata(ds):
6969

7070
# Save metadata as a dictionary
7171
metadata_vals = [ds[var].values.item() for var in scalar_vars]
72+
metadata_vals = [x.decode() if isinstance(x, bytes) else x for x in metadata_vals]
7273
metadata = dict(zip(scalar_vars, metadata_vals))
7374

7475
# Add default values for dimensions to metadata. These may be modified later by

0 commit comments

Comments
 (0)