diff --git a/rmgpy/data/kinetics.py b/rmgpy/data/kinetics.py index 66e9b7b463..4a45e1e8b5 100644 --- a/rmgpy/data/kinetics.py +++ b/rmgpy/data/kinetics.py @@ -3417,7 +3417,7 @@ def filterReactions(reactants, products, reactionList): return reactions ########### -class KineticsDatabase: +class KineticsDatabase(object): """ A class for working with the RMG kinetics database. """ @@ -3441,6 +3441,25 @@ def __init__(self): } self.global_context = {} + def __reduce__(self): + """ + A helper function used when pickling a KineticsDatabase object. + """ + d = { + 'families': self.families, + 'libraries': self.libraries, + 'libraryOrder': self.libraryOrder, + } + return (KineticsDatabase, (), d) + + def __setstate__(self, d): + """ + A helper function used when unpickling a KineticsDatabase object. + """ + self.families = d['families'] + self.libraries = d['libraries'] + self.libraryOrder = d['libraryOrder'] + def load(self, path, families=None, libraries=None, depositories=None): """ Load the kinetics database from the given `path` on disk, where `path` diff --git a/rmgpy/data/statmech.py b/rmgpy/data/statmech.py index 17ef3ab818..45c534626e 100644 --- a/rmgpy/data/statmech.py +++ b/rmgpy/data/statmech.py @@ -421,7 +421,7 @@ def getStatmechData(self, molecule, thermoModel): ################################################################################ -class StatmechDatabase: +class StatmechDatabase(object): """ A class for working with the RMG statistical mechanics (frequencies) database. """ @@ -441,6 +441,27 @@ def __init__(self): } self.global_context = {} + def __reduce__(self): + """ + A helper function used when pickling a StatmechDatabase object. + """ + d = { + 'depository': self.depository, + 'libraries': self.libraries, + 'groups': self.groups, + 'libraryOrder': self.libraryOrder, + } + return (StatmechDatabase, (), d) + + def __setstate__(self, d): + """ + A helper function used when unpickling a StatmechDatabase object. + """ + self.depository = d['depository'] + self.libraries = d['libraries'] + self.groups = d['groups'] + self.libraryOrder = d['libraryOrder'] + def load(self, path, libraries=None, depository=True): """ Load the statmech database from the given `path` on disk, where `path` diff --git a/rmgpy/data/thermo.py b/rmgpy/data/thermo.py index ae0eb65323..1b515effa6 100644 --- a/rmgpy/data/thermo.py +++ b/rmgpy/data/thermo.py @@ -315,7 +315,7 @@ def processOldLibraryEntry(self, data): ################################################################################ -class ThermoDatabase: +class ThermoDatabase(object): """ A class for working with the RMG thermodynamics database. """ @@ -333,6 +333,27 @@ def __init__(self): } self.global_context = {} + def __reduce__(self): + """ + A helper function used when pickling a ThermoDatabase object. + """ + d = { + 'depository': self.depository, + 'libraries': self.libraries, + 'groups': self.groups, + 'libraryOrder': self.libraryOrder, + } + return (ThermoDatabase, (), d) + + def __setstate__(self, d): + """ + A helper function used when unpickling a ThermoDatabase object. + """ + self.depository = d['depository'] + self.libraries = d['libraries'] + self.groups = d['groups'] + self.libraryOrder = d['libraryOrder'] + def load(self, path, libraries=None, depository=True): """ Load the thermo database from the given `path` on disk, where `path`