I/O Write: General

I/O Write: General#

General writer for files to a path.

tad_mctc.io.write.writer.write(filepath, numbers, positions, ftype=None, mode='w', overwrite=False, **kwargs)[source]#

Write the structure to the given file path.

Parameters:
  • filepath (PathLike) – File path to write the structure to.

  • numbers (Tensor) – Tensor of atomic numbers.

  • positions (Tensor) – Tensor of atomic positions (shape: (nat, 3) in atomic units).

  • ftype (str | None, optional) – File type. If None, the file extension is used to infer the type.

  • mode (str, optional) – Mode in which the file is opened. Defaults to "w".

  • overwrite (bool, optional) – If False and the file exists, a FileExistsError is raised.

  • **kwargs (Any) – Additional arguments for the specific writer.

Raises:
  • FileExistsError – If the file exists and overwrite is False.

  • ValueError – If the file type is unknown.

  • NotImplementedError – If the file type is recognized but no writer is available.