Added the ability to pickle Simplex class in Python dev
authorDmitriy Morozov <dmitriy@mrzv.org>
Tue, 14 Sep 2010 11:34:11 -0700
branchdev
changeset 231 04a4629979da
parent 230 6a222607714c
child 234 7643a94222ae
Added the ability to pickle Simplex class in Python
bindings/python/dionysus/__init__.py
bindings/python/simplex.cpp
--- a/bindings/python/dionysus/__init__.py	Tue Sep 14 11:12:33 2010 -0700
+++ b/bindings/python/dionysus/__init__.py	Tue Sep 14 11:34:11 2010 -0700
@@ -17,6 +17,10 @@
 Simplex._cpp_repr_ =    Simplex.__repr__
 Simplex.__repr__   =    repr_with_data
 
+def Simplex_getinitargs(self):
+    return ([v for v in self.vertices], self.data)
+
+Simplex.__getinitargs__ = Simplex_getinitargs
 
 def data_cmp(s1, s2):
     return cmp(s1.data, s2.data)
--- a/bindings/python/simplex.cpp	Tue Sep 14 11:12:33 2010 -0700
+++ b/bindings/python/simplex.cpp	Tue Sep 14 11:34:11 2010 -0700
@@ -87,6 +87,7 @@
 
         .def("__hash__",            &hash_simplex<dp::Vertex, dp::Data>)
         .def("__eq__",              &eq_simplex<dp::Vertex, dp::Data>)
+        .enable_pickling()
     ;
 
     bp::class_<dp::SimplexObject>("SimplexObject")