summaryrefslogtreecommitdiff
path: root/src/cython
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-02-09 22:06:01 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-02-09 22:06:01 +0000
commite4abae7a58633c3c19cf14b6255d705cc5d6f532 (patch)
tree7337cc28135b41f433cc3f808bea8bf1026fb16c /src/cython
parent9755ec3498b4ff0480a74a580545b190f2db5a62 (diff)
cython folder containing gudhi module.
First shot with SimplexTree and MiniSimplexTree constructor/destructor git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@1013 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 83e6607c5d53bd8a414421e50e08f5f8150d2b4d
Diffstat (limited to 'src/cython')
-rw-r--r--src/cython/Makefile8
-rw-r--r--src/cython/cgudhi.pxd9
-rw-r--r--src/cython/gudhi.pyx18
-rwxr-xr-xsrc/cython/main.py5
-rw-r--r--src/cython/setup.py15
5 files changed, 55 insertions, 0 deletions
diff --git a/src/cython/Makefile b/src/cython/Makefile
new file mode 100644
index 00000000..b694ab47
--- /dev/null
+++ b/src/cython/Makefile
@@ -0,0 +1,8 @@
+ext:
+ python setup.py build_ext --inplace
+
+test:
+ python main.py
+
+clean:
+ rm -rf build/ *.o *.so *.cpp
diff --git a/src/cython/cgudhi.pxd b/src/cython/cgudhi.pxd
new file mode 100644
index 00000000..9ba40999
--- /dev/null
+++ b/src/cython/cgudhi.pxd
@@ -0,0 +1,9 @@
+
+cdef extern from "include/gudhi/Simplex_tree.h" namespace "Gudhi":
+ cdef cppclass Simplex_tree_options_full_featured:
+ pass
+ cdef Simplex_tree_options_fast_persistence:
+ pass
+ cdef cppclass Simplex_tree[T]:
+ Simplex_tree()
+
diff --git a/src/cython/gudhi.pyx b/src/cython/gudhi.pyx
new file mode 100644
index 00000000..6fab0726
--- /dev/null
+++ b/src/cython/gudhi.pyx
@@ -0,0 +1,18 @@
+from cython cimport numeric
+cimport cgudhi
+
+cdef class SimplexTree:
+ cdef cgudhi.Simplex_tree[cgudhi.Simplex_tree_options_full_featured] *thisptr
+ def __cinit__(self):
+ self.thisptr = new cgudhi.Simplex_tree[cgudhi.Simplex_tree_options_full_featured]()
+ def __dealloc__(self):
+ if self.thisptr != NULL:
+ del self.thisptr
+
+cdef class MiniSimplexTree:
+ cdef cgudhi.Simplex_tree[cgudhi.Simplex_tree_options_fast_persistence] *thisptr
+ def __cinit__(self):
+ self.thisptr = new cgudhi.Simplex_tree[cgudhi.Simplex_tree_options_fast_persistence]()
+ def __dealloc__(self):
+ if self.thisptr != NULL:
+ del self.thisptr
diff --git a/src/cython/main.py b/src/cython/main.py
new file mode 100755
index 00000000..cb7a4754
--- /dev/null
+++ b/src/cython/main.py
@@ -0,0 +1,5 @@
+#!/usr/bin/env python
+
+import gudhi
+
+st = gudhi.SimplexTree()
diff --git a/src/cython/setup.py b/src/cython/setup.py
new file mode 100644
index 00000000..26a46590
--- /dev/null
+++ b/src/cython/setup.py
@@ -0,0 +1,15 @@
+from distutils.core import setup, Extension
+from Cython.Build import cythonize
+
+gudhi = Extension(
+ "gudhi",
+ sources = ['gudhi.pyx',],
+ language = 'c++',
+ extra_compile_args=['-std=c++11'],
+ include_dirs = ['..'],
+)
+
+setup(
+ name = 'gudhi',
+ ext_modules = cythonize(gudhi),
+)