openff.toolkit.typing.engines.smirnoff.parameters.MappedParameterAttribute
- class openff.toolkit.typing.engines.smirnoff.parameters.MappedParameterAttribute(default=UNDEFINED, unit=None, converter=None, docstring='')[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.
- unitopenmm.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 openmm 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)
Methods
__init__
([default, unit, converter, docstring])converter
(converter)Create a new ParameterAttribute with an associated converter.
Attributes
name