INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
The CSS files in the BokehJS directory.
def css_files(self): ''' The CSS files in the BokehJS directory. ''' bokehjsdir = self.bokehjsdir() js_files = [] for root, dirnames, files in os.walk(bokehjsdir): for fname in files: if fname.endswith(".css"): js_files.append(join...
Return a serialized JSON representation of objects suitable to send to BokehJS.
def serialize_json(obj, pretty=None, indent=None, **kwargs): ''' Return a serialized JSON representation of objects, suitable to send to BokehJS. This function is typically used to serialize single python objects in the manner expected by BokehJS. In particular, many datetime values are automatical...
Handle special scalars such as ( Python NumPy or Pandas ) datetimes or Decimal values.
def transform_python_types(self, obj): ''' Handle special scalars such as (Python, NumPy, or Pandas) datetimes, or Decimal values. Args: obj (obj) : The object to encode. Anything not specifically handled in this method is passed on to the default sy...
The required default method for JSONEncoder subclasses.
def default(self, obj): ''' The required ``default`` method for ``JSONEncoder`` subclasses. Args: obj (obj) : The object to encode. Anything not specifically handled in this method is passed on to the default system JSON encoder. ''' from ....
Add a handler to the pipeline used to initialize new documents.
def add(self, handler): ''' Add a handler to the pipeline used to initialize new documents. Args: handler (Handler) : a handler for this Application to use to process Documents ''' self._handlers.append(handler) # make sure there is at most one stat...
Fills in a new document using the Application s handlers.
def initialize_document(self, doc): ''' Fills in a new document using the Application's handlers. ''' for h in self._handlers: # TODO (havocp) we need to check the 'failed' flag on each handler # and build a composite error display. In develop mode, we want to ...
Invoked to execute code when a new session is created.
def on_session_created(self, session_context): ''' Invoked to execute code when a new session is created. This method calls ``on_session_created`` on each handler, in order, with the session context passed as the only argument. May return a ``Future`` which will delay session creation ...
Allow flexible selector syntax.
def _select_helper(args, kwargs): """ Allow flexible selector syntax. Returns: dict """ if len(args) > 1: raise TypeError("select accepts at most ONE positional argument.") if len(args) > 0 and len(kwargs) > 0: raise TypeError("select accepts EITHER a positional argument, ...
Query this object and all of its references for objects that match the given selector.
def select(self, *args, **kwargs): ''' Query this object and all of its references for objects that match the given selector. There are a few different ways to call the ``select`` method. The most general is to supply a JSON-like query dictionary as the single argument or as key...
Splattable list of: class: ~bokeh. models. annotations. Legend objects.
def legend(self): ''' Splattable list of :class:`~bokeh.models.annotations.Legend` objects. ''' panels = self.above + self.below + self.left + self.right + self.center legends = [obj for obj in panels if isinstance(obj, Legend)] return _legend_attr_splat(legends)
Splattable list of: class: ~bokeh. models. tools. HoverTool objects.
def hover(self): ''' Splattable list of :class:`~bokeh.models.tools.HoverTool` objects. ''' hovers = [obj for obj in self.tools if isinstance(obj, HoverTool)] return _list_attr_splat(hovers)
Adds an object to the plot in a specified place.
def add_layout(self, obj, place='center'): ''' Adds an object to the plot in a specified place. Args: obj (Renderer) : the object to add to the Plot place (str, optional) : where to add the object (default: 'center') Valid places are: 'left', 'right', 'above', 'b...
Adds tools to the plot.
def add_tools(self, *tools): ''' Adds tools to the plot. Args: *tools (Tool) : the tools to add to the Plot Returns: None ''' for tool in tools: if not isinstance(tool, Tool): raise ValueError("All arguments to add_tool must ...
Adds a glyph to the plot with associated data sources and ranges.
def add_glyph(self, source_or_glyph, glyph=None, **kw): ''' Adds a glyph to the plot with associated data sources and ranges. This function will take care of creating and configuring a Glyph object, and then add it to the plot's list of renderers. Args: source (DataSource) ...
Adds new TileRenderer into Plot. renderers
def add_tile(self, tile_source, **kw): ''' Adds new ``TileRenderer`` into ``Plot.renderers`` Args: tile_source (TileSource) : a tile source instance which contain tileset configuration Keyword Arguments: Additional keyword arguments are passed on as-is to the tile rende...
Create a row of Bokeh Layout objects. Forces all objects to have the same sizing_mode which is required for complex layouts to work.
def row(*args, **kwargs): """ Create a row of Bokeh Layout objects. Forces all objects to have the same sizing_mode, which is required for complex layouts to work. Args: children (list of :class:`~bokeh.models.layouts.LayoutDOM` ): A list of instances for the row. Can be any of the foll...
Create a column of Bokeh Layout objects. Forces all objects to have the same sizing_mode which is required for complex layouts to work.
def column(*args, **kwargs): """ Create a column of Bokeh Layout objects. Forces all objects to have the same sizing_mode, which is required for complex layouts to work. Args: children (list of :class:`~bokeh.models.layouts.LayoutDOM` ): A list of instances for the column. Can be any of...
Create a column of bokeh widgets with predefined styling.
def widgetbox(*args, **kwargs): """ Create a column of bokeh widgets with predefined styling. Args: children (list of :class:`~bokeh.models.widgets.widget.Widget`): A list of widgets. sizing_mode (``"fixed"``, ``"stretch_both"``, ``"scale_width"``, ``"scale_height"``, ``"scale_both"`` ): How ...
Create a grid - based arrangement of Bokeh Layout objects.
def layout(*args, **kwargs): """ Create a grid-based arrangement of Bokeh Layout objects. Args: children (list of lists of :class:`~bokeh.models.layouts.LayoutDOM` ): A list of lists of instances for a grid layout. Can be any of the following - :class:`~bokeh.models.plots.Plot`, ...
Create a grid of plots rendered on separate canvases.
def gridplot(children, sizing_mode=None, toolbar_location='above', ncols=None, plot_width=None, plot_height=None, toolbar_options=None, merge_tools=True): ''' Create a grid of plots rendered on separate canvases. The ``gridplot`` function builds a single toolbar for all the plots in the grid. ...
Conveniently create a grid of layoutable objects.
def grid(children=[], sizing_mode=None, nrows=None, ncols=None): """ Conveniently create a grid of layoutable objects. Grids are created by using ``GridBox`` model. This gives the most control over the layout of a grid, but is also tedious and may result in unreadable code in practical applications...
Recursively create grid from input lists.
def _create_grid(iterable, sizing_mode, layer=0): """Recursively create grid from input lists.""" return_list = [] for item in iterable: if isinstance(item, list): return_list.append(_create_grid(item, sizing_mode, layer+1)) elif isinstance(item, LayoutDOM): if sizing...
Yield successive n - sized chunks from list l.
def _chunks(l, ncols): """Yield successive n-sized chunks from list, l.""" assert isinstance(ncols, int), "ncols must be an integer" for i in range(0, len(l), ncols): yield l[i: i+ncols]
Wrap a callback function to execute without first obtaining the document lock.
def without_document_lock(func): ''' Wrap a callback function to execute without first obtaining the document lock. Args: func (callable) : The function to wrap Returns: callable : a function wrapped to execute without a |Document| lock. While inside an unlocked callback, it is co...
Return a script tag that embeds content from a Bokeh server.
def server_document(url="default", relative_urls=False, resources="default", arguments=None): ''' Return a script tag that embeds content from a Bokeh server. Bokeh apps embedded using these methods will NOT set the browser window title. Args: url (str, optional) : A URL to a Bokeh app...
Return a script tag that embeds content from a specific existing session on a Bokeh server.
def server_session(model=None, session_id=None, url="default", relative_urls=False, resources="default"): ''' Return a script tag that embeds content from a specific existing session on a Bokeh server. This function is typically only useful for serving from a a specific session that was previously crea...
Produce a canonical Bokeh server URL.
def _clean_url(url): ''' Produce a canonical Bokeh server URL. Args: url (str) A URL to clean, or "defatul". If "default" then the ``BOKEH_SERVER_HTTP_URL`` will be returned. Returns: str ''' if url == 'default': url = DEFAULT_SERVER_HTTP_URL i...
Extract the app path from a Bokeh server URL
def _get_app_path(url): ''' Extract the app path from a Bokeh server URL Args: url (str) : Returns: str ''' app_path = urlparse(url).path.rstrip("/") if not app_path.startswith("/"): app_path = "/" + app_path return app_path
Return user - supplied HTML arguments to add to a Bokeh server URL.
def _process_arguments(arguments): ''' Return user-supplied HTML arguments to add to a Bokeh server URL. Args: arguments (dict[str, object]) : Key/value pairs to add to the URL Returns: str ''' if arguments is None: return "" result = "" for key, value in argum...
Implement a check_origin policy for Tornado to call.
def check_origin(self, origin): ''' Implement a check_origin policy for Tornado to call. The supplied origin will be compared to the Bokeh server whitelist. If the origin is not allow, an error will be logged and ``False`` will be returned. Args: origin (str) : ...
Initialize a connection to a client.
def open(self): ''' Initialize a connection to a client. Returns: None ''' log.info('WebSocket connection opened') proto_version = self.get_argument("bokeh-protocol-version", default=None) if proto_version is None: self.close() raise...
Perform the specific steps needed to open a connection to a Bokeh session
def _async_open(self, session_id, proto_version): ''' Perform the specific steps needed to open a connection to a Bokeh session Specifically, this method coordinates: * Getting a session for a session ID (creating a new one if needed) * Creating a protocol receiver and hander *...
Process an individual wire protocol fragment.
def on_message(self, fragment): ''' Process an individual wire protocol fragment. The websocket RFC specifies opcodes for distinguishing text frames from binary frames. Tornado passes us either a text or binary string depending on that opcode, we have to look at the type of the fragment...
Send a Bokeh Server protocol message to the connected client.
def send_message(self, message): ''' Send a Bokeh Server protocol message to the connected client. Args: message (Message) : a message to send ''' try: if _message_test_port is not None: _message_test_port.sent.append(message) yield m...
Override parent write_message with a version that acquires a write lock before writing.
def write_message(self, message, binary=False, locked=True): ''' Override parent write_message with a version that acquires a write lock before writing. ''' if locked: with (yield self.write_lock.acquire()): yield super(WSHandler, self).write_message(message,...
Clean up when the connection is closed.
def on_close(self): ''' Clean up when the connection is closed. ''' log.info('WebSocket connection closed: code=%s, reason=%r', self.close_code, self.close_reason) if self.connection is not None: self.application.client_lost(self.connection)
Generate rendered CSS and JS resources suitable for the given collection of Bokeh objects
def bundle_for_objs_and_resources(objs, resources): ''' Generate rendered CSS and JS resources suitable for the given collection of Bokeh objects Args: objs (seq[Model or Document]) : resources (BaseResources or tuple[BaseResources]) Returns: tuple ''' if isinstance(r...
Whether any of a collection of objects satisfies a given query predicate
def _any(objs, query): ''' Whether any of a collection of objects satisfies a given query predicate Args: objs (seq[Model or Document]) : query (callable) Returns: True, if ``query(obj)`` is True for some object in ``objs``, else False ''' for obj in objs: if isin...
Whether a collection of Bokeh objects contains a plot requesting WebGL
def _use_gl(objs): ''' Whether a collection of Bokeh objects contains a plot requesting WebGL Args: objs (seq[Model or Document]) : Returns: bool ''' from ..models.plots import Plot return _any(objs, lambda obj: isinstance(obj, Plot) and obj.output_backend == "webgl")
Whether a collection of Bokeh objects contains a TableWidget
def _use_tables(objs): ''' Whether a collection of Bokeh objects contains a TableWidget Args: objs (seq[Model or Document]) : Returns: bool ''' from ..models.widgets import TableWidget return _any(objs, lambda obj: isinstance(obj, TableWidget))
Whether a collection of Bokeh objects contains a any Widget
def _use_widgets(objs): ''' Whether a collection of Bokeh objects contains a any Widget Args: objs (seq[Model or Document]) : Returns: bool ''' from ..models.widgets import Widget return _any(objs, lambda obj: isinstance(obj, Widget))
MetaHasProps calls this during class creation as it iterates over properties to add to update its registry of new properties.
def add_prop_descriptor_to_class(self, class_name, new_class_attrs, names_with_refs, container_names, dataspecs): ''' ``MetaHasProps`` calls this during class creation as it iterates over properties to add, to update its registry of new properties. The parameters passed in are mutable and this ...
Produce the value as it should be serialized.
def serializable_value(self, obj): ''' Produce the value as it should be serialized. Sometimes it is desirable for the serialized value to differ from the ``__get__`` in order for the ``__get__`` value to appear simpler for user or developer convenience. Args: obj (...
Sets the value of this property from a JSON value.
def set_from_json(self, obj, json, models=None, setter=None): '''Sets the value of this property from a JSON value. Args: obj: (HasProps) : instance to set the property value on json: (JSON-value) : value to set to the attribute to models (dict or None, optional) :...
Get the default value that will be used for a specific instance.
def instance_default(self, obj): ''' Get the default value that will be used for a specific instance. Args: obj (HasProps) : The instance to get the default value for. Returns: object ''' return self.property.themed_default(obj.__class__, self.name, obj...
Sets the value of this property from a JSON value.
def set_from_json(self, obj, json, models=None, setter=None): ''' Sets the value of this property from a JSON value. This method first Args: obj (HasProps) : json (JSON-dict) : models(seq[Model], optional) : setter (ClientSession or ServerSess...
Send a change event notification if the property is set to a value is not equal to old.
def trigger_if_changed(self, obj, old): ''' Send a change event notification if the property is set to a value is not equal to ``old``. Args: obj (HasProps) The object the property is being set on. old (obj) : The previous value of the pr...
Internal implementation of instance attribute access for the BasicPropertyDescriptor getter.
def _get(self, obj): ''' Internal implementation of instance attribute access for the ``BasicPropertyDescriptor`` getter. If the value has not been explicitly set by a user, return that value. Otherwise, return the default. Args: obj (HasProps) : the instance to get...
Internal implementation of instance attribute access for default values.
def _get_default(self, obj): ''' Internal implementation of instance attribute access for default values. Handles bookeeping around |PropertyContainer| value, etc. ''' if self.name in obj._property_values: # this shouldn't happen because we should have checked befor...
Internal implementation to set property values that is used by __set__ set_from_json etc.
def _internal_set(self, obj, value, hint=None, setter=None): ''' Internal implementation to set property values, that is used by __set__, set_from_json, etc. Delegate to the |Property| instance to prepare the value appropriately, then `set. Args: obj (HasProps) ...
Internal implementation helper to set property values.
def _real_set(self, obj, old, value, hint=None, setter=None): ''' Internal implementation helper to set property values. This function handles bookkeeping around noting whether values have been explicitly set, etc. Args: obj (HasProps) The object the propert...
A method to call when a container is mutated behind our back and we detect it with our |PropertyContainer| wrappers.
def _notify_mutated(self, obj, old, hint=None): ''' A method to call when a container is mutated "behind our back" and we detect it with our |PropertyContainer| wrappers. Args: obj (HasProps) : The object who's container value was mutated old (object) : ...
Unconditionally send a change event notification for the property.
def _trigger(self, obj, old, value, hint=None, setter=None): ''' Unconditionally send a change event notification for the property. Args: obj (HasProps) The object the property is being set on. old (obj) : The previous value of the property ...
Sets the value of this property from a JSON value.
def set_from_json(self, obj, json, models=None, setter=None): ''' Sets the value of this property from a JSON value. This method first Args: obj (HasProps) : json (JSON-dict) : models(seq[Model], optional) : setter (ClientSession or ServerSess...
Sets the value of this property from a JSON value.
def set_from_json(self, obj, json, models=None, setter=None): ''' Sets the value of this property from a JSON value. This method first separately extracts and removes any ``units`` field in the JSON, and sets the associated units property directly. The remaining JSON is then passed to t...
Internal helper for dealing with units associated units properties when setting values on |UnitsSpec| properties.
def _extract_units(self, obj, value): ''' Internal helper for dealing with units associated units properties when setting values on |UnitsSpec| properties. When ``value`` is a dict, this function may mutate the value of the associated units property. Args: obj (HasP...
Install a new notebook display hook.
def install_notebook_hook(notebook_type, load, show_doc, show_app, overwrite=False): ''' Install a new notebook display hook. Bokeh comes with support for Jupyter notebooks built-in. However, there are other kinds of notebooks in use by different communities. This function provides a mechanism for othe...
Update Bokeh plots in a Jupyter notebook output cells with new data or property values.
def push_notebook(document=None, state=None, handle=None): ''' Update Bokeh plots in a Jupyter notebook output cells with new data or property values. When working the the notebook, the ``show`` function can be passed the argument ``notebook_handle=True``, which will cause it to return a handle obj...
Run an installed notebook hook with supplied arguments.
def run_notebook_hook(notebook_type, action, *args, **kw): ''' Run an installed notebook hook with supplied arguments. Args: noteboook_type (str) : Name of an existing installed notebook hook actions (str) : Name of the hook action to execute, ``'doc'`` or ``'app'`` ...
Given a UUID id of a div removed or replaced in the Jupyter notebook destroy the corresponding server sessions and stop it.
def destroy_server(server_id): ''' Given a UUID id of a div removed or replaced in the Jupyter notebook, destroy the corresponding server sessions and stop it. ''' server = curstate().uuid_to_server.get(server_id, None) if server is None: log.debug("No server instance found for uuid: %r" % ...
Prepare the IPython notebook for displaying Bokeh plots.
def load_notebook(resources=None, verbose=False, hide_banner=False, load_timeout=5000): ''' Prepare the IPython notebook for displaying Bokeh plots. Args: resources (Resource, optional) : how and where to load BokehJS from (default: CDN) verbose (bool, optional) : wheth...
Embed a Bokeh server application in a Jupyter Notebook output cell.
def show_app(app, state, notebook_url, port=0, **kw): ''' Embed a Bokeh server application in a Jupyter Notebook output cell. Args: app (Application or callable) : A Bokeh Application to embed inline in a Jupyter notebook. state (State) : ** Unused ** notebook_...
Clamp numeric values to be non - negative an optionally less than a given maximum.
def clamp(value, maximum=None): ''' Clamp numeric values to be non-negative, an optionally, less than a given maximum. Args: value (float) : A number to clamp. maximum (float, optional) : A max bound to to clamp to. If None, there is no u...
Darken ( reduce the luminance ) of this color.
def darken(self, amount): ''' Darken (reduce the luminance) of this color. Args: amount (float) : Amount to reduce the luminance by (clamped above zero) Returns: Color ''' hsl = self.to_hsl() hsl.l = self.clamp(hsl.l - amount) ...
Lighten ( increase the luminance ) of this color.
def lighten(self, amount): ''' Lighten (increase the luminance) of this color. Args: amount (float) : Amount to increase the luminance by (clamped above zero) Returns: Color ''' hsl = self.to_hsl() hsl.l = self.clamp(hsl.l + amou...
Set up a handler for button state changes ( clicks ).
def on_click(self, handler): """ Set up a handler for button state changes (clicks). Args: handler (func) : handler function to call when button is toggled. Returns: None """ self.on_change('active', lambda attr, old, new: handler(new))
Set up a handler for button or menu item clicks.
def on_click(self, handler): ''' Set up a handler for button or menu item clicks. Args: handler (func) : handler function to call when button is activated. Returns: None ''' self.on_event(ButtonClick, handler) self.on_event(MenuItemClick, handle...
Set up a JavaScript handler for button or menu item clicks.
def js_on_click(self, handler): ''' Set up a JavaScript handler for button or menu item clicks. ''' self.js_on_event(ButtonClick, handler) self.js_on_event(MenuItemClick, handler)
Attempt to import an optional dependency.
def import_optional(mod_name): ''' Attempt to import an optional dependency. Silently returns None if the requested module is not available. Args: mod_name (str) : name of the optional module to try to import Returns: imported module or None, if import fails ''' try: ...
Detect if PhantomJS is avaiable in PATH at a minimum version.
def detect_phantomjs(version='2.1'): ''' Detect if PhantomJS is avaiable in PATH, at a minimum version. Args: version (str, optional) : Required minimum version for PhantomJS (mostly for testing) Returns: str, path to PhantomJS ''' if settings.phantomjs_path() is not N...
Consume individual protocol message fragments.
def consume(self, fragment): ''' Consume individual protocol message fragments. Args: fragment (``JSON``) : A message fragment to assemble. When a complete message is assembled, the receiver state will reset to begin consuming a new message. ...
Required Sphinx extension setup function.
def setup(app): ''' Required Sphinx extension setup function. ''' app.add_autodocumenter(ColorDocumenter) app.add_autodocumenter(EnumDocumenter) app.add_autodocumenter(PropDocumenter) app.add_autodocumenter(ModelDocumenter)
Return a driver function that can advance a bounced sequence of values.
def bounce(sequence): ''' Return a driver function that can advance a "bounced" sequence of values. .. code-block:: none seq = [0, 1, 2, 3] # bounce(seq) => [0, 1, 2, 3, 3, 2, 1, 0, 0, 1, 2, ...] Args: sequence (seq) : a sequence of values for the driver to bounce ''' ...
Return a driver function that can advance a sequence of cosine values.
def cosine(w, A=1, phi=0, offset=0): ''' Return a driver function that can advance a sequence of cosine values. .. code-block:: none value = A * cos(w*i + phi) + offset Args: w (float) : a frequency for the cosine driver A (float) : an amplitude for the cosine driver phi (...
Return a driver function that can advance a sequence of linear values.
def linear(m=1, b=0): ''' Return a driver function that can advance a sequence of linear values. .. code-block:: none value = m * i + b Args: m (float) : a slope for the linear driver x (float) : an offset for the linear driver ''' def f(i): return m * i + b r...
Return a driver function that can advance a repeated of values.
def repeat(sequence): ''' Return a driver function that can advance a repeated of values. .. code-block:: none seq = [0, 1, 2, 3] # repeat(seq) => [0, 1, 2, 3, 0, 1, 2, 3, 0, 1, ...] Args: sequence (seq) : a sequence of values for the driver to bounce ''' N = len(sequenc...
Return a driver function that can advance a sequence of sine values.
def sine(w, A=1, phi=0, offset=0): ''' Return a driver function that can advance a sequence of sine values. .. code-block:: none value = A * sin(w*i + phi) + offset Args: w (float) : a frequency for the sine driver A (float) : an amplitude for the sine driver phi (float) :...
Required Sphinx extension setup function.
def setup(app): ''' Required Sphinx extension setup function. ''' app.add_node( collapsible_code_block, html=( html_visit_collapsible_code_block, html_depart_collapsible_code_block ) ) app.add_directive('collapsible-code-block', CollapsibleCodeBlock)
Collect a duplicate - free list of all other Bokeh models referred to by this model or by any of its references etc unless filtered - out by the provided callable.
def collect_filtered_models(discard, *input_values): ''' Collect a duplicate-free list of all other Bokeh models referred to by this model, or by any of its references, etc, unless filtered-out by the provided callable. Iterate over ``input_values`` and descend through their structure collecting al...
Look up a Bokeh model class given its view model name.
def get_class(view_model_name): ''' Look up a Bokeh model class, given its view model name. Args: view_model_name (str) : A view model name for a Bokeh model to look up Returns: Model: the model class corresponding to ``view_model_name`` Raises: KeyError, if the mo...
Visit all references to another Model without recursing into any of the child Model ; may visit the same Model more than once if it s referenced more than once. Does not visit the passed - in value.
def _visit_immediate_value_references(value, visitor): ''' Visit all references to another Model without recursing into any of the child Model; may visit the same Model more than once if it's referenced more than once. Does not visit the passed-in value. ''' if isinstance(value, HasProps): ...
Recurse down Models HasProps and Python containers
def _visit_value_and_its_immediate_references(obj, visitor): ''' Recurse down Models, HasProps, and Python containers The ordering in this function is to optimize performance. We check the most comomn types (int, float, str) first so that we can quickly return in the common case. We avoid isinstance ...
A Bokeh protocol reference to this model i. e. a dict of the form:
def ref(self): ''' A Bokeh protocol "reference" to this model, i.e. a dict of the form: .. code-block:: python { 'type' : << view model name >> 'id' : << unique model id >> } Additionally there may be a `subtype` field if this ...
Link two Bokeh model properties using JavaScript.
def js_link(self, attr, other, other_attr): ''' Link two Bokeh model properties using JavaScript. This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value. Args: attr (str) : T...
Attach a CustomJS callback to an arbitrary BokehJS model event.
def js_on_change(self, event, *callbacks): ''' Attach a ``CustomJS`` callback to an arbitrary BokehJS model event. On the BokehJS side, change events for model properties have the form ``"change:property_name"``. As a convenience, if the event name passed to this method is also the name...
Add a callback on this object to trigger when attr changes.
def on_change(self, attr, *callbacks): ''' Add a callback on this object to trigger when ``attr`` changes. Args: attr (str) : an attribute name on this object *callbacks (callable) : callback functions to register Returns: None Example: .. ...
Update objects that match a given selector with the specified attribute/ value updates.
def set_select(self, selector, updates): ''' Update objects that match a given selector with the specified attribute/value updates. Args: selector (JSON-like) : updates (dict) : Returns: None ''' for obj in self.select(selector): ...
Returns a JSON string encoding the attributes of this object.
def to_json_string(self, include_defaults): ''' Returns a JSON string encoding the attributes of this object. References to other objects are serialized as references (just the object ID and type info), so the deserializer will need to separately have the full attributes of those ...
Attach a model to a Bokeh |Document|.
def _attach_document(self, doc): ''' Attach a model to a Bokeh |Document|. This private interface should only ever called by the Document implementation to set the private ._document field properly ''' if self._document is not None and self._document is not doc: rai...
Returns a dictionary of the attributes of this object in a layout corresponding to what BokehJS expects at unmarshalling time.
def _to_json_like(self, include_defaults): ''' Returns a dictionary of the attributes of this object, in a layout corresponding to what BokehJS expects at unmarshalling time. This method does not convert "Bokeh types" into "plain JSON types," for example each child Model will still be a...
Create a new: class: ~bokeh. plotting. gmap. GMap for plotting.
def gmap(google_api_key, map_options, **kwargs): ''' Create a new :class:`~bokeh.plotting.gmap.GMap` for plotting. Args: google_api_key (str): Google requires an API key be supplied for maps to function. See: https://developers.google.com/maps/documentation/javascript/get-api-k...
Return a copy of this color value.
def copy(self): ''' Return a copy of this color value. Returns: HSL ''' return HSL(self.h, self.s, self.l, self.a)
Generate the CSS representation of this HSL color.
def to_css(self): ''' Generate the CSS representation of this HSL color. Returns: str, ``"hsl(...)"`` or ``"hsla(...)"`` ''' if self.a == 1.0: return "hsl(%d, %s%%, %s%%)" % (self.h, self.s*100, self.l*100) else: return "hsla(%d, %s%%, %s%%, ...
Return a corresponding: class: ~bokeh. colors. rgb. RGB color for this HSL color.
def to_rgb(self): ''' Return a corresponding :class:`~bokeh.colors.rgb.RGB` color for this HSL color. Returns: HSL ''' from .rgb import RGB # prevent circular import r, g, b = colorsys.hls_to_rgb(float(self.h)/360, self.l, self.s) return RGB(round(r*...
Get the location of the server subpackage
def serverdir(): """ Get the location of the server subpackage """ path = join(ROOT_DIR, 'server') path = normpath(path) if sys.platform == 'cygwin': path = realpath(path) return path
Get the location of the bokehjs source files. If dev is True the files in bokehjs/ build are preferred. Otherwise uses the files in bokeh/ server/ static.
def bokehjsdir(dev=False): """ Get the location of the bokehjs source files. If dev is True, the files in bokehjs/build are preferred. Otherwise uses the files in bokeh/server/static. """ dir1 = join(ROOT_DIR, '..', 'bokehjs', 'build') dir2 = join(serverdir(), 'static') if dev and isdir(dir1...
Install the Bokeh Server and its background tasks on a Tornado IOLoop.
def start(self): ''' Install the Bokeh Server and its background tasks on a Tornado ``IOLoop``. This method does *not* block and does *not* affect the state of the Tornado ``IOLoop`` You must start and stop the loop yourself, i.e. this method is typically useful when you are al...
Stop the Bokeh Server.
def stop(self, wait=True): ''' Stop the Bokeh Server. This stops and removes all Bokeh Server ``IOLoop`` callbacks, as well as stops the ``HTTPServer`` that this instance was configured with. Args: fast (bool): Whether to wait for orderly cleanup (default: T...
Run the Bokeh Server until shutdown is requested by the user either via a Keyboard interrupt ( Ctrl - C ) or SIGTERM.
def run_until_shutdown(self): ''' Run the Bokeh Server until shutdown is requested by the user, either via a Keyboard interrupt (Ctrl-C) or SIGTERM. Calling this method will start the Tornado ``IOLoop`` and block all execution in the calling process. Returns: None ...
Gets all currently active sessions for applications.
def get_sessions(self, app_path=None): ''' Gets all currently active sessions for applications. Args: app_path (str, optional) : The configured application path for the application to return sessions for. If None, return active sessions for all ...