class openff.toolkit.typing.engines.smirnoff.parameters.IndexedMappedParameterAttribute(default=UNDEFINED, unit=None, converter=None, docstring='')[source]

The attribute of a parameter with an unspecified number of terms, where each term is a mapping.

Some parameters can be associated to multiple terms, where those terms have multiple components. For example, torsions with fractional bond orders have parameters such as k1_bondorder1, k1_bondorder2, k2_bondorder1, k2_bondorder2, …, and IndexedMappedParameterAttribute can be used to encapsulate the sequence of terms as mappings (typically, dicts) of their components.

The only substantial difference with IndexedParameterAttribute is that only sequences of mappings are supported as values and converters and units are checked on each component of each element in the sequence.

Currently, the descriptor makes the sequence immutable. This is to avoid that an element of the sequence could be set without being properly validated. In the future, the data could be wrapped in a safe list that would safely allow mutability.

  • default (object, optional) – When specified, the descriptor makes this attribute optional by attaching a default value to it.

  • unit (openmm.unit.Quantity, optional) – When specified, only sequences of mappings where values are quantities with compatible units are allowed to be set.

  • converter (callable, 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


A parameter attribute representing a sequence.


A parameter attribute representing a mapping.


Create an optional indexed attribute with unit of angstrom.

>>> from openmm import unit
>>> class MyParameter:
...     length = IndexedMappedParameterAttribute(default=None, unit=unit.angstrom)
>>> my_par = MyParameter()
>>> my_par.length is None

Strings are parsed into Quantity objects.

>>> my_par.length = [{1:'1 * angstrom'}, {1: 0.5 * unit.nanometer}]
>>> my_par.length[0]
{1: Quantity(value=1, unit=angstrom)}

Similarly, custom converters work as with ParameterAttribute, but they are used to validate each value in the sequence.

>>> class MyParameter:
...     attr_indexed = IndexedMappedParameterAttribute(converter=float)
>>> my_par = MyParameter()
>>> my_par.attr_indexed = [{1: 1}, {2: '1.0', 3: '1e-2'}, {4: 4.0}]
>>> my_par.attr_indexed
[{1: 1.0}, {2: 1.0, 3: 0.01}, {4: 4.0}]
__init__(default=UNDEFINED, unit=None, converter=None, docstring='')


__init__([default, unit, converter, docstring])


Create a new ParameterAttribute with an associated converter.




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


Create a new ParameterAttribute with an associated converter.

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