pymatgen.serializers.pickle_coders module

This module implements the pickler objects used in abinitio.

class PmgPickler[source]

Bases: _pickle.Pickler

Persistence of External Objects as described in section 12.1.5.1 of https://docs.python.org/3/library/pickle.html

persistent_id(obj)[source]

Instead of pickling as a regular class instance, we emit a persistent ID.

class PmgUnpickler[source]

Bases: _pickle.Unpickler

Persistence of External Objects as described in section 12.1.5.1 of https://docs.python.org/3/library/pickle.html

persistent_load(pid)[source]

This method is invoked whenever a persistent ID is encountered. Here, pid is the tuple returned by PmgPickler.

pmg_pickle_dump(obj, filobj, **kwargs)[source]

Dump an object to a pickle file using PmgPickler.

Parameters:
  • obj (object) – Object to dump.
  • fileobj – File-like object
  • **kwargs – Any of the keyword arguments supported by PmgPickler
pmg_pickle_load(filobj, **kwargs)[source]

Loads a pickle file and deserialize it with PmgUnpickler.

Parameters:
  • filobj – File-like object
  • **kwargs – Any of the keyword arguments supported by PmgUnpickler
Returns:

Deserialized object.