Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def accumulate_from_superclasses(cls, propname): ''' Traverse the class hierarchy and accumulate the special sets of names ``MetaHasProps`` stores on classes: Args: name (str) : name of the special attribute to collect. Typically meaningful ...
[]
Please provide a description of the function:def accumulate_dict_from_superclasses(cls, propname): ''' Traverse the class hierarchy and accumulate the special dicts ``MetaHasProps`` stores on classes: Args: name (str) : name of the special attribute to collect. Typically meaningful val...
[]
Please provide a description of the function:def equals(self, other): ''' Structural equality of models. Args: other (HasProps) : the other instance to compare to Returns: True, if properties are structurally equal, otherwise False ''' # NOTE: don't tr...
[]
Please provide a description of the function:def set_from_json(self, name, json, models=None, setter=None): ''' Set a property value on this object from JSON. Args: name: (str) : name of the attribute to set json: (JSON-value) : value to set to the attribute to mod...
[]
Please provide a description of the function:def update_from_json(self, json_attributes, models=None, setter=None): ''' Updates the object's properties from a JSON attributes dictionary. Args: json_attributes: (JSON-dict) : attributes and values to update models (dict or None, ...
[]
Please provide a description of the function:def properties(cls, with_bases=True): ''' Collect the names of properties on this class. This method *optionally* traverses the class hierarchy and includes properties defined on any parent classes. Args: with_bases (bool, option...
[]
Please provide a description of the function:def properties_with_values(self, include_defaults=True): ''' Collect a dict mapping property names to their values. This method *always* traverses the class hierarchy and includes properties defined on any parent classes. Non-serializable pr...
[]
Please provide a description of the function:def query_properties_with_values(self, query, include_defaults=True): ''' Query the properties values of |HasProps| instances with a predicate. Args: query (callable) : A callable that accepts property descriptors and retu...
[]
Please provide a description of the function:def apply_theme(self, property_values): ''' Apply a set of theme values which will be used rather than defaults, but will not override application-set values. The passed-in dictionary may be kept around as-is and shared with other instances t...
[]
Please provide a description of the function:def indent(text, n=2, ch=" "): ''' Indent all the lines in a given block of text by a specified amount. Args: text (str) : The text to indent n (int, optional) : The amount to indent each line by (default: 2) ch (cha...
[]
Please provide a description of the function:def nice_join(seq, sep=", ", conjuction="or"): ''' Join together sequences of strings into English-friendly phrases using the conjunction ``or`` when appropriate. Args: seq (seq[str]) : a sequence of strings to nicely join sep (str, optional) : a...
[]
Please provide a description of the function:def snakify(name, sep='_'): ''' Convert CamelCase to snake_case. ''' name = re.sub("([A-Z]+)([A-Z][a-z])", r"\1%s\2" % sep, name) name = re.sub("([a-z\\d])([A-Z])", r"\1%s\2" % sep, name) return name.lower()
[]
Please provide a description of the function:def _on_session_destroyed(session_context): ''' Calls any on_session_destroyed callbacks defined on the Document ''' callbacks = session_context._document.session_destroyed_callbacks session_context._document.session_destroyed_callbacks = set() for ca...
[]
Please provide a description of the function:def register(cls): ''' Decorator to add a Message (and its revision) to the Protocol index. Example: .. code-block:: python @register class some_msg_1(Message): msgtype = 'SOME-MSG' revision = 1 ...
[]
Please provide a description of the function:def pull_session(session_id=None, url='default', io_loop=None, arguments=None): ''' Create a session by loading the current server-side document. ``session.document`` will be a fresh document loaded from the server. While the connection to the server is open, ...
[]
Please provide a description of the function:def push_session(document, session_id=None, url='default', io_loop=None): ''' Create a session by pushing the given document to the server, overwriting any existing server-side document. ``session.document`` in the returned session will be your supplied docu...
[]
Please provide a description of the function:def show_session(session_id=None, url='default', session=None, browser=None, new="tab", controller=None): ''' Open a browser displaying a session document. If you have a session from ``pull_session()`` or ``push_session`` you can ``show_session(sessi...
[]
Please provide a description of the function:def loop_until_closed(self, suppress_warning=False): ''' Execute a blocking loop that runs and executes event callbacks until the connection is closed (e.g. by hitting Ctrl-C). While this method can be used to run Bokeh application code "outside" ...
[]
Please provide a description of the function:def pull(self): ''' Pull the server's state and set it as session.document. If this is called more than once, session.document will be the same object instance but its contents will be overwritten. Automatically calls :func:`connect` before ...
[]
Please provide a description of the function:def push(self, document=None): ''' Push the given document to the server and record it as session.document. If this is called more than once, the Document has to be the same (or None to mean "session.document"). .. note:: Automat...
[]
Please provide a description of the function:def show(self, obj=None, browser=None, new="tab"): ''' Open a browser displaying this session. Args: obj (LayoutDOM object, optional) : a Layout (Row/Column), Plot or Widget object to display. The object will be added ...
[]
Please provide a description of the function:def _notify_disconnected(self): ''' Called by the ClientConnection we are using to notify us of disconnect. ''' if self.document is not None: self.document.remove_on_change(self) self._callbacks.remove_all_callbacks()
[]
Please provide a description of the function:def assemble(cls, header_json, metadata_json, content_json): ''' Creates a new message, assembled from JSON fragments. Args: header_json (``JSON``) : metadata_json (``JSON``) : content_json (``JSON``) : Returns:...
[]
Please provide a description of the function:def add_buffer(self, buf_header, buf_payload): ''' Associate a buffer header and payload with this message. Args: buf_header (``JSON``) : a buffer header buf_payload (``JSON`` or bytes) : a buffer payload Returns: ...
[]
Please provide a description of the function:def assemble_buffer(self, buf_header, buf_payload): ''' Add a buffer header and payload that we read from the socket. This differs from add_buffer() because we're validating vs. the header's num_buffers, instead of filling in the header. Arg...
[]
Please provide a description of the function:def write_buffers(self, conn, locked=True): ''' Write any buffer headers and payloads to the given connection. Args: conn (object) : May be any object with a ``write_message`` method. Typically, a Tornado ``WSHandl...
[]
Please provide a description of the function:def create_header(cls, request_id=None): ''' Return a message header fragment dict. Args: request_id (str or None) : Message ID of the message this message replies to Returns: dict : a message header ...
[]
Please provide a description of the function:def send(self, conn): ''' Send the message on the given connection. Args: conn (WebSocketHandler) : a WebSocketHandler to send messages Returns: int : number of bytes sent ''' if conn is None: rai...
[]
Please provide a description of the function:def complete(self): ''' Returns whether all required parts of a message are present. Returns: bool : True if the message is complete, False otherwise ''' return self.header is not None and \ self.metadata is not None ...
[]
Please provide a description of the function:def basicConfig(*args, **kwargs): if default_handler is not None: bokeh_logger.removeHandler(default_handler) bokeh_logger.propagate = True return logging.basicConfig(*args, **kwargs)
[ "\n A logging.basicConfig() wrapper that also undoes the default\n Bokeh-specific configuration.\n " ]
Please provide a description of the function:def deprecated(since_or_msg, old=None, new=None, extra=None): if isinstance(since_or_msg, tuple): if old is None or new is None: raise ValueError("deprecated entity and a replacement are required") if len(since_or_msg) != 3 or not all(i...
[ " Issue a nicely formatted deprecation warning. " ]
Please provide a description of the function:def main(): ''' Execute the "bokeh" command line program. ''' import sys from bokeh.command.bootstrap import main as _main # Main entry point (see setup.py) _main(sys.argv)
[]
Please provide a description of the function:def detach_session(self): if self._session is not None: self._session.unsubscribe(self) self._session = None
[ "Allow the session to be discarded and don't get change notifications from it anymore" ]
Please provide a description of the function:def send_patch_document(self, event): msg = self.protocol.create('PATCH-DOC', [event]) return self._socket.send_message(msg)
[ " Sends a PATCH-DOC message, returning a Future that's completed when it's written out. " ]
Please provide a description of the function:def initialize_references_json(references_json, references, setter=None): ''' Given a JSON representation of the models in a graph, and new model objects, set the properties on the models from the JSON Args: references_json (``JSON``) JSON sp...
[]
Please provide a description of the function:def instantiate_references_json(references_json): ''' Given a JSON representation of all the models in a graph, return a dict of new model objects. Args: references_json (``JSON``) JSON specifying new Bokeh models to create Returns: ...
[]
Please provide a description of the function:def references_json(references): ''' Given a list of all models in a graph, return JSON representing them and their properties. Args: references (seq[Model]) : A list of models to convert to JSON Returns: list ''' refer...
[]
Please provide a description of the function:def decode_json(cls, dct): ''' Custom JSON decoder for Events. Can be used as the ``object_hook`` argument of ``json.load`` or ``json.loads``. Args: dct (dict) : a JSON dictionary to decode The dictionary should h...
[]
Please provide a description of the function:def bokeh_palette(name, rawtext, text, lineno, inliner, options=None, content=None): ''' Generate an inline visual representations of a single color palette. This function evaluates the expression ``"palette = %s" % text``, in the context of a ``globals`` namesp...
[]
Please provide a description of the function:def cumsum(field, include_zero=False): ''' Create a Create a ``DataSpec`` dict to generate a ``CumSum`` expression for a ``ColumnDataSource``. Examples: .. code-block:: python p.wedge(start_angle=cumsum('angle', include_zero=True), ...
[]
Please provide a description of the function:def dodge(field_name, value, range=None): ''' Create a ``DataSpec`` dict that applies a client-side ``Jitter`` transformation to a ``ColumnDataSource`` column. Args: field_name (str) : a field name to configure ``DataSpec`` with value (float) : ...
[]
Please provide a description of the function:def factor_cmap(field_name, palette, factors, start=0, end=None, nan_color="gray"): ''' Create a ``DataSpec`` dict that applies a client-side ``CategoricalColorMapper`` transformation to a ``ColumnDataSource`` column. Args: field_name (str) : a field...
[]
Please provide a description of the function:def factor_hatch(field_name, patterns, factors, start=0, end=None): ''' Create a ``DataSpec`` dict that applies a client-side ``CategoricalPatternMapper`` transformation to a ``ColumnDataSource`` column. Args: field_name (str) : a field name to confi...
[]
Please provide a description of the function:def factor_mark(field_name, markers, factors, start=0, end=None): ''' Create a ``DataSpec`` dict that applies a client-side ``CategoricalMarkerMapper`` transformation to a ``ColumnDataSource`` column. .. note:: This transform is primarily only useful...
[]
Please provide a description of the function:def jitter(field_name, width, mean=0, distribution="uniform", range=None): ''' Create a ``DataSpec`` dict that applies a client-side ``Jitter`` transformation to a ``ColumnDataSource`` column. Args: field_name (str) : a field name to configure ``DataSpec...
[]
Please provide a description of the function:def linear_cmap(field_name, palette, low, high, low_color=None, high_color=None, nan_color="gray"): ''' Create a ``DataSpec`` dict that applyies a client-side ``LinearColorMapper`` transformation to a ``ColumnDataSource`` column. Args: field_name (str) :...
[]
Please provide a description of the function:def log_cmap(field_name, palette, low, high, low_color=None, high_color=None, nan_color="gray"): ''' Create a ``DataSpec`` dict that applies a client-side ``LogColorMapper`` transformation to a ``ColumnDataSource`` column. Args: field_name (str) : a fiel...
[]
Please provide a description of the function:def get_browser_controller(browser=None): ''' Return a browser controller. Args: browser (str or None) : browser name, or ``None`` (default: ``None``) If passed the string ``'none'``, a dummy web browser controller is returned ...
[]
Please provide a description of the function:def view(location, browser=None, new="same", autoraise=True): ''' Open a browser to view the specified location. Args: location (str) : Location to open If location does not begin with "http:" it is assumed to be a...
[]
Please provide a description of the function:def from_py_func(cls, func): ''' Create a ``CustomJSFilter`` instance from a Python function. The function is translated to JavaScript using PScript. The ``func`` function namespace will contain the variable ``source`` at render time. This wi...
[ "\\\n To use Python functions for CustomJSFilter, you need PScript\n '(\"conda install -c conda-forge pscript\" or \"pip install pscript\")" ]
Please provide a description of the function:def streamlines(x, y, u, v, density=1): ''' Return streamlines of a vector flow. * x and y are 1d arrays defining an *evenly spaced* grid. * u and v are 2d arrays (shape [y,x]) giving velocities. * density controls the closeness of the streamlines. For diffe...
[]
Please provide a description of the function:def display_event(div, attributes=[]): style = 'float: left; clear: left; font-size: 10pt' return CustomJS(args=dict(div=div), code= % (attributes, style))
[ "\n Function to build a suitable CustomJS to display the current event\n in the div model.\n ", "\n var attrs = %s;\n var args = [];\n for (var i = 0; i<attrs.length; i++ ) {\n var val = JSON.stringify(cb_obj[attrs[i]], function(key, val) {\n return val.toFi...
Please provide a description of the function:def print_event(attributes=[]): def python_callback(event): cls_name = event.__class__.__name__ attrs = ', '.join(['{attr}={val}'.format(attr=attr, val=event.__dict__[attr]) for attr in attributes]) print('{cls_name}({a...
[ "\n Function that returns a Python callback to pretty print the events.\n " ]
Please provide a description of the function:def create(self, msgtype, *args, **kwargs): ''' Create a new Message instance for the given type. Args: msgtype (str) : ''' if msgtype not in self._messages: raise ProtocolError("Unknown message type %r for protocol v...
[]
Please provide a description of the function:def assemble(self, header_json, metadata_json, content_json): ''' Create a Message instance assembled from json fragments. Args: header_json (``JSON``) : metadata_json (``JSON``) : content_json (``JSON``) : Retu...
[]
Please provide a description of the function:def _combine_document_events(new_event, old_events): ''' Attempt to combine a new event with a list of previous events. The ``old_event`` will be scanned in reverse, and ``.combine(new_event)`` will be called on each. If a combination can be made, the function ...
[]
Please provide a description of the function:def add_next_tick_callback(self, callback): ''' Add callback to be invoked once on the next tick of the event loop. Args: callback (callable) : A callback function to execute on the next tick. Returns: NextTic...
[]
Please provide a description of the function:def add_periodic_callback(self, callback, period_milliseconds): ''' Add a callback to be invoked on a session periodically. Args: callback (callable) : A callback function to execute periodically period_milliseconds (...
[]
Please provide a description of the function:def add_root(self, model, setter=None): ''' Add a model as a root of this Document. Any changes to this model (including to other models referred to by it) will trigger ``on_change`` callbacks registered on this document. Args: ...
[]
Please provide a description of the function:def add_timeout_callback(self, callback, timeout_milliseconds): ''' Add callback to be invoked once, after a specified timeout passes. Args: callback (callable) : A callback function to execute after timeout timeout_m...
[]
Please provide a description of the function:def apply_json_patch(self, patch, setter=None): ''' Apply a JSON patch object and process any resulting events. Args: patch (JSON-data) : The JSON-object containing the patch to apply. setter (ClientSession or ServerS...
[]
Please provide a description of the function:def clear(self): ''' Remove all content from the document but do not reset title. Returns: None ''' self._push_all_models_freeze() try: while len(self._roots) > 0: r = next(iter(self._roots)) ...
[]
Please provide a description of the function:def delete_modules(self): ''' Clean up after any modules created by this Document when its session is destroyed. ''' from gc import get_referrers from types import FrameType log.debug("Deleting %s modules for %s" % (len(self....
[]
Please provide a description of the function:def from_json(cls, json): ''' Load a document from JSON. json (JSON-data) : A JSON-encoded document to create a new Document from. Returns: Document : ''' roots_json = json['roots'] root_ids = roots_j...
[]
Please provide a description of the function:def hold(self, policy="combine"): ''' Activate a document hold. While a hold is active, no model changes will be applied, or trigger callbacks. Once ``unhold`` is called, the events collected during the hold will be applied according to the h...
[]
Please provide a description of the function:def unhold(self): ''' Turn off any active document hold and apply any collected events. Returns: None ''' # no-op if we are already no holding if self._hold is None: return self._hold = None events = list...
[]
Please provide a description of the function:def on_change(self, *callbacks): ''' Provide callbacks to invoke if the document or any Model reachable from its roots changes. ''' for callback in callbacks: if callback in self._callbacks: continue _check_callback(...
[]
Please provide a description of the function:def on_session_destroyed(self, *callbacks): ''' Provide callbacks to invoke when the session serving the Document is destroyed ''' for callback in callbacks: _check_callback(callback, ('session_context',)) self._sessio...
[]
Please provide a description of the function:def remove_root(self, model, setter=None): ''' Remove a model as root model from this Document. Changes to this model may still trigger ``on_change`` callbacks on this document, if the model is still referred to by other root models. ...
[]
Please provide a description of the function:def replace_with_json(self, json): ''' Overwrite everything in this document with the JSON-encoded document. json (JSON-data) : A JSON-encoded document to overwrite this one. Returns: None ''' replace...
[]
Please provide a description of the function:def select(self, selector): ''' Query this document for objects that match the given selector. Args: selector (JSON-like query dictionary) : you can query by type or by name, e.g. ``{"type": HoverTool}``, ``{"name": "mycircle"}`` ...
[]
Please provide a description of the function:def select_one(self, selector): ''' Query this document for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found Args: selector (JSON...
[]
Please provide a description of the function:def to_json_string(self, indent=None): ''' Convert the document to a JSON string. Args: indent (int or None, optional) : number of spaces to indent, or None to suppress all newlines and indentation (default: None) Returns...
[]
Please provide a description of the function:def validate(self): ''' Perform integrity checks on the modes in this document. Returns: None ''' for r in self.roots: refs = r.references() check_integrity(refs)
[]
Please provide a description of the function:def _add_session_callback(self, callback_obj, callback, one_shot, originator): ''' Internal implementation for adding session callbacks. Args: callback_obj (SessionCallback) : A session callback object that wraps a callable and is...
[]
Please provide a description of the function:def _destructively_move(self, dest_doc): ''' Move all data in this doc to the dest_doc, leaving this doc empty. Args: dest_doc (Document) : The Bokeh document to populate with data from this one Returns: None ...
[]
Please provide a description of the function:def _notify_change(self, model, attr, old, new, hint=None, setter=None, callback_invoker=None): ''' Called by Model when it changes ''' # if name changes, update by-name index if attr == 'name': if old is not None: ...
[]
Please provide a description of the function:def _remove_session_callback(self, callback_obj, originator): ''' Remove a callback added earlier with ``add_periodic_callback``, ``add_timeout_callback``, or ``add_next_tick_callback``. Returns: None Raises: KeyError...
[]
Please provide a description of the function:def _check_callback(callback, fargs, what="Callback functions"): '''Bokeh-internal function to check callback signature''' sig = signature(callback) formatted_args = format_signature(sig) error_msg = what + " must have signature func(%s), got func%s" all...
[]
Please provide a description of the function: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 callback (callable) : a callback function to register Returns: ...
[]
Please provide a description of the function:def remove_on_change(self, attr, *callbacks): ''' Remove a callback from this object ''' if len(callbacks) == 0: raise ValueError("remove_on_change takes an attribute name and one or more callbacks, got only one parameter") _callbacks = se...
[]
Please provide a description of the function:def trigger(self, attr, old, new, hint=None, setter=None): ''' Trigger callbacks for ``attr`` on this object. Args: attr (str) : old (object) : new (object) : Returns: None ''' def inv...
[]
Please provide a description of the function:def download(progress=True): ''' Download larger data sets for various Bokeh examples. ''' data_dir = external_data_dir(create=True) print("Using data directory: %s" % data_dir) s3 = 'https://bokeh-sampledata.s3.amazonaws.com' files = [ (s3,...
[]
Please provide a description of the function:def main(argv): ''' Execute the Bokeh command. Args: argv (seq[str]) : a list of command line arguments to process Returns: None The first item in ``argv`` is typically "bokeh", and the second should be the name of one of the available ...
[]
Please provide a description of the function:def show(obj, browser=None, new="tab", notebook_handle=False, notebook_url="localhost:8888", **kw): ''' Immediately display a Bokeh object or application. :func:`show` may be called multiple times in a single Jupyter notebook cell to display multiple obj...
[]
Please provide a description of the function:def html_page_for_render_items(bundle, docs_json, render_items, title, template=None, template_variables={}): ''' Render an HTML page from a template and Bokeh render items. Args: bundle (tuple): a tuple containing (bokehjs, bokehcss) do...
[]
Please provide a description of the function:def extract_hosted_zip(data_url, save_dir, exclude_term=None): zip_name = os.path.join(save_dir, 'temp.zip') # get the zip file try: print('Downloading %r to %r' % (data_url, zip_name)) zip_name, hdrs = urllib.request.urlretrieve(url=data_u...
[ "Downloads, then extracts a zip file." ]
Please provide a description of the function:def extract_zip(zip_name, exclude_term=None): zip_dir = os.path.dirname(os.path.abspath(zip_name)) try: with zipfile.ZipFile(zip_name) as z: # write each zipped file out if it isn't a directory files = [zip_file for zip_file in...
[ "Extracts a zip file to its containing directory." ]
Please provide a description of the function:def value_as_datetime(self): ''' Convenience property to retrieve the value tuple as a tuple of datetime objects. ''' if self.value is None: return None v1, v2 = self.value if isinstance(v1, numbers.Number): ...
[]
Please provide a description of the function:def value_as_date(self): ''' Convenience property to retrieve the value tuple as a tuple of date objects. Added in version 1.1 ''' if self.value is None: return None v1, v2 = self.value if isinstance(v1, nu...
[]
Please provide a description of the function:def modify_document(self, doc): ''' Execute the configured ``main.py`` or ``main.ipynb`` to modify the document. This method will also search the app directory for any theme or template files, and automatically configure the document with the...
[]
Please provide a description of the function:def markers(): ''' Prints a list of valid marker types for scatter() Returns: None ''' print("Available markers: \n\n - " + "\n - ".join(list(MarkerType))) print() print("Shortcuts: \n\n" + "\n".join(" %r: %s" % item for item in _MARKER_SHORT...
[]
Please provide a description of the function:def scatter(self, *args, **kwargs): ''' Creates a scatter plot of the given x and y items. Args: x (str or seq[float]) : values or field names of center x coordinates y (str or seq[float]) : values or field names of center y coordina...
[]
Please provide a description of the function:def hexbin(self, x, y, size, orientation="pointytop", palette="Viridis256", line_color=None, fill_color=None, aspect_scale=1, **kwargs): ''' Perform a simple equal-weight hexagonal binning. A :class:`~bokeh.models._glyphs.HexTile` glyph will be added to disp...
[]
Please provide a description of the function:def harea_stack(self, stackers, **kw): ''' Generate multiple ``HArea`` renderers for levels stacked left to right. Args: stackers (seq[str]) : a list of data source field names to stack successively for ``x1`` and ``x2`` h...
[]
Please provide a description of the function:def hbar_stack(self, stackers, **kw): ''' Generate multiple ``HBar`` renderers for levels stacked left to right. Args: stackers (seq[str]) : a list of data source field names to stack successively for ``left`` and ``right`` bar co...
[]
Please provide a description of the function:def line_stack(self, x, y, **kw): ''' Generate multiple ``Line`` renderers for lines stacked vertically or horizontally. Args: x (seq[str]) : y (seq[str]) : Additionally, the ``name`` of the renderer will be set to ...
[]
Please provide a description of the function:def varea_stack(self, stackers, **kw): ''' Generate multiple ``VArea`` renderers for levels stacked bottom to top. Args: stackers (seq[str]) : a list of data source field names to stack successively for ``y1`` and ``y1`` v...
[]
Please provide a description of the function:def vbar_stack(self, stackers, **kw): ''' Generate multiple ``VBar`` renderers for levels stacked bottom to top. Args: stackers (seq[str]) : a list of data source field names to stack successively for ``left`` and ``right`...
[]
Please provide a description of the function:def graph(self, node_source, edge_source, layout_provider, **kwargs): ''' Creates a network graph using the given node, edge and layout provider. Args: node_source (:class:`~bokeh.models.sources.ColumnDataSource`) : a user-supplied data source ...
[]