[opengm] 88/386: bring dataset IO to python and link against HDF5

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Aug 31 08:35:09 UTC 2016


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch debian/master
in repository opengm.

commit 63623e994f9511c7a6aac105193667031f4c6922
Author: mschiegg <martin.schiegg at iwr.uni-heidelberg.de>
Date:   Wed Dec 17 13:53:44 2014 +0100

    bring dataset IO to python and link against HDF5
---
 src/interfaces/python/opengm/learning/CMakeLists.txt |  2 +-
 src/interfaces/python/opengm/learning/pyDataset.cxx  | 17 +++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/interfaces/python/opengm/learning/CMakeLists.txt b/src/interfaces/python/opengm/learning/CMakeLists.txt
index e865415..cf62f92 100644
--- a/src/interfaces/python/opengm/learning/CMakeLists.txt
+++ b/src/interfaces/python/opengm/learning/CMakeLists.txt
@@ -62,7 +62,7 @@ ELSE()
     SET_TARGET_PROPERTIES(_learning PROPERTIES OUTPUT_NAME "learning"   PREFIX "_")
 ENDIF()
 
-
+target_link_libraries(_learning  ${HDF5_CORE_LIBRARY} ${HDF5_LIBRARIES} )
 
 
 
diff --git a/src/interfaces/python/opengm/learning/pyDataset.cxx b/src/interfaces/python/opengm/learning/pyDataset.cxx
index ca7aafd..5d2d4ed 100644
--- a/src/interfaces/python/opengm/learning/pyDataset.cxx
+++ b/src/interfaces/python/opengm/learning/pyDataset.cxx
@@ -4,6 +4,7 @@
 #include <stddef.h>
 
 #include <opengm/learning/dataset/editabledataset.hxx>
+#include <opengm/learning/dataset/dataset_io.hxx>
 #include <opengm/learning/loss/hammingloss.hxx>
 #include <opengm/learning/loss/generalized-hammingloss.hxx>
 #include <opengm/learning/loss/noloss.hxx>
@@ -52,6 +53,20 @@ void pyPushBackInstance(opengm::datasets::EditableDataset<GM,LOSS>& ds,
 }
 
 template<class GM, class LOSS>
+void pySaveDataset(opengm::datasets::EditableDataset<GM,LOSS >& ds,
+                   const std::string datasetpath,
+                   const std::string prefix) {
+    opengm::datasets::DatasetSerialization::save(ds, datasetpath, prefix);
+}
+
+template<class GM, class LOSS>
+void pyLoadDataset(opengm::datasets::EditableDataset<GM,LOSS >& ds,
+                   const std::string datasetpath,
+                   const std::string prefix) {
+    opengm::datasets::DatasetSerialization::loadAll(datasetpath, prefix, ds);
+}
+
+template<class GM, class LOSS>
 void export_dataset(const std::string& className){
     typedef opengm::datasets::EditableDataset<GM,LOSS > PyDataset;
 
@@ -69,6 +84,8 @@ void export_dataset(const std::string& className){
            .def("pushBackInstance", &pyPushBackInstance<GM,LOSS>)
            .def("pushBackInstanceWithLossParam", &pyPushBackInstanceWithLossParam<GM,LOSS>)
            .def("setWeights", &PyDataset::setWeights)
+           .def("save", &pySaveDataset<GM, LOSS>)
+           .def("load", &pyLoadDataset<GM, LOSS>)
    ;
 
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/opengm.git



More information about the debian-science-commits mailing list