Target data Writers¶
The main entry point for writing target information is
- metatrain.utils.data.writers.get_writer(filename: str | Path, capabilities: ModelCapabilities | None = None, append: bool | None = None, fileformat: str | None = None) Writer [source]¶
Selects the appropriate writer based on the file extension.
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:
capabilities (ModelCapabilities | None) – capabilities of the model
append (bool | None) – if
True
, the data will be appended to the file, if it exists. IfFalse
, the file will be overwritten. IfNone
, the default behavior of the writer is used.fileformat (str | None) – format of the target value file. If
None
the format is determined from the file extension.
- Return type:
Based on the provided filename the writer choses which child writer to use. The mapping which writer is used for which file type is stored in
- metatrain.utils.data.writers.PREDICTIONS_WRITERS: Dict[str, WriterFactory] = {'.mts': <function _make_factory.<locals>.factory>, '.xyz': <function _make_factory.<locals>.factory>, '.zip': <function _make_factory.<locals>.factory>}¶
dict
: dictionary mapping file suffixes to a prediction writer
Implemented Writers¶
Writer Abstract Class¶
- class metatrain.utils.data.writers.Writer(filename: str | Path, capabilities: ModelCapabilities | None = None, append: bool | None = None)[source]¶
Bases:
ABC
- Parameters:
capabilities (ModelCapabilities | None)
append (bool | None)
Available Implementations¶
The available implementations listed below represent concrete writers that inherit from
the Writer
abstract class.
- class metatrain.utils.data.writers.ASEWriter(filename: str | Path, capabilities: ModelCapabilities | None = None, append: bool | None = False)[source]¶
Bases:
Writer
Write systems and predictions to an ASE-compatible XYZ file.
- Parameters:
capabilities (ModelCapabilities | None)
append (bool | None)
- class metatrain.utils.data.writers.DiskDatasetWriter(path: str | Path, capabilities: ModelCapabilities | None = None, append: bool | None = False)[source]¶
Bases:
Writer
- Parameters:
capabilities (ModelCapabilities | None)
append (bool | None)
- class metatrain.utils.data.writers.MetatensorWriter(filename: str | Path, capabilities: ModelCapabilities | None = None, append: bool | None = False)[source]¶
Bases:
Writer
Write systems and predictions to Metatensor files (.mts).
- Parameters:
capabilities (ModelCapabilities | None)
append (bool | None)