Skip to content

Commit

Permalink
Support for no decoding of strs in data files
Browse files Browse the repository at this point in the history
  • Loading branch information
simen-tennoee committed Nov 2, 2020
1 parent 8dd33d8 commit 1bd0d54
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/uncertainpy/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,16 +778,25 @@ def append_evaluations(evaluations, group):
f = backend.File(filename, "r")

if "uncertain parameters" in f.attrs:
self.uncertain_parameters = [parameter.decode("utf8") for parameter in f.attrs["uncertain parameters"]]
try:
self.uncertain_parameters = [parameter.decode("utf8") for parameter in f.attrs["uncertain parameters"]]
except (UnicodeDecodeError, AttributeError):
self.uncertain_parameters = [parameter for parameter in f.attrs["uncertain parameters"]]

if "model name" in f.attrs:
self.model_name = str(f.attrs["model name"])

if "incomplete results" in f.attrs:
self.incomplete = [incomplete.decode("utf8") for incomplete in f.attrs["incomplete results"]]
try:
self.incomplete = [incomplete.decode("utf8") for incomplete in f.attrs["incomplete results"]]
except (UnicodeDecodeError, AttributeError):
self.incomplete = [incomplete for incomplete in f.attrs["incomplete results"]]

if "error" in f.attrs:
self.error = [irregular.decode("utf8") for irregular in f.attrs["error"]]
try:
self.error = [irregular.decode("utf8") for irregular in f.attrs["error"]]
except (UnicodeDecodeError, AttributeError):
self.error = [irregular for irregular in f.attrs["error"]]

if "method" in f.attrs:
self.method = str(f.attrs["method"])
Expand Down

0 comments on commit 1bd0d54

Please sign in to comment.