Serializer#

class Serializer[source]#

Bases: ABC

Interface for any class that can read and write configurations to a persistent format, e.g. a file.

This can be used for the state of an optimization or the setup of the layers.

__init__()#

Methods

__init__()

load()

Load and return data that was previously saved.

load_comment()

Load and return the comment, if any, that was previously saved with the data.

save(data[, comment])

Saves data to a persistent format.

abstract load()[source]#

Load and return data that was previously saved.

abstract load_comment()[source]#

Load and return the comment, if any, that was previously saved with the data.

Returns None if no comment was saved.

Returns:

The comment, or None if no comment was saved.

Return type:

str | None

abstract save(data, comment=None)[source]#

Saves data to a persistent format.

The actual format depends on the implementation.

Parameters:
  • data (dict) – The data to be exported.

  • comment (str | None) – Optional comment to be stored with the data, for example a description of the data. Implementations have to decide how to store the comment.