From: W. Trevor King Date: Sun, 25 Sep 2011 23:39:17 +0000 (-0400) Subject: Adjust ChoiceSetting.convert_from_text to handle numpy character ndarrays. X-Git-Tag: v0.2~20 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=fbdcc0f9f48a5f6eee45f1b506e63767a5c17604;p=h5config.git Adjust ChoiceSetting.convert_from_text to handle numpy character ndarrays. --- diff --git a/h5config/config.py b/h5config/config.py index 0dd6898..5fab005 100644 --- a/h5config/config.py +++ b/h5config/config.py @@ -20,6 +20,8 @@ import copy as _copy +import numpy as _numpy + from . import LOG as _LOG @@ -83,6 +85,9 @@ class ChoiceSetting (Setting): return ret.strip() def convert_from_text(self, value): + if (isinstance(value, _numpy.ndarray) and + value.dtype.type == _numpy.string_): + value = str(value) return dict(self.choices)[value] def convert_to_text(self, value):