bokeh 0.12.14
GroupFilter only operates on string-valued columns
from bokeh.models import GroupFilter
GroupFilter(column_name='visible', group=True)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-30-b872a7a9ba79> in <module>()
1
----> 2 GroupFilter(column_name='visible', group=True)
~/anaconda/lib/python3.6/site-packages/bokeh/models/filters.py in __init__(self, *args, **kw)
72 kw["group"] = args[1]
73
---> 74 super(GroupFilter, self).__init__(**kw)
75
76 class CustomJSFilter(Filter):
~/anaconda/lib/python3.6/site-packages/bokeh/models/filters.py in __init__(self, *args, **kw)
23 kw["filter"] = args[0]
24
---> 25 super(Filter, self).__init__(**kw)
26
27 class IndexFilter(Filter):
~/anaconda/lib/python3.6/site-packages/bokeh/model.py in __init__(self, **kwargs)
217 self._id = kwargs.pop("id", make_id())
218 self._document = None
--> 219 super(Model, self).__init__(**kwargs)
220 default_theme.apply_to_model(self)
221
~/anaconda/lib/python3.6/site-packages/bokeh/core/has_props.py in __init__(self, **properties)
234
235 for name, value in properties.items():
--> 236 setattr(self, name, value)
237
238 def __setattr__(self, name, value):
~/anaconda/lib/python3.6/site-packages/bokeh/core/has_props.py in __setattr__(self, name, value)
261
262 if name in props or (descriptor is not None and descriptor.fset is not None):
--> 263 super(HasProps, self).__setattr__(name, value)
264 else:
265 matches, text = difflib.get_close_matches(name.lower(), props), "similar"
~/anaconda/lib/python3.6/site-packages/bokeh/core/property/descriptors.py in __set__(self, obj, value, setter)
501 raise RuntimeError("%s.%s is a readonly property" % (obj.__class__.__name__, self.name))
502
--> 503 self._internal_set(obj, value, setter=setter)
504
505 def __delete__(self, obj):
~/anaconda/lib/python3.6/site-packages/bokeh/core/property/descriptors.py in _internal_set(self, obj, value, hint, setter)
722
723 '''
--> 724 value = self.property.prepare_value(obj, self.name, value)
725
726 old = self.__get__(obj, obj.__class__)
~/anaconda/lib/python3.6/site-packages/bokeh/core/property/bases.py in prepare_value(self, obj_or_cls, name, value)
279 break
280 else:
--> 281 raise e
282 else:
283 value = self.transform(value)
~/anaconda/lib/python3.6/site-packages/bokeh/core/property/bases.py in prepare_value(self, obj_or_cls, name, value)
272 def prepare_value(self, obj_or_cls, name, value):
273 try:
--> 274 self.validate(value)
275 except ValueError as e:
276 for tp, converter in self.alternatives:
~/anaconda/lib/python3.6/site-packages/bokeh/core/property/bases.py in validate(self, value)
403 if not (value is None or isinstance(value, self._underlying_type)):
404 raise ValueError("expected a value of type %s, got %s of type %s" %
--> 405 (nice_join([ cls.__name__ for cls in self._underlying_type ]), value, type(value).__name__))
406
407 def from_json(self, json, models=None):
ValueError: expected a value of type str, got True of type bool
Obviously I can get around this by mapping my data to strings, but I'm sending a fair amount of it, and wouldn't mind using more compact datatypes
cc @clairetang6 thoughts?
I don't see any reason why the group parameter couldn't be a boolean or number. The JS implementation just checks whether the values of the column are equal (===) to the group parameter. I think this would be an easy addition, just changing the types that are allowed for group on the python and JS sides.
In my case I would need to group by a numeric values as well. Althoug I found an alternative mapping the values and adding them to the BooleanFilter:
boolean_filter = BooleanFilter(
booleans=[True if flag == 5 else False for flag in source.data['flag']]
)
view = CDSView(source=source, filters=[boolean_filter])
But I reckon this is less efficient
Most helpful comment
I don't see any reason why the group parameter couldn't be a boolean or number. The JS implementation just checks whether the values of the column are equal (===) to the group parameter. I think this would be an easy addition, just changing the types that are allowed for
groupon the python and JS sides.