tesliper.writing.serializer

Serialization and deserialization of Tesliper objects.

Classes

ArchiveLoader(source[, encoding])

Class for deserialization of Tesliper objects.

ArchiveWriter(destination[, mode, encoding])

Class for serialization of Tesliper objects.

class tesliper.writing.serializer.ArchiveWriter(destination: Union[str, pathlib.Path], mode: str = 'x', encoding: str = 'utf-8')[source]

Class for serialization of Tesliper objects.

Structure of the produced archive:

.
├───arguments: {input_dir=str, output_dir=str, wanted_files=[str]}
├───parameters: {"ir": {params}, ..., "roa": {params}}
├───conformers
│   ├───arguments: {"allow_data_inconsistency": bool,
│   │               "temperature_of_the_system": float}
│   ├───filenames: [str]
│   ├───kept: [bool]
│   └───data
│       ├───filename_1: {genre=str: data}
|       ...
│       └───filename_N: {genre=str: data}
└───spectra
    ├───experimental
    │   ├───spectra_genre_1: {attr_name: SingleSpectrum.attr}
    |   ...
    │   └───spectra_genre_N: {attr_name: SingleSpectrum.attr}
    ├───calculated
    │   ├───spectra_genre_1: {attr_name: Spectra.attr}
    |   ...
    │   └───spectra_genre_N: {attr_name: Spectra.attr}
    └───averaged
        ├───spectra_genre_1-energies-genre-1: {attr_name: SingleSpectrum.attr}
        ...
        └───spectra_genre_N-energies-genre-N: {attr_name: SingleSpectrum.attr}
Parameters
  • destination (Union[str, Path]) – Path to target file.

  • mode (str, optional) – Specifies how writing to file should be handled. Should be one of characters: ‘a’ (append to existing file), ‘x’ (only write if file doesn’t exist yet), or ‘w’ (overwrite file if it already exists). Defaults to “x”.

  • encoding (str, optional) – Encoding of the output, by default “utf-8”

property mode

Specifies how writing to file should be handled. Should be one of characters: “a”, “x”, or “w”. “a” - append to existing file; “x” - only write if file doesn’t exist yet; “w” - overwrite file if it already exists.

Raises

ValueError – If given anything other than “a”, “x”, or “w”.

property destination: pathlib.Path

Directory, to which generated files should be written.

Raises

FileNotFoundError – If given destination doesn’t exist or is not a directory.

Type

pathlib.Path

jsonencode(obj: Any, *, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, default=None, sort_keys=False, **kw) bytes[source]

json.dumps wrapper, that encodes JSON produced.

class tesliper.writing.serializer.ArchiveLoader(source: Union[str, pathlib.Path], encoding: str = 'utf-8')[source]

Class for deserialization of Tesliper objects.

Parameters
  • source (Union[str, Path]) – Path to the source file.

  • encoding (str, optional) – Source file encoding, by default “utf-8”.

property source: pathlib.Path

File, from which data should read.

Notes

If str given, it will be converted to pathlib.Path.

Raises

FileNotFoundError – If given destination doesn’t exist.

Type

pathlib.Path

jsondecode(string: bytes, *, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw) Any[source]

json.loads wrapper, that decodes bytes before parsing as JSON.