xnn.common.config.coerce#

Shared coercers for upstream config value forms.

The key-translation registry (translate) rewrites upstream key names to the xnn canonical ones; this module handles the value forms those keys carry, so every Model.from_config accepts the same spellings: species as atomic numbers or chemical symbols (also as the string form of either), and per-species values as a list aligned with species, a {Z: value} / {symbol: value} dict, a single number (broadcast), or the string form of any of these. One implementation, used by every model, so an upstream MACE / NequIP yaml parses identically under every model name.

Functions

coerce_per_species(value, species, key[, ...])

Coerce a per-species config value to a tensor aligned with species.

coerce_species(value[, default])

Coerce a configured species list to a list of atomic numbers.