summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Rouvreau <10407034+VincentRouvreau@users.noreply.github.com>2019-08-29 10:04:35 +0200
committerGitHub <noreply@github.com>2019-08-29 10:04:35 +0200
commitc97c861c423ff3f33db10e87a2a790d9717b80cd (patch)
treeafcdc6d54a3335fbef814415a7a8219fc16b1357
parentfb082d6ae9865d148b3d851e50cdaeab00a97c81 (diff)
parent51a38f313f633e1c593d77319f3752a010da782c (diff)
Merge pull request #83 from VincentRouvreau/split_gudhi_python_in_modules
Split gudhi python in modules
-rw-r--r--.appveyor.yml4
-rw-r--r--.gitignore17
-rw-r--r--src/cython/CMakeLists.txt90
-rw-r--r--src/cython/gudhi.pyx.in33
-rw-r--r--src/cython/gudhi/__init__.py1
-rw-r--r--src/cython/gudhi/__init__.py.in40
-rw-r--r--src/cython/gudhi/alpha_complex.pyx (renamed from src/cython/cython/alpha_complex.pyx)12
-rw-r--r--src/cython/gudhi/bottleneck.pyx (renamed from src/cython/cython/bottleneck_distance.pyx)0
-rw-r--r--src/cython/gudhi/cubical_complex.pyx (renamed from src/cython/cython/cubical_complex.pyx)0
-rw-r--r--src/cython/gudhi/euclidean_strong_witness_complex.pyx (renamed from src/cython/cython/euclidean_strong_witness_complex.pyx)14
-rw-r--r--src/cython/gudhi/euclidean_witness_complex.pyx (renamed from src/cython/cython/euclidean_witness_complex.pyx)14
-rw-r--r--src/cython/gudhi/nerve_gic.pyx (renamed from src/cython/cython/nerve_gic.pyx)12
-rw-r--r--src/cython/gudhi/off_reader.pyx (renamed from src/cython/cython/off_reader.pyx)0
-rw-r--r--src/cython/gudhi/periodic_cubical_complex.pyx (renamed from src/cython/cython/periodic_cubical_complex.pyx)0
-rw-r--r--src/cython/gudhi/persistence_graphical_tools.py (renamed from src/cython/cython/persistence_graphical_tools.py)3
-rw-r--r--src/cython/gudhi/reader_utils.pyx (renamed from src/cython/cython/reader_utils.pyx)0
-rw-r--r--src/cython/gudhi/rips_complex.pyx (renamed from src/cython/cython/rips_complex.pyx)12
-rw-r--r--src/cython/gudhi/simplex_tree.pxd56
-rw-r--r--src/cython/gudhi/simplex_tree.pyx (renamed from src/cython/cython/simplex_tree.pyx)101
-rw-r--r--src/cython/gudhi/strong_witness_complex.pyx (renamed from src/cython/cython/strong_witness_complex.pyx)15
-rw-r--r--src/cython/gudhi/subsampling.pyx (renamed from src/cython/cython/subsampling.pyx)0
-rw-r--r--src/cython/gudhi/tangential_complex.pyx (renamed from src/cython/cython/tangential_complex.pyx)12
-rw-r--r--src/cython/gudhi/witness_complex.pyx (renamed from src/cython/cython/witness_complex.pyx)15
-rw-r--r--src/cython/setup.py.in43
24 files changed, 297 insertions, 197 deletions
diff --git a/.appveyor.yml b/.appveyor.yml
index 31eb48d4..ab943fb7 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -55,8 +55,8 @@ build_script:
- cmake -G "Visual Studio 15 2017 Win64" %CMAKE_FLAGS% -DCMAKE_TOOLCHAIN_FILE=c:/Tools/vcpkg/scripts/buildsystems/vcpkg.cmake ..
- if [%target%]==[Python] (
cd src/cython &
- python setup.py install &
- MSBuild RUN_TESTS.vcxproj
+ MSBuild Cython.sln /m /p:Configuration=Release /p:Platform=x64 &
+ ctest -j 1 -C Release
) else (
MSBuild GUDHIdev.sln /m /p:Configuration=Release /p:Platform=x64 &
ctest -j 1 -C Release -E diff_files
diff --git a/.gitignore b/.gitignore
index 5c2195be..31efc180 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,23 @@
# Classical CMake build directory
build/
+# Generated by Cython
+src/cython/gudhi/simplex_tree.cpp
+src/cython/gudhi/alpha_complex.cpp
+src/cython/gudhi/bottleneck.cpp
+src/cython/gudhi/cubical_complex.cpp
+src/cython/gudhi/euclidean_strong_witness_complex.cpp
+src/cython/gudhi/off_reader.cpp
+src/cython/gudhi/periodic_cubical_complex.cpp
+src/cython/gudhi/reader_utils.cpp
+src/cython/gudhi/rips_complex.cpp
+src/cython/gudhi/subsampling.cpp
+src/cython/gudhi/euclidean_witness_complex.cpp
+src/cython/gudhi/nerve_gic.cpp
+src/cython/gudhi/strong_witness_complex.cpp
+src/cython/gudhi/tangential_complex.cpp
+src/cython/gudhi/witness_complex.cpp
+
# Generated by tests
data/points/COIL_database/lucky_cat.off_dist
data/points/COIL_database/lucky_cat.off_sc.dot
diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt
index 509a122e..ab20c6e6 100644
--- a/src/cython/CMakeLists.txt
+++ b/src/cython/CMakeLists.txt
@@ -26,22 +26,29 @@ function( add_gudhi_py_test THE_TEST )
endfunction( add_gudhi_py_test )
# Set gudhi.__debug_info__
-# WARNING : to be done before gudhi.pyx.in configure_file
+# WARNING : to be done before setup.py.in configure_file
function( add_gudhi_debug_info DEBUG_INFO )
set(GUDHI_CYTHON_DEBUG_INFO "${GUDHI_CYTHON_DEBUG_INFO} \"${DEBUG_INFO}\\n\" \\\n" PARENT_SCOPE)
endfunction( add_gudhi_debug_info )
if(PYTHONINTERP_FOUND)
if(CYTHON_FOUND)
- set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}off_reader;")
- set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}simplex_tree;")
- set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}rips_complex;")
- set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}cubical_complex;")
- set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}periodic_cubical_complex;")
- set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}persistence_graphical_tools;")
- set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}reader_utils;")
- set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}witness_complex;")
- set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}strong_witness_complex;")
+ set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}'off_reader', ")
+ set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}'simplex_tree', ")
+ set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}'rips_complex', ")
+ set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}'cubical_complex', ")
+ set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}'periodic_cubical_complex', ")
+ set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}'persistence_graphical_tools', ")
+ set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}'reader_utils', ")
+ set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}'witness_complex', ")
+ set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}'strong_witness_complex', ")
+ set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}'bottleneck', ")
+ set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}'nerve_gic', ")
+ set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}'subsampling', ")
+ set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}'tangential_complex', ")
+ set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}'alpha_complex', ")
+ set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}'euclidean_witness_complex', ")
+ set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}'euclidean_strong_witness_complex', ")
add_gudhi_debug_info("Python version ${PYTHON_VERSION_STRING}")
add_gudhi_debug_info("Cython version ${CYTHON_VERSION}")
@@ -57,11 +64,6 @@ if(PYTHONINTERP_FOUND)
if(SCIPY_FOUND)
add_gudhi_debug_info("Scipy version ${SCIPY_VERSION}")
endif()
- if(MATPLOTLIB_FOUND AND NUMPY_FOUND AND SCIPY_FOUND)
- set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}persistence_graphical_tools;")
- else()
- set(GUDHI_CYTHON_MISSING_MODULES "${GUDHI_CYTHON_MODULES}persistence_graphical_tools;")
- endif()
message("++ ${PYTHON_EXECUTABLE} v.${PYTHON_VERSION_STRING} - Cython is ${CYTHON_VERSION} - Sphinx is ${SPHINX_PATH}")
set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DBOOST_RESULT_OF_USE_DECLTYPE', ")
@@ -91,45 +93,26 @@ if(PYTHONINTERP_FOUND)
set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DCGAL_EIGEN3_ENABLED', ")
endif (EIGEN3_FOUND)
+ set(GUDHI_CYTHON_MODULES_TO_COMPILE "${GUDHI_CYTHON_MODULES_TO_COMPILE}'off_reader', ")
+ set(GUDHI_CYTHON_MODULES_TO_COMPILE "${GUDHI_CYTHON_MODULES_TO_COMPILE}'simplex_tree', ")
+ set(GUDHI_CYTHON_MODULES_TO_COMPILE "${GUDHI_CYTHON_MODULES_TO_COMPILE}'rips_complex', ")
+ set(GUDHI_CYTHON_MODULES_TO_COMPILE "${GUDHI_CYTHON_MODULES_TO_COMPILE}'cubical_complex', ")
+ set(GUDHI_CYTHON_MODULES_TO_COMPILE "${GUDHI_CYTHON_MODULES_TO_COMPILE}'periodic_cubical_complex', ")
+ set(GUDHI_CYTHON_MODULES_TO_COMPILE "${GUDHI_CYTHON_MODULES_TO_COMPILE}'reader_utils', ")
+ set(GUDHI_CYTHON_MODULES_TO_COMPILE "${GUDHI_CYTHON_MODULES_TO_COMPILE}'witness_complex', ")
+ set(GUDHI_CYTHON_MODULES_TO_COMPILE "${GUDHI_CYTHON_MODULES_TO_COMPILE}'strong_witness_complex', ")
if (NOT CGAL_VERSION VERSION_LESS 4.11.0)
- set(GUDHI_CYTHON_BOTTLENECK_DISTANCE "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/bottleneck_distance.pyx'")
- set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}bottleneck_distance;")
- set(GUDHI_CYTHON_NERVE_GIC "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/nerve_gic.pyx'")
- set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}nerve_gic;")
- else()
- set(GUDHI_CYTHON_MISSING_MODULES "${GUDHI_CYTHON_MISSING_MODULES}bottleneck_distance;")
- set(GUDHI_CYTHON_MISSING_MODULES "${GUDHI_CYTHON_MISSING_MODULES}nerve_gic;")
- endif ()
- if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0)
- set(GUDHI_CYTHON_SUBSAMPLING "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/subsampling.pyx'")
- set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}subsampling;")
- set(GUDHI_CYTHON_TANGENTIAL_COMPLEX "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/tangential_complex.pyx'")
- set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}tangential_complex;")
- else()
- set(GUDHI_CYTHON_MISSING_MODULES "${GUDHI_CYTHON_MISSING_MODULES}subsampling;")
- set(GUDHI_CYTHON_MISSING_MODULES "${GUDHI_CYTHON_MISSING_MODULES}tangential_complex;")
- endif ()
- if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0)
- set(GUDHI_CYTHON_ALPHA_COMPLEX "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/alpha_complex.pyx'")
- set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}alpha_complex;")
- else()
- set(GUDHI_CYTHON_MISSING_MODULES "${GUDHI_CYTHON_MISSING_MODULES}alpha_complex;")
+ set(GUDHI_CYTHON_MODULES_TO_COMPILE "${GUDHI_CYTHON_MODULES_TO_COMPILE}'bottleneck', ")
+ set(GUDHI_CYTHON_MODULES_TO_COMPILE "${GUDHI_CYTHON_MODULES_TO_COMPILE}'nerve_gic', ")
endif ()
if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0)
- set(GUDHI_CYTHON_EUCLIDEAN_WITNESS_COMPLEX
- "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/euclidean_witness_complex.pyx'\ninclude '${CMAKE_CURRENT_SOURCE_DIR}/cython/euclidean_strong_witness_complex.pyx'\n")
- set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}euclidean_witness_complex;")
- set(GUDHI_CYTHON_MODULES "${GUDHI_CYTHON_MODULES}euclidean_strong_witness_complex;")
- else()
- set(GUDHI_CYTHON_MISSING_MODULES "${GUDHI_CYTHON_MISSING_MODULES}euclidean_witness_complex;")
- set(GUDHI_CYTHON_MISSING_MODULES "${GUDHI_CYTHON_MISSING_MODULES}euclidean_strong_witness_complex;")
+ set(GUDHI_CYTHON_MODULES_TO_COMPILE "${GUDHI_CYTHON_MODULES_TO_COMPILE}'subsampling', ")
+ set(GUDHI_CYTHON_MODULES_TO_COMPILE "${GUDHI_CYTHON_MODULES_TO_COMPILE}'tangential_complex', ")
+ set(GUDHI_CYTHON_MODULES_TO_COMPILE "${GUDHI_CYTHON_MODULES_TO_COMPILE}'alpha_complex', ")
+ set(GUDHI_CYTHON_MODULES_TO_COMPILE "${GUDHI_CYTHON_MODULES_TO_COMPILE}'euclidean_witness_complex', ")
+ set(GUDHI_CYTHON_MODULES_TO_COMPILE "${GUDHI_CYTHON_MODULES_TO_COMPILE}'euclidean_strong_witness_complex', ")
endif ()
- add_gudhi_debug_info("Installed modules are: ${GUDHI_CYTHON_MODULES}")
- if(GUDHI_CYTHON_MISSING_MODULES)
- add_gudhi_debug_info("Missing modules are: ${GUDHI_CYTHON_MISSING_MODULES}")
- endif()
-
if(CGAL_FOUND)
can_cgal_use_cxx11_thread_local()
if (NOT CGAL_CAN_USE_CXX11_THREAD_LOCAL_RESULT)
@@ -210,8 +193,13 @@ if(PYTHONINTERP_FOUND)
# Generate setup.py file to cythonize Gudhi - This file must be named setup.py by convention
configure_file(setup.py.in "${CMAKE_CURRENT_BINARY_DIR}/setup.py" @ONLY)
- # Generate gudhi.pyx - Gudhi cython file
- configure_file(gudhi.pyx.in "${CMAKE_CURRENT_BINARY_DIR}/gudhi.pyx" @ONLY)
+
+ # Generate gudhi/__init__.py
+ file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/gudhi")
+ configure_file("gudhi/__init__.py.in" "${CMAKE_CURRENT_BINARY_DIR}/gudhi/__init__.py" @ONLY)
+
+ # Other .py files
+ file(COPY "gudhi/persistence_graphical_tools.py" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/gudhi")
add_custom_command(
OUTPUT gudhi.so
diff --git a/src/cython/gudhi.pyx.in b/src/cython/gudhi.pyx.in
deleted file mode 100644
index 1c380308..00000000
--- a/src/cython/gudhi.pyx.in
+++ /dev/null
@@ -1,33 +0,0 @@
-"""This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
- See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
- Author(s): Vincent Rouvreau
-
- Copyright (C) 2016 Inria
-
- Modification(s):
- - YYYY/MM Author: Description of the modification
-"""
-
-__author__ = "Vincent Rouvreau"
-__copyright__ = "Copyright (C) 2016-2019 Inria"
-__license__ = "https://gudhi.inria.fr/licensing/"
-__version__ = "@GUDHI_VERSION@"
-# This variable is used by doctest to find files
-__root_source_dir__ = "@CMAKE_SOURCE_DIR@"
-__debug_info__ = @GUDHI_CYTHON_DEBUG_INFO@
-
-include '@CMAKE_CURRENT_SOURCE_DIR@/cython/off_reader.pyx'
-include '@CMAKE_CURRENT_SOURCE_DIR@/cython/simplex_tree.pyx'
-include '@CMAKE_CURRENT_SOURCE_DIR@/cython/rips_complex.pyx'
-include '@CMAKE_CURRENT_SOURCE_DIR@/cython/cubical_complex.pyx'
-include '@CMAKE_CURRENT_SOURCE_DIR@/cython/periodic_cubical_complex.pyx'
-include '@CMAKE_CURRENT_SOURCE_DIR@/cython/persistence_graphical_tools.py'
-include '@CMAKE_CURRENT_SOURCE_DIR@/cython/reader_utils.pyx'
-include '@CMAKE_CURRENT_SOURCE_DIR@/cython/witness_complex.pyx'
-include '@CMAKE_CURRENT_SOURCE_DIR@/cython/strong_witness_complex.pyx'
-@GUDHI_CYTHON_ALPHA_COMPLEX@
-@GUDHI_CYTHON_EUCLIDEAN_WITNESS_COMPLEX@
-@GUDHI_CYTHON_SUBSAMPLING@
-@GUDHI_CYTHON_TANGENTIAL_COMPLEX@
-@GUDHI_CYTHON_BOTTLENECK_DISTANCE@
-@GUDHI_CYTHON_NERVE_GIC@
diff --git a/src/cython/gudhi/__init__.py b/src/cython/gudhi/__init__.py
new file mode 100644
index 00000000..fde749eb
--- /dev/null
+++ b/src/cython/gudhi/__init__.py
@@ -0,0 +1 @@
+# Fake empty __init__.py for cython to accept this directory as a Python package
diff --git a/src/cython/gudhi/__init__.py.in b/src/cython/gudhi/__init__.py.in
new file mode 100644
index 00000000..b2d2d3d7
--- /dev/null
+++ b/src/cython/gudhi/__init__.py.in
@@ -0,0 +1,40 @@
+from importlib import import_module
+
+"""This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
+ See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
+ Author(s): Vincent Rouvreau
+
+ Copyright (C) 2016 Inria
+
+ Modification(s):
+ - YYYY/MM Author: Description of the modification
+"""
+
+__author__ = "GUDHI Editorial Board"
+__copyright__ = "Copyright (C) 2016 Inria"
+__license__ = "https://gudhi.inria.fr/licensing/"
+__version__ = "@GUDHI_VERSION@"
+# This variable is used by doctest to find files
+__root_source_dir__ = "@CMAKE_SOURCE_DIR@"
+__debug_info__ = @GUDHI_CYTHON_DEBUG_INFO@
+
+from sys import exc_info
+from importlib import import_module
+
+__all__ = [@GUDHI_CYTHON_MODULES@]
+
+__available_modules__ = ''
+__missing_modules__ = ''
+
+# try to import * from gudhi.__module_name__
+for __module_name__ in __all__:
+ try:
+ __module__ = import_module('gudhi.' + __module_name__)
+ try:
+ __to_import__ = __module__.__all__
+ except AttributeError:
+ __to_import__ = [name for name in __module__.__dict__ if not name.startswith('_')]
+ globals().update({name: __module__.__dict__[name] for name in __to_import__})
+ __available_modules__ += __module_name__ + ";"
+ except:
+ __missing_modules__ += __module_name__ + ";"
diff --git a/src/cython/cython/alpha_complex.pyx b/src/cython/gudhi/alpha_complex.pyx
index 26cde0a1..88ef3b1b 100644
--- a/src/cython/cython/alpha_complex.pyx
+++ b/src/cython/gudhi/alpha_complex.pyx
@@ -3,8 +3,12 @@ from libcpp.vector cimport vector
from libcpp.utility cimport pair
from libcpp.string cimport string
from libcpp cimport bool
+from libc.stdint cimport intptr_t
import os
+from gudhi.simplex_tree cimport *
+from gudhi.simplex_tree import SimplexTree
+
""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
Author(s): Vincent Rouvreau
@@ -106,6 +110,8 @@ cdef class AlphaComplex:
:returns: A simplex tree created from the Delaunay Triangulation.
:rtype: SimplexTree
"""
- simplex_tree = SimplexTree()
- self.thisptr.create_simplex_tree(simplex_tree.thisptr, max_alpha_square)
- return simplex_tree
+ stree = SimplexTree()
+ cdef intptr_t stree_int_ptr=stree.thisptr
+ cdef Simplex_tree_interface_full_featured* stree_ptr = <Simplex_tree_interface_full_featured*>stree_int_ptr
+ self.thisptr.create_simplex_tree(stree_ptr, max_alpha_square)
+ return stree
diff --git a/src/cython/cython/bottleneck_distance.pyx b/src/cython/gudhi/bottleneck.pyx
index 4b378cbc..4b378cbc 100644
--- a/src/cython/cython/bottleneck_distance.pyx
+++ b/src/cython/gudhi/bottleneck.pyx
diff --git a/src/cython/cython/cubical_complex.pyx b/src/cython/gudhi/cubical_complex.pyx
index 0dc133d1..0dc133d1 100644
--- a/src/cython/cython/cubical_complex.pyx
+++ b/src/cython/gudhi/cubical_complex.pyx
diff --git a/src/cython/cython/euclidean_strong_witness_complex.pyx b/src/cython/gudhi/euclidean_strong_witness_complex.pyx
index 26bd8375..465635c4 100644
--- a/src/cython/cython/euclidean_strong_witness_complex.pyx
+++ b/src/cython/gudhi/euclidean_strong_witness_complex.pyx
@@ -1,6 +1,10 @@
from cython cimport numeric
from libcpp.vector cimport vector
from libcpp.utility cimport pair
+from libc.stdint cimport intptr_t
+
+from gudhi.simplex_tree cimport *
+from gudhi.simplex_tree import SimplexTree
""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
@@ -65,12 +69,14 @@ cdef class EuclideanStrongWitnessComplex:
:returns: A simplex tree created from the Delaunay Triangulation.
:rtype: SimplexTree
"""
- simplex_tree = SimplexTree()
+ stree = SimplexTree()
+ cdef intptr_t stree_int_ptr=stree.thisptr
+ cdef Simplex_tree_interface_full_featured* stree_ptr = <Simplex_tree_interface_full_featured*>stree_int_ptr
if limit_dimension is not -1:
- self.thisptr.create_simplex_tree(simplex_tree.thisptr, max_alpha_square, limit_dimension)
+ self.thisptr.create_simplex_tree(stree_ptr, max_alpha_square, limit_dimension)
else:
- self.thisptr.create_simplex_tree(simplex_tree.thisptr, max_alpha_square)
- return simplex_tree
+ self.thisptr.create_simplex_tree(stree_ptr, max_alpha_square)
+ return stree
def get_point(self, vertex):
"""This function returns the point corresponding to a given vertex.
diff --git a/src/cython/cython/euclidean_witness_complex.pyx b/src/cython/gudhi/euclidean_witness_complex.pyx
index e687c6f3..92d54eb5 100644
--- a/src/cython/cython/euclidean_witness_complex.pyx
+++ b/src/cython/gudhi/euclidean_witness_complex.pyx
@@ -1,6 +1,10 @@
from cython cimport numeric
from libcpp.vector cimport vector
from libcpp.utility cimport pair
+from libc.stdint cimport intptr_t
+
+from gudhi.simplex_tree cimport *
+from gudhi.simplex_tree import SimplexTree
""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
@@ -65,12 +69,14 @@ cdef class EuclideanWitnessComplex:
:returns: A simplex tree created from the Delaunay Triangulation.
:rtype: SimplexTree
"""
- simplex_tree = SimplexTree()
+ stree = SimplexTree()
+ cdef intptr_t stree_int_ptr=stree.thisptr
+ cdef Simplex_tree_interface_full_featured* stree_ptr = <Simplex_tree_interface_full_featured*>stree_int_ptr
if limit_dimension is not -1:
- self.thisptr.create_simplex_tree(simplex_tree.thisptr, max_alpha_square, limit_dimension)
+ self.thisptr.create_simplex_tree(stree_ptr, max_alpha_square, limit_dimension)
else:
- self.thisptr.create_simplex_tree(simplex_tree.thisptr, max_alpha_square)
- return simplex_tree
+ self.thisptr.create_simplex_tree(stree_ptr, max_alpha_square)
+ return stree
def get_point(self, vertex):
"""This function returns the point corresponding to a given vertex.
diff --git a/src/cython/cython/nerve_gic.pyx b/src/cython/gudhi/nerve_gic.pyx
index 3c8f1200..9fec626f 100644
--- a/src/cython/cython/nerve_gic.pyx
+++ b/src/cython/gudhi/nerve_gic.pyx
@@ -4,6 +4,10 @@ from libcpp.utility cimport pair
from libcpp.string cimport string
from libcpp cimport bool
import os
+from libc.stdint cimport intptr_t
+
+from gudhi.simplex_tree cimport *
+from gudhi.simplex_tree import SimplexTree
""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
@@ -158,9 +162,11 @@ cdef class CoverComplex:
:returns: A simplex tree created from the Cover complex.
:rtype: SimplexTree
"""
- simplex_tree = SimplexTree()
- self.thisptr.create_simplex_tree(simplex_tree.thisptr)
- return simplex_tree
+ stree = SimplexTree()
+ cdef intptr_t stree_int_ptr=stree.thisptr
+ cdef Simplex_tree_interface_full_featured* stree_ptr = <Simplex_tree_interface_full_featured*>stree_int_ptr
+ self.thisptr.create_simplex_tree(stree_ptr)
+ return stree
def find_simplices(self):
"""Computes the simplices of the simplicial complex.
diff --git a/src/cython/cython/off_reader.pyx b/src/cython/gudhi/off_reader.pyx
index 9efd97ff..9efd97ff 100644
--- a/src/cython/cython/off_reader.pyx
+++ b/src/cython/gudhi/off_reader.pyx
diff --git a/src/cython/cython/periodic_cubical_complex.pyx b/src/cython/gudhi/periodic_cubical_complex.pyx
index 724fadd4..724fadd4 100644
--- a/src/cython/cython/periodic_cubical_complex.pyx
+++ b/src/cython/gudhi/periodic_cubical_complex.pyx
diff --git a/src/cython/cython/persistence_graphical_tools.py b/src/cython/gudhi/persistence_graphical_tools.py
index 34803222..181bc8ea 100644
--- a/src/cython/cython/persistence_graphical_tools.py
+++ b/src/cython/gudhi/persistence_graphical_tools.py
@@ -2,6 +2,9 @@ from os import path
from math import isfinite
import numpy as np
+from gudhi.reader_utils import read_persistence_intervals_in_dimension
+from gudhi.reader_utils import read_persistence_intervals_grouped_by_dimension
+
""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
Author(s): Vincent Rouvreau, Bertrand Michel
diff --git a/src/cython/cython/reader_utils.pyx b/src/cython/gudhi/reader_utils.pyx
index 147fae71..147fae71 100644
--- a/src/cython/cython/reader_utils.pyx
+++ b/src/cython/gudhi/reader_utils.pyx
diff --git a/src/cython/cython/rips_complex.pyx b/src/cython/gudhi/rips_complex.pyx
index b9a2331f..1a6c8571 100644
--- a/src/cython/cython/rips_complex.pyx
+++ b/src/cython/gudhi/rips_complex.pyx
@@ -3,7 +3,10 @@ from libcpp.vector cimport vector
from libcpp.utility cimport pair
from libcpp.string cimport string
from libcpp cimport bool
-import os
+from libc.stdint cimport intptr_t
+
+from gudhi.simplex_tree cimport *
+from gudhi.simplex_tree import SimplexTree
""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
@@ -93,6 +96,7 @@ cdef class RipsComplex:
:returns: A simplex tree created from the Delaunay Triangulation.
:rtype: SimplexTree
"""
- simplex_tree = SimplexTree()
- self.thisref.create_simplex_tree(simplex_tree.thisptr, max_dimension)
- return simplex_tree
+ stree = SimplexTree()
+ cdef intptr_t stree_ptr=stree.thisptr
+ self.thisref.create_simplex_tree(<Simplex_tree_interface_full_featured*>stree_ptr, max_dimension)
+ return stree
diff --git a/src/cython/gudhi/simplex_tree.pxd b/src/cython/gudhi/simplex_tree.pxd
new file mode 100644
index 00000000..5f86cfe2
--- /dev/null
+++ b/src/cython/gudhi/simplex_tree.pxd
@@ -0,0 +1,56 @@
+from cython cimport numeric
+from libcpp.vector cimport vector
+from libcpp.utility cimport pair
+from libcpp cimport bool
+from libcpp.string cimport string
+
+""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
+ See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
+ Author(s): Vincent Rouvreau
+
+ Copyright (C) 2016 Inria
+
+ Modification(s):
+ - YYYY/MM Author: Description of the modification
+"""
+
+__author__ = "Vincent Rouvreau"
+__copyright__ = "Copyright (C) 2016 Inria"
+__license__ = "MIT"
+
+cdef extern from "Simplex_tree_interface.h" namespace "Gudhi":
+ cdef cppclass Simplex_tree_options_full_featured:
+ pass
+
+ cdef cppclass Simplex_tree_interface_full_featured "Gudhi::Simplex_tree_interface<Gudhi::Simplex_tree_options_full_featured>":
+ Simplex_tree()
+ double simplex_filtration(vector[int] simplex)
+ void assign_simplex_filtration(vector[int] simplex, double filtration)
+ void initialize_filtration()
+ int num_vertices()
+ int num_simplices()
+ void set_dimension(int dimension)
+ int dimension()
+ int upper_bound_dimension()
+ bool find_simplex(vector[int] simplex)
+ bool insert_simplex_and_subfaces(vector[int] simplex,
+ double filtration)
+ vector[pair[vector[int], double]] get_filtration()
+ vector[pair[vector[int], double]] get_skeleton(int dimension)
+ vector[pair[vector[int], double]] get_star(vector[int] simplex)
+ vector[pair[vector[int], double]] get_cofaces(vector[int] simplex,
+ int dimension)
+ void expansion(int max_dim)
+ void remove_maximal_simplex(vector[int] simplex)
+ bool prune_above_filtration(double filtration)
+ bool make_filtration_non_decreasing()
+
+cdef extern from "Persistent_cohomology_interface.h" namespace "Gudhi":
+ cdef cppclass Simplex_tree_persistence_interface "Gudhi::Persistent_cohomology_interface<Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_full_featured>>":
+ Simplex_tree_persistence_interface(Simplex_tree_interface_full_featured * st, bool persistence_dim_max)
+ vector[pair[int, pair[double, double]]] get_persistence(int homology_coeff_field, double min_persistence)
+ vector[int] betti_numbers()
+ vector[int] persistent_betti_numbers(double from_value, double to_value)
+ vector[pair[double,double]] intervals_in_dimension(int dimension)
+ void write_output_diagram(string diagram_file_name)
+ vector[pair[vector[int], vector[int]]] persistence_pairs()
diff --git a/src/cython/cython/simplex_tree.pyx b/src/cython/gudhi/simplex_tree.pyx
index 8e791c17..51134681 100644
--- a/src/cython/cython/simplex_tree.pyx
+++ b/src/cython/gudhi/simplex_tree.pyx
@@ -1,10 +1,6 @@
-from cython cimport numeric
-from libcpp.vector cimport vector
-from libcpp.utility cimport pair
-from libcpp cimport bool
-from libcpp.string cimport string
-
+from libc.stdint cimport intptr_t
from numpy import array as np_array
+cimport simplex_tree
""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
@@ -20,43 +16,6 @@ __author__ = "Vincent Rouvreau"
__copyright__ = "Copyright (C) 2016 Inria"
__license__ = "MIT"
-cdef extern from "Simplex_tree_interface.h" namespace "Gudhi":
- cdef cppclass Simplex_tree_options_full_featured:
- pass
-
- cdef cppclass Simplex_tree_interface_full_featured "Gudhi::Simplex_tree_interface<Gudhi::Simplex_tree_options_full_featured>":
- Simplex_tree()
- double simplex_filtration(vector[int] simplex)
- void assign_simplex_filtration(vector[int] simplex, double filtration)
- void initialize_filtration()
- int num_vertices()
- int num_simplices()
- void set_dimension(int dimension)
- int dimension()
- int upper_bound_dimension()
- bool find_simplex(vector[int] simplex)
- bool insert_simplex_and_subfaces(vector[int] simplex,
- double filtration)
- vector[pair[vector[int], double]] get_filtration()
- vector[pair[vector[int], double]] get_skeleton(int dimension)
- vector[pair[vector[int], double]] get_star(vector[int] simplex)
- vector[pair[vector[int], double]] get_cofaces(vector[int] simplex,
- int dimension)
- void expansion(int max_dim)
- void remove_maximal_simplex(vector[int] simplex)
- bool prune_above_filtration(double filtration)
- bool make_filtration_non_decreasing()
-
-cdef extern from "Persistent_cohomology_interface.h" namespace "Gudhi":
- cdef cppclass Simplex_tree_persistence_interface "Gudhi::Persistent_cohomology_interface<Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_full_featured>>":
- Simplex_tree_persistence_interface(Simplex_tree_interface_full_featured * st, bool persistence_dim_max)
- vector[pair[int, pair[double, double]]] get_persistence(int homology_coeff_field, double min_persistence)
- vector[int] betti_numbers()
- vector[int] persistent_betti_numbers(double from_value, double to_value)
- vector[pair[double,double]] intervals_in_dimension(int dimension)
- void write_output_diagram(string diagram_file_name)
- vector[pair[vector[int], vector[int]]] persistence_pairs()
-
# SimplexTree python interface
cdef class SimplexTree:
"""The simplex tree is an efficient and flexible data structure for
@@ -68,7 +27,13 @@ cdef class SimplexTree:
This class is a filtered, with keys, and non contiguous vertices version
of the simplex tree.
"""
- cdef Simplex_tree_interface_full_featured * thisptr
+ # unfortunately 'cdef public Simplex_tree_interface_full_featured* thisptr' is not possible
+ # Use intptr_t instead to cast the pointer
+ cdef public intptr_t thisptr
+
+ # Get the pointer casted as it should be
+ cdef Simplex_tree_interface_full_featured* get_ptr(self):
+ return <Simplex_tree_interface_full_featured*>(self.thisptr)
cdef Simplex_tree_persistence_interface * pcohptr
@@ -79,18 +44,20 @@ cdef class SimplexTree:
# The real cython constructor
def __cinit__(self):
- self.thisptr = new Simplex_tree_interface_full_featured()
+ cdef Simplex_tree_interface_full_featured* ptr = new Simplex_tree_interface_full_featured()
+ self.thisptr = <intptr_t>ptr
def __dealloc__(self):
- if self.thisptr != NULL:
- del self.thisptr
+ cdef Simplex_tree_interface_full_featured* ptr = self.get_ptr()
+ if ptr != NULL:
+ del ptr
if self.pcohptr != NULL:
del self.pcohptr
def __is_defined(self):
"""Returns true if SimplexTree pointer is not NULL.
"""
- return self.thisptr != NULL
+ return self.get_ptr() != NULL
def __is_persistence_defined(self):
"""Returns true if Persistence pointer is not NULL.
@@ -106,7 +73,7 @@ cdef class SimplexTree:
:returns: The simplicial complex filtration value.
:rtype: float
"""
- return self.thisptr.simplex_filtration(simplex)
+ return self.get_ptr().simplex_filtration(simplex)
def assign_filtration(self, simplex, filtration):
"""This function assigns the simplicial complex filtration value for a
@@ -117,7 +84,7 @@ cdef class SimplexTree:
:param filtration: The simplicial complex filtration value.
:type filtration: float
"""
- self.thisptr.assign_simplex_filtration(simplex, filtration)
+ self.get_ptr().assign_simplex_filtration(simplex, filtration)
def initialize_filtration(self):
"""This function initializes and sorts the simplicial complex
@@ -134,7 +101,7 @@ cdef class SimplexTree:
:func:`removing<gudhi.SimplexTree.remove_maximal_simplex>`
simplices.
"""
- self.thisptr.initialize_filtration()
+ self.get_ptr().initialize_filtration()
def num_vertices(self):
"""This function returns the number of vertices of the simplicial
@@ -143,7 +110,7 @@ cdef class SimplexTree:
:returns: The simplicial complex number of vertices.
:rtype: int
"""
- return self.thisptr.num_vertices()
+ return self.get_ptr().num_vertices()
def num_simplices(self):
"""This function returns the number of simplices of the simplicial
@@ -152,7 +119,7 @@ cdef class SimplexTree:
:returns: the simplicial complex number of simplices.
:rtype: int
"""
- return self.thisptr.num_simplices()
+ return self.get_ptr().num_simplices()
def dimension(self):
"""This function returns the dimension of the simplicial complex.
@@ -169,7 +136,7 @@ cdef class SimplexTree:
:func:`prune_above_filtration()<gudhi.SimplexTree.prune_above_filtration>`
methods).
"""
- return self.thisptr.dimension()
+ return self.get_ptr().dimension()
def upper_bound_dimension(self):
"""This function returns a valid dimension upper bound of the
@@ -178,7 +145,7 @@ cdef class SimplexTree:
:returns: an upper bound on the dimension of the simplicial complex.
:rtype: int
"""
- return self.thisptr.upper_bound_dimension()
+ return self.get_ptr().upper_bound_dimension()
def set_dimension(self, dimension):
"""This function sets the dimension of the simplicial complex.
@@ -196,7 +163,7 @@ cdef class SimplexTree:
:func:`prune_above_filtration()<gudhi.SimplexTree.prune_above_filtration>`
).
"""
- self.thisptr.set_dimension(<int>dimension)
+ self.get_ptr().set_dimension(<int>dimension)
def find(self, simplex):
"""This function returns if the N-simplex was found in the simplicial
@@ -210,7 +177,7 @@ cdef class SimplexTree:
cdef vector[int] csimplex
for i in simplex:
csimplex.push_back(i)
- return self.thisptr.find_simplex(csimplex)
+ return self.get_ptr().find_simplex(csimplex)
def insert(self, simplex, filtration=0.0):
"""This function inserts the given N-simplex and its subfaces with the
@@ -230,7 +197,7 @@ cdef class SimplexTree:
cdef vector[int] csimplex
for i in simplex:
csimplex.push_back(i)
- return self.thisptr.insert_simplex_and_subfaces(csimplex,
+ return self.get_ptr().insert_simplex_and_subfaces(csimplex,
<double>filtration)
def get_filtration(self):
@@ -241,7 +208,7 @@ cdef class SimplexTree:
:rtype: list of tuples(simplex, filtration)
"""
cdef vector[pair[vector[int], double]] filtration \
- = self.thisptr.get_filtration()
+ = self.get_ptr().get_filtration()
ct = []
for filtered_complex in filtration:
v = []
@@ -260,7 +227,7 @@ cdef class SimplexTree:
:rtype: list of tuples(simplex, filtration)
"""
cdef vector[pair[vector[int], double]] skeleton \
- = self.thisptr.get_skeleton(<int>dimension)
+ = self.get_ptr().get_skeleton(<int>dimension)
ct = []
for filtered_simplex in skeleton:
v = []
@@ -281,7 +248,7 @@ cdef class SimplexTree:
for i in simplex:
csimplex.push_back(i)
cdef vector[pair[vector[int], double]] star \
- = self.thisptr.get_star(csimplex)
+ = self.get_ptr().get_star(csimplex)
ct = []
for filtered_simplex in star:
v = []
@@ -306,7 +273,7 @@ cdef class SimplexTree:
for i in simplex:
csimplex.push_back(i)
cdef vector[pair[vector[int], double]] cofaces \
- = self.thisptr.get_cofaces(csimplex, <int>codimension)
+ = self.get_ptr().get_cofaces(csimplex, <int>codimension)
ct = []
for filtered_simplex in cofaces:
v = []
@@ -337,7 +304,7 @@ cdef class SimplexTree:
:func:`dimension()<gudhi.SimplexTree.dimension>`
to recompute the exact dimension.
"""
- self.thisptr.remove_maximal_simplex(simplex)
+ self.get_ptr().remove_maximal_simplex(simplex)
def prune_above_filtration(self, filtration):
"""Prune above filtration value given as parameter.
@@ -370,7 +337,7 @@ cdef class SimplexTree:
:func:`dimension()<gudhi.SimplexTree.dimension>`
method to recompute the exact dimension.
"""
- return self.thisptr.prune_above_filtration(filtration)
+ return self.get_ptr().prune_above_filtration(filtration)
def expansion(self, max_dim):
"""Expands the Simplex_tree containing only its one skeleton
@@ -389,7 +356,7 @@ cdef class SimplexTree:
:param max_dim: The maximal dimension.
:type max_dim: int.
"""
- self.thisptr.expansion(max_dim)
+ self.get_ptr().expansion(max_dim)
def make_filtration_non_decreasing(self):
"""This function ensures that each simplex has a higher filtration
@@ -410,7 +377,7 @@ cdef class SimplexTree:
:func:`initialize_filtration()<gudhi.SimplexTree.initialize_filtration>`
to recompute it.
"""
- return self.thisptr.make_filtration_non_decreasing()
+ return self.get_ptr().make_filtration_non_decreasing()
def persistence(self, homology_coeff_field=11, min_persistence=0, persistence_dim_max = False):
"""This function returns the persistence of the simplicial complex.
@@ -432,7 +399,7 @@ cdef class SimplexTree:
"""
if self.pcohptr != NULL:
del self.pcohptr
- self.pcohptr = new Simplex_tree_persistence_interface(self.thisptr, persistence_dim_max)
+ self.pcohptr = new Simplex_tree_persistence_interface(self.get_ptr(), persistence_dim_max)
cdef vector[pair[int, pair[double, double]]] persistence_result
if self.pcohptr != NULL:
persistence_result = self.pcohptr.get_persistence(homology_coeff_field, min_persistence)
diff --git a/src/cython/cython/strong_witness_complex.pyx b/src/cython/gudhi/strong_witness_complex.pyx
index 8c155815..4e3d1b67 100644
--- a/src/cython/cython/strong_witness_complex.pyx
+++ b/src/cython/gudhi/strong_witness_complex.pyx
@@ -1,6 +1,10 @@
from cython cimport numeric
from libcpp.vector cimport vector
from libcpp.utility cimport pair
+from libc.stdint cimport intptr_t
+
+from gudhi.simplex_tree cimport *
+from gudhi.simplex_tree import SimplexTree
""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
@@ -63,9 +67,12 @@ cdef class StrongWitnessComplex:
:returns: A simplex tree created from the Delaunay Triangulation.
:rtype: SimplexTree
"""
- simplex_tree = SimplexTree()
+ stree = SimplexTree()
+ cdef intptr_t stree_int_ptr=stree.thisptr
+ cdef Simplex_tree_interface_full_featured* stree_ptr = <Simplex_tree_interface_full_featured*>stree_int_ptr
if limit_dimension is not -1:
- self.thisptr.create_simplex_tree(simplex_tree.thisptr, max_alpha_square, limit_dimension)
+ self.thisptr.create_simplex_tree(stree_ptr,
+ max_alpha_square, limit_dimension)
else:
- self.thisptr.create_simplex_tree(simplex_tree.thisptr, max_alpha_square)
- return simplex_tree
+ self.thisptr.create_simplex_tree(stree_ptr, max_alpha_square)
+ return stree
diff --git a/src/cython/cython/subsampling.pyx b/src/cython/gudhi/subsampling.pyx
index 1135c1fb..1135c1fb 100644
--- a/src/cython/cython/subsampling.pyx
+++ b/src/cython/gudhi/subsampling.pyx
diff --git a/src/cython/cython/tangential_complex.pyx b/src/cython/gudhi/tangential_complex.pyx
index 00a84810..9eb22115 100644
--- a/src/cython/cython/tangential_complex.pyx
+++ b/src/cython/gudhi/tangential_complex.pyx
@@ -3,8 +3,12 @@ from libcpp.vector cimport vector
from libcpp.utility cimport pair
from libcpp.string cimport string
from libcpp cimport bool
+from libc.stdint cimport intptr_t
import os
+from gudhi.simplex_tree cimport *
+from gudhi.simplex_tree import SimplexTree
+
""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
Author(s): Vincent Rouvreau
@@ -138,9 +142,11 @@ cdef class TangentialComplex:
:returns: A simplex tree created from the complex.
:rtype: SimplexTree
"""
- simplex_tree = SimplexTree()
- self.thisptr.create_simplex_tree(simplex_tree.thisptr)
- return simplex_tree
+ stree = SimplexTree()
+ cdef intptr_t stree_int_ptr=stree.thisptr
+ cdef Simplex_tree_interface_full_featured* stree_ptr = <Simplex_tree_interface_full_featured*>stree_int_ptr
+ self.thisptr.create_simplex_tree(stree_ptr)
+ return stree
def fix_inconsistencies_using_perturbation(self, max_perturb, time_limit=-1.0):
"""Attempts to fix inconsistencies by perturbing the point positions.
diff --git a/src/cython/cython/witness_complex.pyx b/src/cython/gudhi/witness_complex.pyx
index 91046f57..c859877d 100644
--- a/src/cython/cython/witness_complex.pyx
+++ b/src/cython/gudhi/witness_complex.pyx
@@ -1,6 +1,10 @@
from cython cimport numeric
from libcpp.vector cimport vector
from libcpp.utility cimport pair
+from libc.stdint cimport intptr_t
+
+from gudhi.simplex_tree cimport *
+from gudhi.simplex_tree import SimplexTree
""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
@@ -63,9 +67,12 @@ cdef class WitnessComplex:
:returns: A simplex tree created from the Delaunay Triangulation.
:rtype: SimplexTree
"""
- simplex_tree = SimplexTree()
+ stree = SimplexTree()
+ cdef intptr_t stree_int_ptr=stree.thisptr
+ cdef Simplex_tree_interface_full_featured* stree_ptr = <Simplex_tree_interface_full_featured*>stree_int_ptr
if limit_dimension is not -1:
- self.thisptr.create_simplex_tree(simplex_tree.thisptr, max_alpha_square, limit_dimension)
+ self.thisptr.create_simplex_tree(stree_ptr,
+ max_alpha_square, limit_dimension)
else:
- self.thisptr.create_simplex_tree(simplex_tree.thisptr, max_alpha_square)
- return simplex_tree
+ self.thisptr.create_simplex_tree(stree_ptr, max_alpha_square)
+ return stree
diff --git a/src/cython/setup.py.in b/src/cython/setup.py.in
index 70c85852..fd4307e3 100644
--- a/src/cython/setup.py.in
+++ b/src/cython/setup.py.in
@@ -12,29 +12,42 @@ from numpy import get_include as numpy_get_include
- YYYY/MM Author: Description of the modification
"""
-__author__ = "GUDHI Editorial Board"
+__author__ = "Vincent Rouvreau"
__copyright__ = "Copyright (C) 2016 Inria"
-__license__ = "GPL v3"
-
-gudhi = Extension(
- "gudhi",
- sources = ['@CMAKE_CURRENT_BINARY_DIR@/gudhi.pyx',],
- language = 'c++',
- extra_compile_args=[@GUDHI_CYTHON_EXTRA_COMPILE_ARGS@],
- extra_link_args=[@GUDHI_CYTHON_EXTRA_LINK_ARGS@],
- libraries=[@GUDHI_CYTHON_LIBRARIES@],
- library_dirs=[@GUDHI_CYTHON_LIBRARY_DIRS@],
- include_dirs = [numpy_get_include(), @GUDHI_CYTHON_INCLUDE_DIRS@],
- runtime_library_dirs=[@GUDHI_CYTHON_RUNTIME_LIBRARY_DIRS@],
-)
+__license__ = "MIT"
+
+modules = [@GUDHI_CYTHON_MODULES_TO_COMPILE@]
+
+source_dir='@CMAKE_CURRENT_SOURCE_DIR@/gudhi/'
+extra_compile_args=[@GUDHI_CYTHON_EXTRA_COMPILE_ARGS@]
+extra_link_args=[@GUDHI_CYTHON_EXTRA_LINK_ARGS@]
+libraries=[@GUDHI_CYTHON_LIBRARIES@]
+library_dirs=[@GUDHI_CYTHON_LIBRARY_DIRS@]
+include_dirs = [numpy_get_include(), '@CMAKE_CURRENT_SOURCE_DIR@/gudhi/', @GUDHI_CYTHON_INCLUDE_DIRS@]
+runtime_library_dirs=[@GUDHI_CYTHON_RUNTIME_LIBRARY_DIRS@]
+
+# Create ext_modules list from module list
+ext_modules = []
+for module in modules:
+ ext_modules.append(Extension(
+ 'gudhi.' + module,
+ sources = [source_dir + module + '.pyx',],
+ language = 'c++',
+ extra_compile_args=extra_compile_args,
+ extra_link_args=extra_link_args,
+ libraries=libraries,
+ library_dirs=library_dirs,
+ include_dirs=include_dirs,
+ runtime_library_dirs=runtime_library_dirs,))
setup(
name = 'gudhi',
+ packages=["gudhi",],
author='GUDHI Editorial Board',
author_email='gudhi-contact@lists.gforge.inria.fr',
version='@GUDHI_VERSION@',
url='http://gudhi.gforge.inria.fr/',
- ext_modules = cythonize(gudhi),
+ ext_modules = cythonize(ext_modules),
install_requires = ['cython','numpy >= 1.9',],
setup_requires = ['numpy >= 1.9',],
)