INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
Given an object a specific key and the normalization options this method will find the specified normalization options on the appropriate OptionTree group the elements according to the selected normalization option ( i. e. either per frame or over the whole animation ) and finally compute the dimension ranges in each g... | def compute_ranges(self, obj, key, ranges):
"""
Given an object, a specific key, and the normalization options,
this method will find the specified normalization options on
the appropriate OptionTree, group the elements according to
the selected normalization option (i.e. either ... |
Gets the normalization options for a LabelledData object by traversing the object to find elements and their ids. The id is then used to select the appropriate OptionsTree accumulating the normalization options into a dictionary. Returns a dictionary of normalization options for each element in the tree. | def _get_norm_opts(self, obj):
"""
Gets the normalization options for a LabelledData object by
traversing the object to find elements and their ids.
The id is then used to select the appropriate OptionsTree,
accumulating the normalization options into a dictionary.
Return... |
Traverses the supplied object getting all options in opts for the specified opt_type and specs. Also takes into account the plotting class defaults for plot options. If a keyfn is supplied the returned options will be grouped by the returned keys. | def _traverse_options(cls, obj, opt_type, opts, specs=None, keyfn=None, defaults=True):
"""
Traverses the supplied object getting all options in opts for
the specified opt_type and specs. Also takes into account the
plotting class defaults for plot options. If a keyfn is
supplied... |
Uses traversal to find the appropriate projection for a nested object. Respects projections set on Overlays before considering Element based settings before finally looking up the default projection on the plot type. If more than one non - None projection type is found an exception is raised. | def _get_projection(cls, obj):
"""
Uses traversal to find the appropriate projection
for a nested object. Respects projections set on
Overlays before considering Element based settings,
before finally looking up the default projection on
the plot type. If more than one no... |
Refreshes the plot by rerendering it and then pushing the updated data if the plot has an associated Comm. | def refresh(self, **kwargs):
"""
Refreshes the plot by rerendering it and then pushing
the updated data if the plot has an associated Comm.
"""
traverse_setter(self, '_force', True)
key = self.current_key if self.current_key else self.keys[0]
dim_streams = [stream... |
Triggers update to a plot on a refresh event | def _trigger_refresh(self, key):
"Triggers update to a plot on a refresh event"
# Update if not top-level, batched or an ElementPlot
if not self.top_level or isinstance(self, GenericElementPlot):
self.update(key) |
Pushes updated plot data via the Comm. | def push(self):
"""
Pushes updated plot data via the Comm.
"""
if self.comm is None:
raise Exception('Renderer does not have a comm.')
diff = self.renderer.diff(self)
self.comm.send(diff) |
Initializes comm and attaches streams. | def init_comm(self):
"""
Initializes comm and attaches streams.
"""
if self.comm:
return self.comm
comm = None
if self.dynamic or self.renderer.widget_mode == 'live':
comm = self.renderer.comm_manager.get_server_comm()
return comm |
Computes the z - order of element in the NdOverlay taking into account possible batching of elements. | def get_zorder(self, overlay, key, el):
"""
Computes the z-order of element in the NdOverlay
taking into account possible batching of elements.
"""
spec = util.get_overlay_spec(overlay, key, el)
return self.ordering.index(spec) |
Executes finalize hooks | def _execute_hooks(self, element):
"""
Executes finalize hooks
"""
if self.hooks and self.finalize_hooks:
self.param.warning(
"Supply either hooks or finalize_hooks not both, "
"using hooks and ignoring finalize_hooks.")
hooks = self.ho... |
Computes padding along the axes taking into account the plot aspect. | def get_padding(self, extents):
"""
Computes padding along the axes taking into account the plot aspect.
"""
(x0, y0, z0, x1, y1, z1) = extents
padding = 0 if self.overlaid else self.padding
xpad, ypad, zpad = get_axis_padding(padding)
if not self.overlaid and not... |
Gets the extents for the axes from the current Element. The globally computed ranges can optionally override the extents. | def get_extents(self, element, ranges, range_type='combined', xdim=None, ydim=None, zdim=None):
"""
Gets the extents for the axes from the current Element. The globally
computed ranges can optionally override the extents.
The extents are computed by combining the data ranges, extents
... |
Given a HoloMap compute the appropriate ( mapwise or framewise ) ranges in order to apply the Compositor collapse operations in display mode ( data collapse should already have happened ). | def _apply_compositor(self, holomap, ranges=None, keys=None, dimensions=None):
"""
Given a HoloMap compute the appropriate (mapwise or framewise)
ranges in order to apply the Compositor collapse operations in
display mode (data collapse should already have happened).
"""
... |
Handles the creation of new subplots when a DynamicMap returns a changing set of elements in an Overlay. | def _create_dynamic_subplots(self, key, items, ranges, **init_kwargs):
"""
Handles the creation of new subplots when a DynamicMap returns
a changing set of elements in an Overlay.
"""
length = self.style_grouping
group_fn = lambda x: (x.type.__name__, x.last.group, x.last... |
Updates existing subplots when the subplot has been assigned to plot an element that is not an exact match to the object it was initially assigned. | def _update_subplot(self, subplot, spec):
"""
Updates existing subplots when the subplot has been assigned
to plot an element that is not an exact match to the object
it was initially assigned.
"""
# See if the precise spec has already been assigned a cyclic
# in... |
Iterates over all subplots and collects the extents of each. | def _get_subplot_extents(self, overlay, ranges, range_type):
"""
Iterates over all subplots and collects the extents of each.
"""
if range_type == 'combined':
extents = {'extents': [], 'soft': [], 'hard': [], 'data': []}
else:
extents = {range_type: []}
... |
Creates a clone of the Layout with the nth - frame for each Element. | def _get_frame(self, key):
"""
Creates a clone of the Layout with the nth-frame for each
Element.
"""
cached = self.current_key is None
layout_frame = self.layout.clone(shared_data=False)
if key == self.current_key and not self._force:
return self.curr... |
Strip out any leading/ training commas from the token | def _strip_commas(cls, kw):
"Strip out any leading/training commas from the token"
kw = kw[:-1] if kw[-1]==',' else kw
return kw[1:] if kw[0]==',' else kw |
Collect the tokens from a ( potentially ) nested parse result. | def collect_tokens(cls, parseresult, mode):
"""
Collect the tokens from a (potentially) nested parse result.
"""
inner = '(%s)' if mode=='parens' else '[%s]'
if parseresult is None: return []
tokens = []
for token in parseresult.asList():
# If value is... |
Helper function to return dictionary given the parse results from a pyparsing. nestedExpr object ( containing keywords ). | def todict(cls, parseresult, mode='parens', ns={}):
"""
Helper function to return dictionary given the parse results
from a pyparsing.nestedExpr object (containing keywords).
The ns is a dynamic namespace (typically the IPython Notebook
namespace) used to update the class-level ... |
Given a normalization parse group ( i. e. the contents of the braces ) validate the option list and compute the appropriate integer value for the normalization plotting option. | def process_normalization(cls, parse_group):
"""
Given a normalization parse group (i.e. the contents of the
braces), validate the option list and compute the appropriate
integer value for the normalization plotting option.
"""
if ('norm_options' not in parse_group): retu... |
Given a parsed options specification as a list of groups combine groups without options with the first subsequent group which has options. A line of the form A B C [ opts ] D E [ opts_2 ] results in [ ( { A B C } [ opts ] ) ( { D E } [ opts_2 ] ) ] | def _group_paths_without_options(cls, line_parse_result):
"""
Given a parsed options specification as a list of groups, combine
groups without options with the first subsequent group which has
options.
A line of the form
'A B C [opts] D E [opts_2]'
results in
... |
Convert any potentially deprecated paths and issue appropriate warnings | def apply_deprecations(cls, path):
"Convert any potentially deprecated paths and issue appropriate warnings"
split = path.split('.')
msg = 'Element {old} deprecated. Use {new} instead.'
for old, new in cls.deprecations:
if split[0] == old:
parsewarning.warning... |
Parse an options specification returning a dictionary with path keys and { plot: <options > style: <options > } values. | def parse(cls, line, ns={}):
"""
Parse an options specification, returning a dictionary with
path keys and {'plot':<options>, 'style':<options>} values.
"""
parses = [p for p in cls.opts_spec.scanString(line)]
if len(parses) != 1:
raise SyntaxError("Invalid s... |
Similar to parse but returns a list of Options objects instead of the dictionary format. | def parse_options(cls, line, ns={}):
"""
Similar to parse but returns a list of Options objects instead
of the dictionary format.
"""
parsed = cls.parse(line, ns=ns)
options_list = []
for spec in sorted(parsed.keys()):
options = parsed[spec]
... |
Parse compositor specifications returning a list Compositors | def parse(cls, line, ns={}):
"""
Parse compositor specifications, returning a list Compositors
"""
definitions = []
parses = [p for p in cls.compositor_spec.scanString(line)]
if len(parses) != 1:
raise SyntaxError("Invalid specification syntax.")
else... |
Method to get the appropriate normalization range dictionary given a key and element. | def get_ranges(self, element, key):
"""
Method to get the appropriate normalization range dictionary
given a key and element.
"""
keys = self.p['keys']
ranges = self.p['ranges']
if ranges == {}:
return {d.name: element.range(d.name, self.data_range)
... |
Applies a aggregate function to all ViewableElements. | def aggregate(self, dimensions=None, function=None, spreadfn=None, **kwargs):
"""Applies a aggregate function to all ViewableElements.
See :py:meth:`Dimensioned.opts` and :py:meth:`Apply.__call__`
for more information.
"""
kwargs['_method_args'] = (dimensions, function, spreadfn... |
Applies a reduce function to all ViewableElement objects. | def reduce(self, dimensions=[], function=None, spreadfn=None, **kwargs):
"""Applies a reduce function to all ViewableElement objects.
See :py:meth:`Dimensioned.opts` and :py:meth:`Apply.__call__`
for more information.
"""
kwargs['_method_args'] = (dimensions, function, spreadfn)... |
Replaces dimensions in list with dictionary of overrides. | def replace_dimensions(cls, dimensions, overrides):
"""Replaces dimensions in list with dictionary of overrides.
Args:
dimensions: List of dimensions
overrides: Dictionary of dimension specs indexed by name
Returns:
list: List of dimensions with replacements... |
Returns a filtered version of the DynamicMap cache leaving only keys consistently with the newly specified values | def _filter_cache(self, dmap, kdims):
"""
Returns a filtered version of the DynamicMap cache leaving only
keys consistently with the newly specified values
"""
filtered = []
for key, value in dmap.data.items():
if not any(kd.values and v not in kd.values for k... |
Returns the corresponding Options object. | def get(self, group=None, backend=None):
"""Returns the corresponding Options object.
Args:
group: The options group. Flattens across groups if None.
backend: Current backend if None otherwise chosen backend.
Returns:
Options object associated with the objec... |
Prints a repr of the object including any applied options. | def info(self, show_defaults=False):
"""Prints a repr of the object including any applied options.
Args:
show_defaults: Whether to include default options
"""
pprinter = PrettyPrinter(show_options=True, show_defaults=show_defaults)
print(pprinter.pprint(self._obj)) |
Given a list of Dataset objects cast them to the specified datatype ( by default the format matching the current interface ) with the given cast_type ( if specified ). | def cast(cls, datasets, datatype=None, cast_type=None):
"""
Given a list of Dataset objects, cast them to the specified
datatype (by default the format matching the current interface)
with the given cast_type (if specified).
"""
datatype = datatype or cls.datatype
... |
Given a Dataset object and a dictionary with dimension keys and selection keys ( i. e tuple ranges slices sets lists or literals ) return a boolean mask over the rows in the Dataset object that have been selected. | def select_mask(cls, dataset, selection):
"""
Given a Dataset object and a dictionary with dimension keys and
selection keys (i.e tuple ranges, slices, sets, lists or literals)
return a boolean mask over the rows in the Dataset object that
have been selected.
"""
... |
Given a Dataset object and selection to be applied returns boolean to indicate whether a scalar value has been indexed. | def indexed(cls, dataset, selection):
"""
Given a Dataset object and selection to be applied returns
boolean to indicate whether a scalar value has been indexed.
"""
selected = list(selection.keys())
all_scalar = all((not isinstance(sel, (tuple, slice, set, list))
... |
Utility function to concatenate an NdMapping of Dataset objects. | def concatenate(cls, datasets, datatype=None, new_type=None):
"""
Utility function to concatenate an NdMapping of Dataset objects.
"""
from . import Dataset, default_datatype
new_type = new_type or Dataset
if isinstance(datasets, NdMapping):
dimensions = datas... |
Make adjustments to plot extents by computing stacked bar heights adjusting the bar baseline and forcing the x - axis to be categorical. | def get_extents(self, element, ranges, range_type='combined'):
"""
Make adjustments to plot extents by computing
stacked bar heights, adjusting the bar baseline
and forcing the x-axis to be categorical.
"""
if self.batched:
overlay = self.current_frame
... |
Given a dataset object and data in the appropriate format for the interface return a simple scalar. | def unpack_scalar(cls, dataset, data):
"""
Given a dataset object and data in the appropriate format for
the interface, return a simple scalar.
"""
if (len(data.data_vars) == 1 and
len(data[dataset.vdims[0].name].shape) == 0):
return data[dataset.vdims[0].... |
Applies optional checks to individual data elements before they are inserted ensuring that they are of a certain type. Subclassed may implement further element restrictions. | def _item_check(self, dim_vals, data):
"""
Applies optional checks to individual data elements before
they are inserted ensuring that they are of a certain
type. Subclassed may implement further element restrictions.
"""
if not self._check_items:
return
... |
Adds item to the data applying dimension types and ensuring key conforms to Dimension type and values. | def _add_item(self, dim_vals, data, sort=True, update=True):
"""
Adds item to the data, applying dimension types and ensuring
key conforms to Dimension type and values.
"""
sort = sort and self.sort
if not isinstance(dim_vals, tuple):
dim_vals = (dim_vals,)
... |
If a type is specified by the corresponding key dimension this method applies the type to the supplied key. | def _apply_key_type(self, keys):
"""
If a type is specified by the corresponding key dimension,
this method applies the type to the supplied key.
"""
typed_key = ()
for dim, key in zip(self.kdims, keys):
key_type = dim.type
if key_type is None:
... |
Partitions key into key and deep dimension groups. If only key indices are supplied the data is indexed with an empty tuple. Keys with indices than there are dimensions will be padded. | def _split_index(self, key):
"""
Partitions key into key and deep dimension groups. If only key
indices are supplied, the data is indexed with an empty tuple.
Keys with indices than there are dimensions will be padded.
"""
if not isinstance(key, tuple):
key = ... |
Returns slice of data element if the item is deep indexable. Warns if attempting to slice an object that has not been declared deep indexable. | def _dataslice(self, data, indices):
"""
Returns slice of data element if the item is deep
indexable. Warns if attempting to slice an object that has not
been declared deep indexable.
"""
if self._deep_indexable and isinstance(data, Dimensioned) and indices:
r... |
Clones the object overriding data and parameters. | def clone(self, data=None, shared_data=True, *args, **overrides):
"""Clones the object, overriding data and parameters.
Args:
data: New data replacing the existing data
shared_data (bool, optional): Whether to use existing data
new_type (optional): Type to cast objec... |
Groups object by one or more dimensions | def groupby(self, dimensions, container_type=None, group_type=None, **kwargs):
"""Groups object by one or more dimensions
Applies groupby operation over the specified dimensions
returning an object of type container_type (expected to be
dictionary-like) containing the groups.
A... |
Adds a dimension and its values to the object | def add_dimension(self, dimension, dim_pos, dim_val, vdim=False, **kwargs):
"""Adds a dimension and its values to the object
Requires the dimension name or object, the desired position in
the key dimensions and a key value scalar or sequence of the
same length as the existing keys.
... |
Drops dimension ( s ) from keys | def drop_dimension(self, dimensions):
"""Drops dimension(s) from keys
Args:
dimensions: Dimension(s) to drop
Returns:
Clone of object with with dropped dimension(s)
"""
dimensions = [dimensions] if np.isscalar(dimensions) else dimensions
dims = [... |
Return the values along the requested dimension. | def dimension_values(self, dimension, expanded=True, flat=True):
"""Return the values along the requested dimension.
Args:
dimension: The dimension to return values for
expanded (bool, optional): Whether to expand values
Whether to return the expanded values, beh... |
Reindexes object dropping static or supplied kdims | def reindex(self, kdims=[], force=False):
"""Reindexes object dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key
dimensions. By default drops all non-varying key dimensions.
Reducing the number of key dimensions will discard information
... |
Prints information about the Dimensioned object including the number and type of objects contained within it and information about its dimensions. | def info(self):
"""
Prints information about the Dimensioned object, including the
number and type of objects contained within it and information
about its dimensions.
"""
if (len(self.values()) > 0):
info_str = self.__class__.__name__ +\
... |
Merges other item with this object | def update(self, other):
"""Merges other item with this object
Args:
other: Object containing items to merge into this object
Must be a dictionary or NdMapping type
"""
if isinstance(other, NdMapping):
dims = [d for d in other.kdims if d not in se... |
Returns the keys of all the elements. | def keys(self):
" Returns the keys of all the elements."
if self.ndims == 1:
return [k[0] for k in self.data.keys()]
else:
return list(self.data.keys()) |
Returns all elements as a list in ( key value ) format. | def items(self):
"Returns all elements as a list in (key,value) format."
return list(zip(list(self.keys()), list(self.values()))) |
Standard pop semantics for all mapping types | def pop(self, key, default=None):
"Standard pop semantics for all mapping types"
if not isinstance(key, tuple): key = (key,)
return self.data.pop(key, default) |
Deprecated method to convert an MultiDimensionalMapping of Elements to a Table. | def table(self, datatype=None, **kwargs):
"""
Deprecated method to convert an MultiDimensionalMapping of
Elements to a Table.
"""
if config.future_deprecations:
self.param.warning("The table method is deprecated and should no "
"longer b... |
Deprecated method to convert a MultiDimensionalMapping to a pandas DataFrame. Conversion to a dataframe now only supported by specific subclasses such as UniformNdMapping types. | def dframe(self):
"""
Deprecated method to convert a MultiDimensionalMapping to
a pandas DataFrame. Conversion to a dataframe now only
supported by specific subclasses such as UniformNdMapping
types.
"""
self.param.warning("The MultiDimensionalMapping.dframe metho... |
Expands slices containing steps into a list. | def _expand_slice(self, indices):
"""
Expands slices containing steps into a list.
"""
keys = list(self.data.keys())
expanded = []
for idx, ind in enumerate(indices):
if isinstance(ind, slice) and ind.step is not None:
dim_ind = slice(ind.start... |
Generates filter conditions used for slicing the data structure. | def _generate_conditions(self, map_slice):
"""
Generates filter conditions used for slicing the data structure.
"""
conditions = []
for dim, dim_slice in zip(self.kdims, map_slice):
if isinstance(dim_slice, slice):
start, stop = dim_slice.start, dim_sl... |
Clones the object overriding data and parameters. | def clone(self, data=None, shared_data=True, new_type=None, link=True,
*args, **overrides):
"""Clones the object, overriding data and parameters.
Args:
data: New data replacing the existing data
shared_data (bool, optional): Whether to use existing data
... |
Convert dimension values to DataFrame. | def dframe(self, dimensions=None, multi_index=False):
"""Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension,
either completely flat or indexed by key dimensions.
Args:
dimensions: Dimensions to return as columns
mul... |
Group inherited from items | def group(self):
"Group inherited from items"
if self._group:
return self._group
group = get_ndmapping_label(self, 'group') if len(self) else None
if group is None:
return type(self).__name__
return group |
Label inherited from items | def label(self):
"Label inherited from items"
if self._label:
return self._label
else:
if len(self):
label = get_ndmapping_label(self, 'label')
return '' if label is None else label
else:
return '' |
The type of elements stored in the mapping. | def type(self):
"The type of elements stored in the mapping."
if self._type is None and len(self):
self._type = self.values()[0].__class__
return self._type |
Snaps coordinate ( s ) to closest coordinate in Dataset | def closest(self, coords=[], **kwargs):
"""Snaps coordinate(s) to closest coordinate in Dataset
Args:
coords: List of coordinates expressed as tuples
**kwargs: Coordinates defined as keyword pairs
Returns:
List of tuples of the snapped coordinates
R... |
Sorts the data by the values along the supplied dimensions. | def sort(self, by=None, reverse=False):
"""
Sorts the data by the values along the supplied dimensions.
Args:
by: Dimension(s) to sort by
reverse (bool, optional): Reverse sort order
Returns:
Sorted Dataset
"""
if by is None:
... |
Return the lower and upper bounds of values along dimension. | def range(self, dim, data_range=True, dimension_range=True):
"""Return the lower and upper bounds of values along dimension.
Args:
dimension: The dimension to compute the range on.
data_range (bool): Compute range from data values
dimension_range (bool): Include Dime... |
Adds a dimension and its values to the Dataset | def add_dimension(self, dimension, dim_pos, dim_val, vdim=False, **kwargs):
"""Adds a dimension and its values to the Dataset
Requires the dimension name or object, the desired position in
the key dimensions and a key value scalar or array of values,
matching the length o shape of the D... |
Applies selection by dimension name | def select(self, selection_specs=None, **selection):
"""Applies selection by dimension name
Applies a selection along the dimensions of the object using
keyword arguments. The selection may be narrowed to certain
objects using selection_specs. For container objects the
selection... |
Reindexes Dataset dropping static or supplied kdims | def reindex(self, kdims=None, vdims=None):
"""Reindexes Dataset dropping static or supplied kdims
Creates a new object with a reordered or reduced set of key
dimensions. By default drops all non-varying key dimensions.x
Args:
kdims (optional): New list of key dimensionsx
... |
Samples values at supplied coordinates. | def sample(self, samples=[], bounds=None, closest=True, **kwargs):
"""Samples values at supplied coordinates.
Allows sampling of element with a list of coordinates matching
the key dimensions, returning a new object containing just the
selected samples. Supports multiple signatures:
... |
Applies reduction along the specified dimension ( s ). | def reduce(self, dimensions=[], function=None, spreadfn=None, **reductions):
"""Applies reduction along the specified dimension(s).
Allows reducing the values along one or more key dimension
with the supplied function. Supports two signatures:
Reducing with a list of dimensions, e.g.:
... |
Aggregates data on the supplied dimensions. | def aggregate(self, dimensions=None, function=None, spreadfn=None, **kwargs):
"""Aggregates data on the supplied dimensions.
Aggregates over the supplied key dimensions with the defined
function.
Args:
dimensions: Dimension(s) to aggregate on
Default to all ... |
Groups object by one or more dimensions | def groupby(self, dimensions=[], container_type=HoloMap, group_type=None,
dynamic=False, **kwargs):
"""Groups object by one or more dimensions
Applies groupby operation over the specified dimensions
returning an object of type container_type (expected to be
dictionary-li... |
Return the values along the requested dimension. | def dimension_values(self, dimension, expanded=True, flat=True):
"""Return the values along the requested dimension.
Args:
dimension: The dimension to return values for
expanded (bool, optional): Whether to expand values
Whether to return the expanded values, beh... |
Get the type of the requested dimension. | def get_dimension_type(self, dim):
"""Get the type of the requested dimension.
Type is determined by Dimension.type attribute or common
type of the dimension values, otherwise None.
Args:
dimension: Dimension to look up by name or by index
Returns:
Decl... |
Convert dimension values to DataFrame. | def dframe(self, dimensions=None, multi_index=False):
"""Convert dimension values to DataFrame.
Returns a pandas dataframe of columns along each dimension,
either completely flat or indexed by key dimensions.
Args:
dimensions: Dimensions to return as columns
mul... |
Convert dimension values to a dictionary. | def columns(self, dimensions=None):
"""Convert dimension values to a dictionary.
Returns a dictionary of column arrays along each dimension
of the element.
Args:
dimensions: Dimensions to return as columns
Returns:
Dictionary of arrays for each dimensio... |
Clones the object overriding data and parameters. | def clone(self, data=None, shared_data=True, new_type=None, *args, **overrides):
"""Clones the object, overriding data and parameters.
Args:
data: New data replacing the existing data
shared_data (bool, optional): Whether to use existing data
new_type (optional): Typ... |
Context manager that temporarily overrides the pyplot rcParams. | def _rc_context(rcparams):
"""
Context manager that temporarily overrides the pyplot rcParams.
"""
deprecated = ['text.latex.unicode', 'examples.directory']
old_rcparams = {k: mpl.rcParams[k] for k in mpl.rcParams.keys()
if mpl_version < '3.0' or k not in deprecated}
mpl.rcPa... |
Decorator for MPLPlot methods applying the matplotlib rc params in the plots fig_rcparams while when method is called. | def mpl_rc_context(f):
"""
Decorator for MPLPlot methods applying the matplotlib rc params
in the plots fig_rcparams while when method is called.
"""
def wrapper(self, *args, **kwargs):
with _rc_context(self.fig_rcparams):
return f(self, *args, **kwargs)
return wrapper |
Return an axis which may need to be initialized from a new figure. | def _init_axis(self, fig, axis):
"""
Return an axis which may need to be initialized from
a new figure.
"""
if not fig and self._create_fig:
fig = plt.figure()
l, b, r, t = self.fig_bounds
inches = self.fig_inches
fig.subplots_adjus... |
General method to finalize the axis and plot. | def _finalize_axis(self, key):
"""
General method to finalize the axis and plot.
"""
if 'title' in self.handles:
self.handles['title'].set_visible(self.show_title)
self.drawn = True
if self.subplot:
return self.handles['axis']
else:
... |
Method to return a matplotlib animation. The start and stop frames may be specified as well as the fps. | def anim(self, start=0, stop=None, fps=30):
"""
Method to return a matplotlib animation. The start and stop
frames may be specified as well as the fps.
"""
figure = self.state or self.initialize_plot()
anim = animation.FuncAnimation(figure, self.update_frame,
... |
Plot all the views contained in the AdjointLayout Object using axes appropriate to the layout configuration. All the axes are supplied by LayoutPlot - the purpose of the call is to invoke subplots with correct options and styles and hide any empty axes as necessary. | def initialize_plot(self, ranges=None):
"""
Plot all the views contained in the AdjointLayout Object using axes
appropriate to the layout configuration. All the axes are
supplied by LayoutPlot - the purpose of the call is to
invoke subplots with correct options and styles and hid... |
Make adjustments to the positions of subplots ( if available ) relative to the main plot axes as required. | def adjust_positions(self, redraw=True):
"""
Make adjustments to the positions of subplots (if available)
relative to the main plot axes as required.
This method is called by LayoutPlot after an initial pass
used to position all the Layouts together. This method allows
L... |
Computes the tallest and widest cell for each row and column by examining the Layouts in the GridSpace. The GridSpec is then instantiated and the LayoutPlots are configured with the appropriate embedded layout_types. The first element of the returned tuple is a dictionary of all the LayoutPlots indexed by row and colum... | def _compute_gridspec(self, layout):
"""
Computes the tallest and widest cell for each row and column
by examining the Layouts in the GridSpace. The GridSpec is then
instantiated and the LayoutPlots are configured with the
appropriate embedded layout_types. The first element of t... |
Situate the current AdjointLayoutPlot in a LayoutPlot. The LayoutPlot specifies a layout_type into which the AdjointLayoutPlot must be embedded. This enclosing layout is guaranteed to have enough cells to display all the views. | def grid_situate(self, current_idx, layout_type, subgrid_width):
"""
Situate the current AdjointLayoutPlot in a LayoutPlot. The
LayoutPlot specifies a layout_type into which the AdjointLayoutPlot
must be embedded. This enclosing layout is guaranteed to have
enough cells to displa... |
Plot all the views contained in the AdjointLayout Object using axes appropriate to the layout configuration. All the axes are supplied by LayoutPlot - the purpose of the call is to invoke subplots with correct options and styles and hide any empty axes as necessary. | def _create_subplots(self, layout, positions, layout_dimensions, ranges, axes={}, num=1, create=True):
"""
Plot all the views contained in the AdjointLayout Object using axes
appropriate to the layout configuration. All the axes are
supplied by LayoutPlot - the purpose of the call is to
... |
Temporarily declares the streams as being in a triggered state. Needed by DynamicMap to determine whether to memoize on a Callable i. e. if a stream has memoization disabled and is in triggered state Callable should disable lookup in the memoization cache. This is done by the dynamicmap_memoization context manager. | def triggering_streams(streams):
"""
Temporarily declares the streams as being in a triggered state.
Needed by DynamicMap to determine whether to memoize on a Callable,
i.e. if a stream has memoization disabled and is in triggered state
Callable should disable lookup in the memoization cache. This i... |
Utility to quickly and easily declare Stream classes. Designed for interactive use such as notebooks and shouldn t replace parameterized class definitions in source code that is imported. | def define(cls, name, **kwargs):
"""
Utility to quickly and easily declare Stream classes. Designed
for interactive use such as notebooks and shouldn't replace
parameterized class definitions in source code that is imported.
Takes a stream class name and a set of keywords where ... |
Given a list of streams collect all the stream parameters into a dictionary and pass it to the union set of subscribers. | def trigger(cls, streams):
"""
Given a list of streams, collect all the stream parameters into
a dictionary and pass it to the union set of subscribers.
Passing multiple streams at once to trigger can be useful when a
subscriber may be set multiple times across streams but only
... |
Processes a list of streams promoting Parameterized objects and methods to Param based streams. | def _process_streams(cls, streams):
"""
Processes a list of streams promoting Parameterized objects and
methods to Param based streams.
"""
parameterizeds = defaultdict(set)
valid, invalid = [], []
for s in streams:
if isinstance(s, Stream):
... |
Property returning the subscriber list | def subscribers(self):
"""Property returning the subscriber list"""
return [s for p, s in sorted(self._subscribers, key=lambda x: x[0])] |
Clear all subscribers registered to this stream. | def clear(self, policy='all'):
"""
Clear all subscribers registered to this stream.
The default policy of 'all' clears all subscribers. If policy is
set to 'user', only subscribers defined by the user are cleared
(precedence between zero and one). A policy of 'internal' clears
... |
Resets stream parameters to their defaults. | def reset(self):
"""
Resets stream parameters to their defaults.
"""
with util.disable_constant(self):
for k, p in self.params().items():
if k != 'name':
setattr(self, k, p.default) |
Register a callable subscriber to this stream which will be invoked either when event is called or when this stream is passed to the trigger classmethod. | def add_subscriber(self, subscriber, precedence=0):
"""
Register a callable subscriber to this stream which will be
invoked either when event is called or when this stream is
passed to the trigger classmethod.
Precedence allows the subscriber ordering to be
controlled. U... |
The rename method allows stream parameters to be allocated to new names to avoid clashes with other stream parameters of the same name. Returns a new clone of the stream instance with the specified name mapping. | def rename(self, **mapping):
"""
The rename method allows stream parameters to be allocated to
new names to avoid clashes with other stream parameters of the
same name. Returns a new clone of the stream instance with the
specified name mapping.
"""
params = {k: v ... |
Sets the stream parameters which are expected to be declared constant. | def _set_stream_parameters(self, **kwargs):
"""
Sets the stream parameters which are expected to be declared
constant.
"""
with util.disable_constant(self):
self.param.set_param(**kwargs) |
The update method updates the stream parameters ( without any renaming applied ) in response to some event. If the stream has a custom transform method this is applied to transform the parameter values accordingly. | def update(self, **kwargs):
"""
The update method updates the stream parameters (without any
renaming applied) in response to some event. If the stream has a
custom transform method, this is applied to transform the
parameter values accordingly.
To update and trigger, us... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.