[ismrmrd] 115/281: working on Python bindings

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Jan 14 20:01:04 UTC 2015


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

ghisvail-guest pushed a commit to annotated tag ismrmrd0.5
in repository ismrmrd.

commit fa9bc6c693b5404f206be652bdf1724331805ebe
Author: Joseph Naegele <joseph.naegele at gmail.com>
Date:   Wed Mar 27 10:59:31 2013 -0400

    working on Python bindings
---
 bindings/CMakeLists.txt              | 16 ++--------------
 bindings/{ => python}/CMakeLists.txt |  0
 bindings/{ => python}/ismrmrd.i      | 26 ++++++++++++++++----------
 3 files changed, 18 insertions(+), 24 deletions(-)

diff --git a/bindings/CMakeLists.txt b/bindings/CMakeLists.txt
index 5a43e2f..8ff8ecd 100644
--- a/bindings/CMakeLists.txt
+++ b/bindings/CMakeLists.txt
@@ -1,14 +1,2 @@
-find_package(SWIG REQUIRED)
-include(${SWIG_USE_FILE})
-
-find_package(PythonLibs)
-include_directories(${PYTHON_INCLUDE_PATH})
-
-include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
-
-#set(CMAKE_SWIG_FLAGS "-c++")
-set(CMAKE_SWIG_FLAGS "")
-set_source_files_properties(ismrmrd.i PROPERTIES CPLUSPLUS ON)
-#set_source_files_properties(ismrmrd.i PROPERTIES SWIG_FLAGS "-includeall")
-SWIG_ADD_MODULE(ismrmrd python ismrmrd.i)
-SWIG_LINK_LIBRARIES(ismrmrd ${PYTHON_LIBRARIES})
+add_subdirectory(python)
+#add_subdirectory(java)
diff --git a/bindings/CMakeLists.txt b/bindings/python/CMakeLists.txt
similarity index 100%
copy from bindings/CMakeLists.txt
copy to bindings/python/CMakeLists.txt
diff --git a/bindings/ismrmrd.i b/bindings/python/ismrmrd.i
similarity index 59%
rename from bindings/ismrmrd.i
rename to bindings/python/ismrmrd.i
index 0de1724..12eb680 100644
--- a/bindings/ismrmrd.i
+++ b/bindings/python/ismrmrd.i
@@ -6,21 +6,27 @@
 
 %include "stdint.i"
 
-//%include "carrays.i"
-//%array_class(float, floatArray);
+%extend ISMRMRD::Acquisition {
+    PyObject* getData() {
+        PyObject *list = PyList_New(0);
+
+        std::valarray<float> data = $self->getData();
+
+        int i;
+        for (i = 0; i < data.size(); i++) {
+            PyObject *o = PyFloat_FromDouble((double)data[i]);
+            PyList_Append(list, o);
+            Py_DECREF(o);
+        }
+        return list;
+    }
+
+}
 
 %ignore ISMRMRD::Acquisition::getData;
 
 %include "ismrmrd.h"
 
-%extend ISMRMRD::Acquisition {
-
-    float* getData() {
-        return (float*)(&($self->getData()[0]));
-    }
-    
-}
-
 namespace ISMRMRD {
     %template(Image_ushort) Image<unsigned short int>;
     %template(Image_float)  Image<float>;

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



More information about the debian-science-commits mailing list