Commit 698e6763 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Fix pickling of GraphView objects

parent 1cc26bed
...@@ -408,7 +408,7 @@ class PropertyMap(object): ...@@ -408,7 +408,7 @@ class PropertyMap(object):
def __unregister_map(self): def __unregister_map(self):
for g in [self.__g(), self.__base_g()]: for g in [self.__g(), self.__base_g()]:
if g is not None: if g is not None and id(self) in g._Graph__known_properties:
del g._Graph__known_properties[id(self)] del g._Graph__known_properties[id(self)]
def __del__(self): def __del__(self):
...@@ -2039,6 +2039,15 @@ class GraphView(Graph): ...@@ -2039,6 +2039,15 @@ class GraphView(Graph):
return self.__base return self.__base
base = property(__get_base, doc="Base graph.") base = property(__get_base, doc="Base graph.")
# pickling support
def __getstate__(self):
return Graph.__getstate__(self)
def __setstate__(self, state):
g = Graph()
g.__setstate__(state)
self.__init__(g)
def value_types(): def value_types():
"""Return a list of possible properties value types.""" """Return a list of possible properties value types."""
...@@ -2176,7 +2185,7 @@ Vector_string.__repr__ = lambda self: repr(list(self)) ...@@ -2176,7 +2185,7 @@ Vector_string.__repr__ = lambda self: repr(list(self))
# Global RNG # Global RNG
_rng = libcore.get_rng(numpy.random.randint(0, sys.maxsize)) _rng = libcore.get_rng((numpy.random.randint(0, sys.maxsize) + os.getpid()) % sys.maxsize)
def seed_rng(seed): def seed_rng(seed):
"Seed the random number generator used by graph-tool's algorithms." "Seed the random number generator used by graph-tool's algorithms."
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment