results

Module Contents

Classes

OptDir

StrEnum is a Python enum.Enum that inherits from str. The default

ResultVar

A class to represent result variables and the desired optimisation direction

ResultVec

A class to represent fixed size vector result variable

ResultHmap

A class to represent a holomap return type

PathResult

Parameter that can be set to a string specifying the path of a file.

ResultVideo

Parameter that can be set to a string specifying the path of a file.

ResultImage

Parameter that can be set to a string specifying the path of a file.

ResultString

A String Parameter, with a default value and optional regular expression (regex) matching.

ResultContainer

An attribute descriptor for declaring parameters.

ResultReference

Use this class to save arbitrary objects that are not picklable or native to panel. You can pass a container callback that takes the object and returns a panel pane to be displayed

ResultVolume

An attribute descriptor for declaring parameters.

Functions

curve(→ holoviews.Curve)

Attributes

PANEL_TYPES

class results.OptDir

Bases: strenum.StrEnum

StrEnum is a Python enum.Enum that inherits from str. The default auto() behavior uses the member name as its value.

Example usage:

class Example(StrEnum):
    UPPER_CASE = auto()
    lower_case = auto()
    MixedCase = auto()

assert Example.UPPER_CASE == "UPPER_CASE"
assert Example.lower_case == "lower_case"
assert Example.MixedCase == "MixedCase"
minimize
maximize
none
class results.ResultVar(units='ul', direction: OptDir = OptDir.minimize, **params)

Bases: param.Number

A class to represent result variables and the desired optimisation direction

__slots__ = ['units', 'direction']
as_dim() holoviews.Dimension
hash_persistent() str

A hash function that avoids the PYTHONHASHSEED ‘feature’ which returns a different hash value each time the program is run

class results.ResultVec(size, units='ul', direction: OptDir = OptDir.minimize, **params)

Bases: param.List

A class to represent fixed size vector result variable

__slots__ = ['units', 'direction', 'size']
hash_persistent() str

A hash function that avoids the PYTHONHASHSEED ‘feature’ which returns a different hash value each time the program is run

index_name(idx: int) str

given the index of the vector, return the column name that

Parameters:

idx (int) – index of the result vector

Returns:

column name of the vector for the xarray dataset

Return type:

str

index_names() List[str]

Returns a list of all the xarray column names for the result vector

Returns:

column names

Return type:

list[str]

class results.ResultHmap(default=None, *, doc=None, label=None, precedence=None, instantiate=False, constant=False, readonly=False, pickle_default_value=True, allow_None=False, per_instance=True, allow_refs=False, nested_refs=False)

Bases: param.Parameter

A class to represent a holomap return type

hash_persistent() str

A hash function that avoids the PYTHONHASHSEED ‘feature’ which returns a different hash value each time the program is run

results.curve(x_vals: List[float], y_vals: List[float], x_name: str, y_name: str, **kwargs) holoviews.Curve
class results.PathResult(default=None, units='path', **params)

Bases: param.Filename

Parameter that can be set to a string specifying the path of a file.

The string should be specified in UNIX style, but it will be returned in the format of the user’s operating system.

The specified path can be absolute, or relative to either:

  • any of the paths specified in the search_paths attribute (if search_paths is not None);

or

  • any of the paths searched by resolve_path() (if search_paths is None).

__slots__ = ['units']
hash_persistent() str

A hash function that avoids the PYTHONHASHSEED ‘feature’ which returns a different hash value each time the program is run

class results.ResultVideo(default=None, units='video', **params)

Bases: PathResult

Parameter that can be set to a string specifying the path of a file.

The string should be specified in UNIX style, but it will be returned in the format of the user’s operating system.

The specified path can be absolute, or relative to either:

  • any of the paths specified in the search_paths attribute (if search_paths is not None);

or

  • any of the paths searched by resolve_path() (if search_paths is None).

class results.ResultImage(default=None, units='image', **params)

Bases: PathResult

Parameter that can be set to a string specifying the path of a file.

The string should be specified in UNIX style, but it will be returned in the format of the user’s operating system.

The specified path can be absolute, or relative to either:

  • any of the paths specified in the search_paths attribute (if search_paths is not None);

or

  • any of the paths searched by resolve_path() (if search_paths is None).

class results.ResultString(default=None, units='str', **params)

Bases: param.String

A String Parameter, with a default value and optional regular expression (regex) matching.

Example of using a regex to implement IPv4 address matching:

class IPAddress(String):
  '''IPv4 address as a string (dotted decimal notation)'''
 def __init__(self, default="0.0.0.0", allow_None=False, **kwargs):
     ip_regex = r'^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$'
     super(IPAddress, self).__init__(default=default, regex=ip_regex, **kwargs)
__slots__ = ['units']
hash_persistent() str

A hash function that avoids the PYTHONHASHSEED ‘feature’ which returns a different hash value each time the program is run

class results.ResultContainer(default=None, units='container', **params)

Bases: param.Parameter

An attribute descriptor for declaring parameters.

Parameters are a special kind of class attribute. Setting a Parameterized class attribute to be a Parameter instance causes that attribute of the class (and the class’s instances) to be treated as a Parameter. This allows special behavior, including dynamically generated parameter values, documentation strings, constant and read-only parameters, and type or range checking at assignment time.

For example, suppose someone wants to define two new kinds of objects Foo and Bar, such that Bar has a parameter delta, Foo is a subclass of Bar, and Foo has parameters alpha, sigma, and gamma (and delta inherited from Bar). She would begin her class definitions with something like this:

