Anaconda Enterprise: Documentation

# bokeh.core.property.bases

Provide base classes for the Bokeh property system.

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.property.bases.``ContainerProperty`(default=None, help=None, serialized=True, readonly=False)

  A base class for Container-like type properties.

class `bokeh.core.property.bases.``ParameterizedProperty`(default=None, help=None, serialized=True, readonly=False)

  A base class for Properties that have type parameters, e.g. `List(String)`.

class `bokeh.core.property.bases.``PrimitiveProperty`(default=None, help=None, serialized=True, readonly=False)

  A base class for simple property types.

  Subclasses should define a class attribute `_underlying_type` that is a tuple of acceptable type values for the property.

  Example

  A trivial version of a `Float` property might look like:

      class Float(PrimitiveProperty):
          _underlying_type = (numbers.Real,)

class `bokeh.core.property.bases.``Property`(default=None, help=None, serialized=True, readonly=False)

  Base class for Bokeh property instances, which can be added to Bokeh Models.

  Parameters: | default (obj or None, optional) – A default value for attributes created from this property to have (default: None) help (str or None, optional) – A documentation string for this property. It will be automatically used by the bokeh_prop extension when generating Spinx documentation. (default: None) serialized (bool, optional) – Whether attributes created from this property should be included in serialization (default: True) readonly (bool, optional) – Whether attributes created from this property are read-only. (default: False)

  `accepts`(tp, converter)

    Declare that other types may be converted to this property type.

    Parameters: | tp (Property) – A type that may be converted automatically to this property type. converter (callable) – A function accepting `value` to perform conversion of the value to this property type.
    Returns: | self

  `asserts`(fn, msg_or_fn)

    Assert that prepared values satisfy given conditions.

    Assertions are intended in enforce conditions beyond simple value type validation. For instance, this method can be use to assert that the columns of a `ColumnDataSource` all collectively have the same length at all times.

    Parameters: | fn (callable) – A function accepting `(obj, value)` that returns True if the value passes the assertion, or False othwise msg_or_fn (str or callable) – A message to print in case the assertion fails, or a function accepting `(obj, name, value)` to call in in case the assertion fails.
    Returns: | self

  `from_json`(json, models=None)

    Convert from JSON-compatible values into a value for this property.

    JSON-compatible values are: list, dict, number, string, bool, None

  `is_valid`(value)

    Whether the value passes validation

    Parameters: | value (obj) – the value to validate against this property type
    Returns: | True if valid, False otherwise

  `make_descriptors`(base_name)

    Return a list of `BasicPropertyDescriptor` instances to install on a class, in order to delegate attribute access to this property.

    Parameters: | name (str) – the name of the property these descriptors are for
    Returns: | list[BasicPropertyDescriptor]

    The descriptors returned are collected by the `MetaHasProps` metaclass and added to `HasProps` subclasses during class creation.

  `matches`(new, old)

    Whether two parameters match values.

    If either `new` or `old` is a NumPy array or Pandas Series or Index, then the result of `np.array_equal` will determine if the values match.

    Otherwise, the result of standard Python equality will be returned.

    Returns: | True, if new and old match, False otherwise

  `serialize_value`(value)

    Change the value into a JSON serializable format.

  `themed_default`(cls, name, theme_overrides)

    The default, transformed by prepare_value() and the theme overrides.

  `transform`(value)

    Change the value into the canonical format for this property.

    Parameters: | value (obj) – the value to apply transformation to.
    Returns: | transformed value
    Return type: | obj

  `validate`(value)

    Determine whether we can set this property from this value.

    Validation happens before transform()

    Parameters: | value (obj) – the value to validate against this property type
    Returns: | None
    Raises: | ValueError if the value is not valid for this property type

  classmethod `wrap`(value)

    Some property types need to wrap their values in special containers, etc.

  `readonly`

    Whether this property is read-only.

    Read-only properties may only be modified by the client (i.e., by BokehJS in the browser).

  `serialized`

    Whether the property should be serialized when serializing an object.

    This would be False for a “virtual” or “convenience” property that duplicates information already available in other properties, for example.