The validation module provides the capability to perform integrity checks on an entire collection of Bokeh models.
To create a Bokeh visualization, the central task is to assemble a collection model objects from bokeh.models into a graph that represents the scene that should be created in the client. It is possible to to this âby handâ, using the model objects directly. However, to make this process easier, Bokeh provides higher level interfaces such as bokeh.plotting for users.
These interfaces automate common âassemblyâ steps, to ensure a Bokeh object graph is created in a consistent, predictable way. However, regardless of what interface is used, it is possible to put Bokeh models together in ways that are incomplete, or that do not make sense in some way.
To assist with diagnosing potential problems, Bokeh performs a validation step when outputting a visualization for display. This module contains error and warning codes as well as helper functions for defining validation checks.
One use case for warnings is to loudly point users in the right direction when they accidentally do something that they probably didnât mean to do - this is the case for EMPTY_LAYOUT for instance. Since warnings donât necessarily indicate misuse, they are configurable. To silence a warning, use the silence function provided.
>>> from bokeh.core.validation import silence >>> from bokeh.core.validation.warnings import EMPTY_LAYOUT >>> silence(EMPTY_LAYOUT, True)Error Codes#
These define the standard error codes and messages for Bokeh validation checks.
A glyph has a property set to a field name that does not correspond to any column in the GlyphRenderer
âs data source.
A GlyphRenderer
has no glyph configured.
A GlyphRenderer
has no data source configured.
A Plot
is missing one or more required default ranges (will result in blank plot).
Google Maps API now requires an API key for all use. See https://developers.google.com/maps/documentation/javascript/get-api-key for more information on how to obtain your own, to use for the api_key
property of your Google Map plot .
All data_sources on LegendItem.renderers
must match when LegendItem.label is type field.
MercatorTicker
and MercatorTickFormatter``models must have their ``dimension
property set to 'lat'
or 'lon'
.
A Scale
on is missing one or more required default scales (will result in blank plot).
A Scale
type is incompatible with one or more ranges on the same plot dimension (will result in blank plot).
The GraphSource
is incorrectly configured.
Map plots can only support Range1d
types, not data ranges.
The PointDrawTool
renderers may only reference XYGlyph
models.
The BoxEditTool
renderers may only reference Rect
glyph models.
The PolyDrawTool
renderers may only reference MultiLine
and Patches
glyph models.
The PolyEditTool
renderers may only reference MultiLine
and Patches
glyph models.
The PolyEditTool
vertex_renderer may only reference XYGlyph
models.
The RangeTool
must have at least one of x_range
or y_range
configured
FactorRange
must specify a unique list of categorical factors for an axis.
An extra range name is configured with a name that does not correspond to any range.
noUiSlider
most have a nonequal start and end.
Expected min_width <= width <= max_width
Expected min_height <= height <= max_height
CDSView
filters are not compatible with glyphs with connected topology such as Line or Patch.
The LineEditTool
renderers may only reference MultiLine
and Line
glyph models.
The LineEditTool
intersection_enderer may only reference LineGlyph
models.
The same model canât be used multiple times in a layout.
Indicates that a custom error check has failed.
These define the standard warning codes and messages for Bokeh validation checks.
A Plot
object has no renderers configured (will result in a blank plot).
A layout model has no children (will result in a blank layout).
Each component can be rendered in only one place, canât be both a root and in a layout.
Indicates that a custom warning check has failed.
These helper functions can be used to perform integrity checks on collections of Bokeh models, or mark methods on Models as warning or error checks.
Collect all warnings associated with a collection of Bokeh models.
models (seq[Model]) â a collection of Models to test
A collection of all warning and error messages
ValidationIssues
This function will return an object containing all errors and/or warning conditions that are detected. For example, layouts without any children will add a warning to the collection:
>>> empty_row = Row() >>> check_integrity([empty_row]) ValidationIssues( warning=[ ValidationIssue( code=1002, name="EMPTY_LAYOUT", text="Layout has no children", extra="Row(id='1001', ...)", ), ], )
Silence a particular warning on all Bokeh models.
A set containing the all silenced warnings
This function adds or removes warnings from a set of silencers which is referred to when running check_integrity
. If a warning is added to the silencers - then it will never be raised.
>>> from bokeh.core.validation.warnings import EMPTY_LAYOUT >>> bokeh.core.validation.silence(EMPTY_LAYOUT, True) {1002}
To turn a warning back on use the same method but with the silence argument set to false
>>> bokeh.core.validation.silence(EMPTY_LAYOUT, False) set()
Decorator to mark a validator method for a Bokeh error condition
code_or_name (int, str or Issue) â a code from bokeh.validation.errors
or a string label for a custom check
decorator for Bokeh model methods
callable
The function that is decorated must have a name that starts with _check
, and return a string message in case a bad condition is detected, and None
if no bad condition is detected.
Examples:
The first example uses a numeric code for a standard error provided in bokeh.validation.errors
. This usage is primarily of interest to Bokeh core developers.
from bokeh.validation.errors import REQUIRED_RANGES @error(REQUIRED_RANGES) def _check_no_glyph_renderers(self): if bad_condition: return "message"
The second example shows how a custom warning check can be implemented by passing an arbitrary string label to the decorator. This usage is primarily of interest to anyone extending Bokeh with their own custom models.
@error("MY_CUSTOM_WARNING") def _check_my_custom_warning(self): if bad_condition: return "message"
Decorator to mark a validator method for a Bokeh error condition
code_or_name (int, str or Issue) â a code from bokeh.validation.errors
or a string label for a custom check
decorator for Bokeh model methods
callable
The function that is decorated should have a name that starts with _check
, and return a string message in case a bad condition is detected, and None
if no bad condition is detected.
Examples:
The first example uses a numeric code for a standard warning provided in bokeh.validation.warnings
. This usage is primarily of interest to Bokeh core developers.
from bokeh.validation.warnings import MISSING_RENDERERS @warning(MISSING_RENDERERS) def _check_no_glyph_renderers(self): if bad_condition: return "message"
The second example shows how a custom warning check can be implemented by passing an arbitrary string label to the decorator. This usage is primarily of interest to anyone extending Bokeh with their own custom models.
@warning("MY_CUSTOM_WARNING") def _check_my_custom_warning(self): if bad_condition: return "message"
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4