class Bar(Parameterized):
    delta = Parameter(default=0.6, doc='The difference between steps.')
    ...
class Foo(Bar):
    alpha = Parameter(default=0.1, doc='The starting value.')
    sigma = Parameter(default=0.5, doc='The standard deviation.',
                    constant=True)
    gamma = Parameter(default=1.0, doc='The ending value.')
    ...

Class Foo would then have four parameters, with delta defaulting to 0.6.

Parameters have several advantages over plain attributes:

  1. Parameters can be set automatically when an instance is constructed: The default constructor for Foo (and Bar) will accept arbitrary keyword arguments, each of which can be used to specify the value of a Parameter of Foo (or any of Foo’s superclasses). E.g., if a script does this:

    myfoo = Foo(alpha=0.5)
    

    myfoo.alpha will return 0.5, without the Foo constructor needing special code to set alpha.

    If Foo implements its own constructor, keyword arguments will still be accepted if the constructor accepts a dictionary of keyword arguments (as in def __init__(self,**params):), and then each class calls its superclass (as in super(Foo,self).__init__(**params)) so that the Parameterized constructor will process the keywords.

  2. A Parameterized class need specify only the attributes of a Parameter whose values differ from those declared in superclasses; the other values will be inherited. E.g. if Foo declares:

    delta = Parameter(default=0.2)
    

    the default value of 0.2 will override the 0.6 inherited from Bar, but the doc will be inherited from Bar.

  3. The Parameter descriptor class can be subclassed to provide more complex behavior, allowing special types of parameters that, for example, require their values to be numbers in certain ranges, generate their values dynamically from a random distribution, or read their values from a file or other external source.

  4. The attributes associated with Parameters provide enough information for automatically generating property sheets in graphical user interfaces, allowing Parameterized instances to be edited by users.

Note that Parameters can only be used when set as class attributes of Parameterized classes. Parameters used as standalone objects, or as class attributes of non-Parameterized classes, will not have the behavior described here.

__slots__ = ['units']
hash_persistent() str

A hash function that avoids the PYTHONHASHSEED ‘feature’ which returns a different hash value each time the program is run

class results.ResultReference(obj: Any = None, container: Callable[Any, panel.pane.panel] = None, default: Any = None, units: str = 'container', **params)

Bases: param.Parameter

Use this class to save arbitrary objects that are not picklable or native to panel. You can pass a container callback that takes the object and returns a panel pane to be displayed

__slots__ = ['units', 'obj', 'container']
hash_persistent() str

A hash function that avoids the PYTHONHASHSEED ‘feature’ which returns a different hash value each time the program is run

class results.ResultVolume(obj=None, default=None, units='container', **params)

Bases: param.Parameter

An attribute descriptor for declaring parameters.

Parameters are a special kind of class attribute. Setting a Parameterized class attribute to be a Parameter instance causes that attribute of the class (and the class’s instances) to be treated as a Parameter. This allows special behavior, including dynamically generated parameter values, documentation strings, constant and read-only parameters, and type or range checking at assignment time.

For example, suppose someone wants to define two new kinds of objects Foo and Bar, such that Bar has a parameter delta, Foo is a subclass of Bar, and Foo has parameters alpha, sigma, and gamma (and delta inherited from Bar). She would begin her class definitions with something like this:

class Bar(Parameterized):
    delta = Parameter(default=0.6, doc='The difference between steps.')
    ...
class Foo(Bar):
    alpha = Parameter(default=0.1, doc='The starting value.')
    sigma = Parameter(default=0.5, doc='The standard deviation.',
                    constant=True)
    gamma = Parameter(default=1.0, doc='The ending value.')
    ...

Class Foo would then have four parameters, with delta defaulting to 0.6.

Parameters have several advantages over plain attributes:

  1. Parameters can be set automatically when an instance is constructed: The default constructor for Foo (and Bar) will accept arbitrary keyword arguments, each of which can be used to specify the value of a Parameter of Foo (or any of Foo’s superclasses). E.g., if a script does this:

    myfoo = Foo(alpha=0.5)
    

    myfoo.alpha will return 0.5, without the Foo constructor needing special code to set alpha.

    If Foo implements its own constructor, keyword arguments will still be accepted if the constructor accepts a dictionary of keyword arguments (as in def __init__(self,**params):), and then each class calls its superclass (as in super(Foo,self).__init__(**params)) so that the Parameterized constructor will process the keywords.

  2. A Parameterized class need specify only the attributes of a Parameter whose values differ from those declared in superclasses; the other values will be inherited. E.g. if Foo declares:

    delta = Parameter(default=0.2)
    

    the default value of 0.2 will override the 0.6 inherited from Bar, but the doc will be inherited from Bar.

  3. The Parameter descriptor class can be subclassed to provide more complex behavior, allowing special types of parameters that, for example, require their values to be numbers in certain ranges, generate their values dynamically from a random distribution, or read their values from a file or other external source.

  4. The attributes associated with Parameters provide enough information for automatically generating property sheets in graphical user interfaces, allowing Parameterized instances to be edited by users.

Note that Parameters can only be used when set as class attributes of Parameterized classes. Parameters used as standalone objects, or as class attributes of non-Parameterized classes, will not have the behavior described here.

__slots__ = ['units', 'obj']
hash_persistent() str

A hash function that avoids the PYTHONHASHSEED ‘feature’ which returns a different hash value each time the program is run

results.PANEL_TYPES = ()