holoviews.util.parser module#

The magics offered by the HoloViews IPython extension are powerful and support rich, compositional specifications. To avoid the the brittle, convoluted code that results from trying to support the syntax in pure Python, this file defines suitable parsers using pyparsing that are cleaner and easier to understand.

Pyparsing is required by matplotlib and will therefore be available if HoloViews is being used in conjunction with matplotlib.

class holoviews.util.parser.CompositorSpec[source]#

Bases: Parser

The syntax for defining a set of compositor is as follows:

[ mode op(spec) [settings] value ]+

The components are:

mode : Operation mode, either ‘data’ or ‘display’. group : Value identifier with capitalized initial letter. op : The name of the operation to apply. spec : Overlay specification of form (A * B) where A and B are

dotted path specifications.

settingsOptional list of keyword arguments to be used as

parameters to the operation (in square brackets).

classmethod parse(line, ns=None)[source]#

Parse compositor specifications, returning a list Compositors

class holoviews.util.parser.OptsSpec[source]#

Bases: Parser

An OptsSpec is a string specification that describes an OptionTree. It is a list of tree path specifications (using dotted syntax) separated by keyword lists for any of the style, plotting or normalization options. These keyword lists are denoted ‘plot(..)’, ‘style(…)’ and ‘norm(…)’ respectively. These three groups may be specified even more concisely using keyword lists delimited by square brackets, parentheses and braces respectively. All these sets are optional and may be supplied in any order.

For instance, the following string:

Image (interpolation=None) plot(show_title=False) Curve style(color=’r’)

Would specify an OptionTree where Image has “interpolation=None” for style and ‘show_title=False’ for plot options. The Curve has a style set such that color=’r’.

The parser is fairly forgiving; commas between keywords are optional and additional spaces are often allowed. The only restriction is that keywords must be immediately followed by the ‘=’ sign (no space).

classmethod apply_deprecations(path)[source]#

Convert any potentially deprecated paths and issue appropriate warnings

classmethod parse(line, ns=None)[source]#

Parse an options specification, returning a dictionary with path keys and {‘plot’:<options>, ‘style’:<options>} values.

classmethod parse_options(line, ns=None)[source]#

Similar to parse but returns a list of Options objects instead of the dictionary format.

classmethod process_normalization(parse_group)[source]#

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.

class holoviews.util.parser.Parser[source]#

Bases: object

Base class for magic line parsers, designed for forgiving parsing of keyword lists.

classmethod collect_tokens(parseresult, mode)[source]#

Collect the tokens from a (potentially) nested parse result.

classmethod todict(parseresult, mode='parens', ns=None)[source]#

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 namespace.

class holoviews.util.parser.ParserWarning(*, name)[source]#

Bases: Parameterized

Parameter Definitions