Anaconda Enterprise: Documentation

# bokeh.core.has_props

Provide a base class for objects that can have declarative, typed, serializable properties.

Note

These classes form part of the very low-level machinery that implements the Bokeh model and property system. It is unlikely that any of these classes or their methods will be applicable to any standard usage or to anyone who is not directly developing on Bokeh’s own infrastructure.

class `bokeh.core.has_props.``HasProps`(**properties)

  Base class for all class types that have Bokeh properties.

  `apply_theme`(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 to save memory (so neither the caller nor the |HasProps| instance should modify it).

    Parameters: | property_values (dict) – theme values to use in place of defaults
    Returns: | None

  classmethod `dataspecs`()

    Collect the names of all `DataSpec` properties on this class.

    This method always traverses the class hierarchy and includes properties defined on any parent classes.

    Returns: | names of DataSpec properties
    Return type: | set[str]

  classmethod `dataspecs_with_props`()

    Collect a dict mapping the names of all `DataSpec` properties on this class to the associated properties.

    This method always traverses the class hierarchy and includes properties defined on any parent classes.

    Returns: | mapping of names and `DataSpec` properties
    Return type: | dict[str, DataSpec]

  `equals`(other)

    Structural equality of models.

    Parameters: | other (HasProps) – the other instance to compare to
    Returns: | True, if properties are structurally equal, otherwise False

  classmethod `lookup`(name)

    Find the `PropertyDescriptor` for a Bokeh property on a class, given the property name.

    Parameters: | name (str) – name of the property to search for
    Returns: | descriptor for property named `name`
    Return type: | PropertyDescriptor

  `pprint`(verbose=False, max_width=79, newline='\n')

    Print a “pretty” string representation of the object to stdout.

    Note

    This function only functions in the IPython shell or Jupyter Notebooks.

    Parameters: | Verbose (bool, optional) – This is a conventional argument for IPython representation printers but is unused by Bokeh. (default: False) max_width (int, optional) – Minimum width to start breaking lines when possible. (default: 79) newline (str, optional) – Character to use to separate each line (default: `\n`)
    Returns: | None
    Raises: | ValueError, if `IPython` cannot be imported

    Examples

        In [1]: from bokeh.models import Range1d

        In [1]: r = Range1d(start=10, end=20)

        In [2]: r.pprint()
        bokeh.models.ranges.Range1d(
            id='1576d21a-0c74-4214-8d8f-ad415e1e4ed4',
            bounds=None,
            callback=None,
            end=20,
            js_property_callbacks={},
            max_interval=None,
            min_interval=None,
            name=None,
            start=10,
            tags=[])

  `pretty`(verbose=False, max_width=79, newline='\n')

    Generate a “pretty” string representation of the object.

    Note

    This function only functions in the IPython shell or Jupyter Notebooks.

    Parameters: | Verbose (bool, optional) – This is a conventional argument for IPython representation printers but is unused by Bokeh. (default: False) max_width (int, optional) – Minimum width to start breaking lines when possible. (default: 79) newline (str, optional) – Character to use to separate each line (default: `\n`)
    Returns: | pretty object representation
    Return type: | str
    Raises: | ValueError, if `IPython` cannot be imported

  classmethod `properties`(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.

    Parameters: | with_bases (bool, optional) – Whether to include properties defined on parent classes in the results. (default: True)
    Returns: | property names
    Return type: | set[str]

  classmethod `properties_containers`()

    Collect the names of all container properties on this class.

    This method always traverses the class hierarchy and includes properties defined on any parent classes.

    Returns: | names of container properties
    Return type: | set[str]

  classmethod `properties_with_refs`()

    Collect the names of all properties on this class that also have references.

    This method always traverses the class hierarchy and includes properties defined on any parent classes.

    Returns: | names of properties that have references
    Return type: | set[str]

  `properties_with_values`(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 properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

    Parameters: | include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)
    Returns: | mapping from property names to their values
    Return type: | dict

  `query_properties_with_values`(query, include_defaults=True)

    Query the properties values of |HasProps| instances with a predicate.

    Parameters: | query (callable) – A callable that accepts property descriptors and returns True or False include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)
    Returns: | mapping of property names and values for matching properties
    Return type: | dict

  `set_from_json`(name, json, models=None, setter=None)

    Set a property value on this object from JSON.

    Parameters: | name – (str) : name of the attribute to set json – (JSON-value) : value to set to the attribute to models (dict or None, optional) – Mapping of model ids to models (default: None) This is needed in cases where the attributes to update also have values that have references. setter (ClientSession or ServerSession or None, optional) – This is used to prevent “boomerang” updates to Bokeh apps. In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.
    Returns: | None

  `themed_values`()

    Get any theme-provided overrides.

    Results are returned as a dict from property name to value, or `None` if no theme overrides any values for this instance.

    Returns: | dict or None

  `unapply_theme`()

    Remove any themed values and restore defaults.

    Returns: | None

  `update`(**kwargs)

    Updates the object’s properties from the given keyword arguments.

    Returns: | None

    Examples

    The following are equivalent:

        from bokeh.models import Range1d

        r = Range1d

        # set properties individually:
        r.start = 10
        r.end = 20

        # update properties together:
        r.update(start=10, end=20)

  `update_from_json`(json_attributes, models=None, setter=None)

    Updates the object’s properties from a JSON attributes dictionary.

    Parameters: | json_attributes – (JSON-dict) : attributes and values to update models (dict or None, optional) – Mapping of model ids to models (default: None) This is needed in cases where the attributes to update also have values that have references. setter (ClientSession or ServerSession or None, optional) – This is used to prevent “boomerang” updates to Bokeh apps. In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.
    Returns: | None

class `bokeh.core.has_props.``MetaHasProps`(class_name, bases, nmspc)

  Specialize the construction of |HasProps| classes.

  This class is a metaclass for |HasProps| that is responsible for creating and adding the |PropertyDescriptor| instances that delegate validation and serialization to |Property| attributes.

`bokeh.core.has_props.``abstract`(cls)

  A decorator to mark abstract base classes derived from |HasProps|.

`bokeh.core.has_props.``accumulate_dict_from_superclasses`(cls, propname)

  Traverse the class hierarchy and accumulate the special dicts `MetaHasProps` stores on classes:

  Parameters: | name (str) – name of the special attribute to collect. Typically meaningful values are: `__dataspecs__`, `__overridden_defaults__`

`bokeh.core.has_props.``accumulate_from_superclasses`(cls, propname)

  Traverse the class hierarchy and accumulate the special sets of names `MetaHasProps` stores on classes:

  Parameters: | name (str) – name of the special attribute to collect. Typically meaningful values are: `__container_props__`, `__properties__`, `__properties_with_refs__`