Skip to content

Commit 959fa6e

Browse files
committed
added support for coloring object arrays (only use numeric values)
1 parent 99a8c93 commit 959fa6e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

larray_editor/arraymodel.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,11 @@ def reset_minmax(self):
259259
try:
260260
data = self.get_values(sample=True)
261261
color_value = self.color_func(data) if self.color_func is not None else data
262+
if color_value.dtype.type == np.object_:
263+
color_value = color_value[is_number_value(color_value)]
264+
# this is probably broken if we have complex numbers stored as objects but I don't foresee
265+
# this case happening anytime soon.
266+
color_value = color_value.astype(float)
262267
# ignore nan, -inf, inf (setting them to 0 or to very large numbers is not an option)
263268
color_value = color_value[np.isfinite(color_value)]
264269
self.vmin = float(np.min(color_value))

0 commit comments

Comments
 (0)