Skip to content

Data

schemas.data.Data

Bases: ABC

Assists with updating data with atomistic schemas.

update_atomistic(data, schema_map, mol_index=0)

Update the fields of the Schema instance with the provided data.

This method updates the attributes of the Schema instance based on the keys and values in the provided dictionary. The keys in the dictionary can represent nested fields using dot notation.

PARAMETER DESCRIPTION
data

A dictionary containing the keys and values to update the MoleculeSchema instance. The keys can use dot notation to specify nested attributes.

TYPE: dict[str, Any]

schema_map

A mapping of field keys to their cadence and other metadata.

TYPE: dict[str, dict[str, str]]

mol_index

The current molecule index for updating array fields.

TYPE: int DEFAULT: 0

RETURNS DESCRIPTION
int

The updated molecule index after processing the input data.

Example
mol_schema = MoleculeSchema()
schema_map = mol_schema.get_schema_map()
data = {
    "qc.energy": -76.4,
    "system.coordinates": [[0.0, 0.0, 0.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0]],
    "topology.bonds": [(0, 1), (0, 2)]
}
molecule.update(data, schema_map)
RAISES DESCRIPTION
AttributeError

If a specified attribute does not exist in the schema.

ValueError

If the cadence is unknown.

Notes
  • The method supports updating nested attributes by splitting keys on the dot ('.') character.
  • If a key does not use dot notation, it will update the top-level attribute directly.