From b12250d409561a29af1f15f6f03c5f97f7ed9aeb Mon Sep 17 00:00:00 2001 From: Chris Mackey Date: Tue, 12 Dec 2023 14:51:57 -0800 Subject: [PATCH] fix(colorobj): Catch edge case of casting to -0.0 --- honeybee/colorobj.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/honeybee/colorobj.py b/honeybee/colorobj.py index 247b52f7..773bf9e7 100644 --- a/honeybee/colorobj.py +++ b/honeybee/colorobj.py @@ -118,7 +118,15 @@ def graphic_container(self): # produce a range of values from the collected attributes attr_dict = {i: val for i, val in enumerate(self._attributes_unique)} attr_dict_rev = {val: i for i, val in attr_dict.items()} - values = tuple(attr_dict_rev[r_attr] for r_attr in self._attributes) + try: + values = tuple(attr_dict_rev[r_attr] for r_attr in self._attributes) + except KeyError: # possibly caused by float cast to -0.0 + values = [] + for r_attr in self._attributes: + if r_attr == '-0.0': + values.append(attr_dict_rev['0.0']) + else: + values.append(attr_dict_rev[r_attr]) # produce legend parameters with an ordinal dict for the attributes l_par = self.legend_parameters.duplicate()