openforcefield.typing.engines.smirnoff.parameters.MappedParameterAttribute

class openforcefield.typing.engines.smirnoff.parameters.MappedParameterAttribute(default=<class 'openforcefield.typing.engines.smirnoff.parameters.ParameterAttribute.UNDEFINED'>, unit=None, converter=None)[source]

The attribute of a parameter in which each term is a mapping.

The substantial difference with IndexedParameterAttribute is that, unlike indexing, the mapping can be based on artbitrary references, like indices but can starting at non-zero values and include non-adjacent keys.

Parameters
defaultobject, optional

When specified, the descriptor makes this attribute optional by attaching a default value to it.

unitsimtk.unit.Quantity, optional

When specified, only sequences of mappings where values are quantities with compatible units are allowed to be set.

convertercallable, optional

An optional function that can be used to validate and cast each component of each element of the sequence before setting the attribute.

See also

IndexedParameterAttribute

A parameter attribute representing a sequence.

IndexedMappedParameterAttribute

A parameter attribute representing a sequence, each term of which is a mapping.

Examples

Create an optional indexed attribute with unit of angstrom.

>>> from simtk import unit
>>> class MyParameter:
...     length = MappedParameterAttribute(default=None, unit=unit.angstrom)
...
>>> my_par = MyParameter()
>>> my_par.length is None
True

Like other ParameterAttribute objects, strings are parsed into Quantity objects.

>>> my_par.length = {1:'1.5 * angstrom', 2: '1.4 * angstrom'}
>>> my_par.length[1]
Quantity(value=1.5, unit=angstrom)

Unlike other ParameterAttribute objects, the reference points can do not need ot be zero-indexed, non-adjancent, such as interpolating defining a bond parameter for interpolation by defining references values and bond orders 2 and 3:

>>> my_par.length = {2:'1.42 * angstrom', 3: '1.35 * angstrom'}
>>> my_par.length[2]
Quantity(value=1.42, unit=angstrom)
Attributes
name

Methods

UNDEFINED()

Custom type used by ParameterAttribute to differentiate between None and undeclared default.

converter(converter)

Create a new ParameterAttribute with an associated converter.

__init__(default=<class 'openforcefield.typing.engines.smirnoff.parameters.ParameterAttribute.UNDEFINED'>, unit=None, converter=None)

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__([default, unit, converter])

Initialize self.

converter(converter)

Create a new ParameterAttribute with an associated converter.

Attributes

name

class UNDEFINED

Custom type used by ParameterAttribute to differentiate between None and undeclared default.

converter(converter)

Create a new ParameterAttribute with an associated converter.

This is meant to be used as a decorator (see main examples).