Commit b15a91ca authored by Gregory Ashton's avatar Gregory Ashton

Adds decoding for single strings and list of strings

Fix one of the sub issues in #75. Namely plot_corner will now run for
data generated by python 2 when imported into python 3
parent 194d88a9
Pipeline #20504 passed with stages
in 13 minutes and 54 seconds
......@@ -39,7 +39,7 @@ class Result(dict):
def __init__(self, dictionary=None):
if type(dictionary) is dict:
for key in dictionary:
setattr(self, key, dictionary[key])
setattr(self, key, self._decode_object(dictionary[key]))
def __getattr__(self, name):
......@@ -62,6 +62,22 @@ class Result(dict):
return ''
def _decode_object(self, item):
""" When reading in data, ensure all bytes are decoded to strings """
return item.decode()
except AttributeError:
return [i.decode() for i in item]
except (AttributeError, TypeError):
logging.debug("Unable to decode item")
return item
def get_result_dictionary(self):
return dict(self)
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