Target data Writers

The main entry point for writing target information is

metatensor.models.utils.data.writers.write_predictions(filename: str, systems: List[System], capabilities: ModelCapabilities, predictions: TensorMap, fileformat: str | None = None) None[source]

Writes predictions to a file.

For certain file suffixes, the systems will also be written (i.e xyz).

The capabilities of the model are used to infer the type (physical quantity) of the predictions. In this way, for example, position gradients of energies can be saved as forces.

For the moment, strain gradients of the energy are saved as stresses (and not as virials).

Parameters:
  • filename (str) – name of the file to write

  • systems (List[System]) – list of systems that for some writers will also be written

  • capabilities (ModelCapabilities) – capabilities of the model

  • predictions (TensorMap) – metatensor.torch.TensorMap containing the predictions that should be written

  • fileformat (str | None) – format of the target value file. If None the format is determined from the suffix.

Return type:

None

Based on the provided filename the writer choses which child writer to use. The mapping which reader is used for which file type is stored in

metatensor.models.utils.data.writers.PREDICTIONS_WRITERS = {'.xyz': <function write_xyz>}

dict: dictionary mapping file suffixes to a prediction writers

Implemented Writers

metatensor.models.utils.data.writers.write_xyz(filename: str, systems: List[System], capabilities: ModelCapabilities, predictions: Dict[str, TensorMap]) None[source]

An ase-based xyz file writer. Writes the systems and predictions to an xyz file.

According to ASE practice, arrays which have a dimension corresponding to each atom are saved inside atoms.arrays, while any other arrays are saved inside atoms.info.

Parameters:
Param:

capabilities: capabilities of the model.

Return type:

None