Skip to content

Commit

Permalink
fix(colorobj): Catch edge case of casting to -0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey committed Dec 12, 2023
1 parent e718f5f commit b12250d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion honeybee/colorobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit b12250d

Please sign in to comment.