def __init__(self, *args, **kwargs): # pop tools as it is also a property that doesn't match the argument # supported types tools = kwargs.pop('tools', None) for name in ['xgrid', 'ygrid', 'legend']: if name in kwargs: kwargs["_" + name] = kwargs[name] del kwargs[name] if 'responsive' in kwargs and 'sizing_mode' in kwargs: raise ValueError( "Chart initialized with both 'responsive' and 'sizing_mode' supplied, supply only one" ) if 'responsive' in kwargs: kwargs['sizing_mode'] = _convert_responsive(kwargs['responsive']) del kwargs['responsive'] self._active_drag = kwargs.pop('active_drag', 'auto') self._active_inspect = kwargs.pop('active_inspect', 'auto') self._active_scroll = kwargs.pop('active_scroll', 'auto') self._active_tap = kwargs.pop('active_tap', 'auto') title_text = kwargs.pop("title", None) super(Chart, self).__init__(*args, **kwargs) self.title.text = title_text defaults.apply(self) if tools is not None: self._tools = tools # TODO (fpliger): we do this to still support deprecated document but # should go away when __deprecated_attributes__ is empty for k in self.__deprecated_attributes__: if k in kwargs: setattr(self, k, kwargs[k]) self._glyphs = [] self._built = False self._builders = [] self._renderer_map = [] self._ranges = defaultdict(list) self._labels = defaultdict(list) self._scales = defaultdict(list) self._tooltips = [] if hasattr(self, '_tools'): self.create_tools(self._tools, self._active_drag, self._active_inspect, self._active_scroll, self._active_tap)
def __init__(self, *args, **kwargs): # pop tools as it is also a property that doesn't match the argument # supported types tools = kwargs.pop('tools', None) for name in ['xgrid', 'ygrid', 'legend']: if name in kwargs: kwargs["_" + name] = kwargs[name] del kwargs[name] if 'responsive' in kwargs and 'sizing_mode' in kwargs: raise ValueError("Chart initialized with both 'responsive' and 'sizing_mode' supplied, supply only one") if 'responsive' in kwargs: kwargs['sizing_mode'] = _convert_responsive(kwargs['responsive']) del kwargs['responsive'] self._active_drag = kwargs.pop('active_drag', 'auto') self._active_inspect = kwargs.pop('active_inspect', 'auto') self._active_scroll = kwargs.pop('active_scroll', 'auto') self._active_tap = kwargs.pop('active_tap', 'auto') title_text = kwargs.pop("title", None) super(Chart, self).__init__(*args, **kwargs) self.title.text = title_text defaults.apply(self) if tools is not None: self._tools = tools # TODO (fpliger): we do this to still support deprecated document but # should go away when __deprecated_attributes__ is empty for k in self.__deprecated_attributes__: if k in kwargs: setattr(self, k, kwargs[k]) self._glyphs = [] self._built = False self._builders = [] self._renderer_map = [] self._ranges = defaultdict(list) self._labels = defaultdict(list) self._scales = defaultdict(list) self._tooltips = [] if hasattr(self, '_tools'): self.create_tools(self._tools, self._active_drag, self._active_inspect, self._active_scroll, self._active_tap)
def test__convert_responsive_false(): assert _convert_responsive(False) == 'fixed'
def test__convert_responsive_true(): assert _convert_responsive(True) == 'scale_width'
def test__convert_responsive_error(): with pytest.raises(ValueError): _convert_responsive("foo")