diff options
Diffstat (limited to 'src/cython')
-rw-r--r-- | src/cython/CMakeLists.txt | 6 | ||||
-rw-r--r-- | src/cython/doc/_templates/layout.html | 4 | ||||
-rw-r--r-- | src/cython/doc/alpha_complex_sum.rst | 2 | ||||
-rw-r--r-- | src/cython/doc/alpha_complex_user.rst | 104 | ||||
-rw-r--r-- | src/cython/doc/bottleneck_distance_user.rst | 7 | ||||
-rw-r--r-- | src/cython/doc/cubical_complex_user.rst | 3 | ||||
-rw-r--r-- | src/cython/doc/index.rst | 19 | ||||
-rw-r--r-- | src/cython/doc/installation.rst | 4 | ||||
-rw-r--r-- | src/cython/doc/persistence_graphical_tools_user.rst | 1 | ||||
-rw-r--r-- | src/cython/doc/persistent_cohomology_user.rst | 3 | ||||
-rw-r--r-- | src/cython/doc/rips_complex_user.rst | 157 | ||||
-rw-r--r-- | src/cython/doc/simplex_tree_user.rst | 1 | ||||
-rw-r--r-- | src/cython/doc/tangential_complex_user.rst | 36 | ||||
-rw-r--r-- | src/cython/doc/witness_complex_user.rst | 6 | ||||
-rwxr-xr-x | src/cython/example/rips_complex_diagram_persistence_from_distance_matrix_file_example.py | 45 |
15 files changed, 192 insertions, 206 deletions
diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index 51c208aa..96c2acb3 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -1,8 +1,8 @@ cmake_minimum_required(VERSION 2.8) project(Cython) -if(CYTHON_PATH) - message("${PYTHON_EXECUTABLE} v.${PYTHON_VERSION_STRING} - Cython is ${CYTHON_PATH} - py.test is ${PYTEST_PATH} - Sphinx is ${SPHINX_PATH}") +if(CYTHON_FOUND) + message("++ ${PYTHON_EXECUTABLE} v.${PYTHON_VERSION_STRING} - Cython is ${CYTHON_EXECUTABLE} - py.test is ${PYTEST_PATH} - Sphinx is ${SPHINX_PATH}") set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DBOOST_RESULT_OF_USE_DECLTYPE', ") set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DBOOST_ALL_NO_LIB', ") @@ -281,4 +281,4 @@ if(CYTHON_PATH) COMMAND make.bat html doctest) endif (UNIX) endif(SPHINX_PATH) -endif(CYTHON_PATH) +endif(CYTHON_FOUND) diff --git a/src/cython/doc/_templates/layout.html b/src/cython/doc/_templates/layout.html index af0eef64..b11c1236 100644 --- a/src/cython/doc/_templates/layout.html +++ b/src/cython/doc/_templates/layout.html @@ -205,8 +205,8 @@ <ul class="dropdown"> <li><a href="http://gudhi.gforge.inria.fr/doc/latest/">C++ documentation</a></li> <li><a href="http://gudhi.gforge.inria.fr/doc/latest/installation.html">C++ installation manual</a></li> - <li><a href="http://gudhi.gforge.inria.fr/cython/latest/">Cython documentation</a></li> - <li><a href="http://gudhi.gforge.inria.fr/cython/latest/installation.html">Cython installation manual</a></li> + <li><a href="http://gudhi.gforge.inria.fr/python/latest/">Python documentation</a></li> + <li><a href="http://gudhi.gforge.inria.fr/python/latest/installation.html">Python installation manual</a></li> </ul> </li> <li class="divider"></li> diff --git a/src/cython/doc/alpha_complex_sum.rst b/src/cython/doc/alpha_complex_sum.rst index 8437e901..a5f6420a 100644 --- a/src/cython/doc/alpha_complex_sum.rst +++ b/src/cython/doc/alpha_complex_sum.rst @@ -16,7 +16,7 @@ | | complex. | | | | | | This package requires having CGAL version 4.7 or higher (4.8.1 is | -| | advised for better perfomances). | +| | advised for better performance). | +----------------------------------------------------------------+------------------------------------------------------------------------+ | :doc:`alpha_complex_user` | :doc:`alpha_complex_ref` | +----------------------------------------------------------------+------------------------------------------------------------------------+ diff --git a/src/cython/doc/alpha_complex_user.rst b/src/cython/doc/alpha_complex_user.rst index 2356944d..e8268ef1 100644 --- a/src/cython/doc/alpha_complex_user.rst +++ b/src/cython/doc/alpha_complex_user.rst @@ -1,4 +1,3 @@ -========================= Alpha complex user manual ========================= Definition @@ -30,39 +29,40 @@ This example builds the Delaunay triangulation from the given points, and initia repr(simplex_tree.num_simplices()) + ' simplices - ' + \ repr(simplex_tree.num_vertices()) + ' vertices.' print(result_str) + fmt = '%s -> %.2f' for filtered_value in simplex_tree.get_filtration(): - print(filtered_value) + print(fmt % tuple(filtered_value)) The output is: .. testoutput:: Alpha complex is of dimension 2 - 25 simplices - 7 vertices. - ([0], 0.0) - ([1], 0.0) - ([2], 0.0) - ([3], 0.0) - ([4], 0.0) - ([5], 0.0) - ([6], 0.0) - ([2, 3], 6.25) - ([4, 5], 7.25) - ([0, 2], 8.5) - ([0, 1], 9.25) - ([1, 3], 10.0) - ([1, 2], 11.25) - ([1, 2, 3], 12.5) - ([0, 1, 2], 12.995867768595042) - ([5, 6], 13.25) - ([2, 4], 20.0) - ([4, 6], 22.736686390532547) - ([4, 5, 6], 22.736686390532547) - ([3, 6], 30.25) - ([2, 6], 36.5) - ([2, 3, 6], 36.5) - ([2, 4, 6], 37.24489795918368) - ([0, 4], 59.710743801652896) - ([0, 2, 4], 59.710743801652896) + [0] -> 0.00 + [1] -> 0.00 + [2] -> 0.00 + [3] -> 0.00 + [4] -> 0.00 + [5] -> 0.00 + [6] -> 0.00 + [2, 3] -> 6.25 + [4, 5] -> 7.25 + [0, 2] -> 8.50 + [0, 1] -> 9.25 + [1, 3] -> 10.00 + [1, 2] -> 11.25 + [1, 2, 3] -> 12.50 + [0, 1, 2] -> 13.00 + [5, 6] -> 13.25 + [2, 4] -> 20.00 + [4, 6] -> 22.74 + [4, 5, 6] -> 22.74 + [3, 6] -> 30.25 + [2, 6] -> 36.50 + [2, 3, 6] -> 36.50 + [2, 4, 6] -> 37.24 + [0, 4] -> 59.71 + [0, 2, 4] -> 59.71 Algorithm @@ -164,39 +164,39 @@ Then, it is asked to display information about the alpha complex: repr(simplex_tree.num_simplices()) + ' simplices - ' + \ repr(simplex_tree.num_vertices()) + ' vertices.' print(result_str) + fmt = '%s -> %.2f' for filtered_value in simplex_tree.get_filtration(): - print(filtered_value) + print(fmt % tuple(filtered_value)) the program output is: .. testoutput:: Alpha complex is of dimension 2 - 23 simplices - 7 vertices. - ([0], 0.0) - ([1], 0.0) - ([2], 0.0) - ([3], 0.0) - ([4], 0.0) - ([5], 0.0) - ([6], 0.0) - ([2, 3], 6.25) - ([4, 5], 7.25) - ([0, 2], 8.5) - ([0, 1], 9.25) - ([1, 3], 10.0) - ([1, 2], 11.25) - ([1, 2, 3], 12.5) - ([0, 1, 2], 12.995867768595042) - ([5, 6], 13.25) - ([2, 4], 20.0) - ([4, 6], 22.736686390532547) - ([4, 5, 6], 22.736686390532547) - ([3, 6], 30.25) - ([2, 6], 36.5) - ([2, 3, 6], 36.5) - ([2, 4, 6], 37.24489795918368) + [0] -> 0.00 + [1] -> 0.00 + [2] -> 0.00 + [3] -> 0.00 + [4] -> 0.00 + [5] -> 0.00 + [6] -> 0.00 + [2, 3] -> 6.25 + [4, 5] -> 7.25 + [0, 2] -> 8.50 + [0, 1] -> 9.25 + [1, 3] -> 10.00 + [1, 2] -> 11.25 + [1, 2, 3] -> 12.50 + [0, 1, 2] -> 13.00 + [5, 6] -> 13.25 + [2, 4] -> 20.00 + [4, 6] -> 22.74 + [4, 5, 6] -> 22.74 + [3, 6] -> 30.25 + [2, 6] -> 36.50 + [2, 3, 6] -> 36.50 + [2, 4, 6] -> 37.24 -============== CGAL citations ============== diff --git a/src/cython/doc/bottleneck_distance_user.rst b/src/cython/doc/bottleneck_distance_user.rst index 8c29d069..0066992f 100644 --- a/src/cython/doc/bottleneck_distance_user.rst +++ b/src/cython/doc/bottleneck_distance_user.rst @@ -1,4 +1,3 @@ -=============================== Bottleneck distance user manual =============================== Definition @@ -23,15 +22,15 @@ This example computes the bottleneck distance from 2 persistence diagrams: diag1 = [[2.7, 3.7],[9.6, 14.],[34.2, 34.974], [3.,float('Inf')]] diag2 = [[2.8, 4.45],[9.5, 14.1],[3.2,float('Inf')]] - message = "Bottleneck distance approximation=" + repr(gudhi.bottleneck_distance(diag1, diag2, 0.1)) + message = "Bottleneck distance approximation=" + '%.2f' % gudhi.bottleneck_distance(diag1, diag2, 0.1) print(message) - message = "Bottleneck distance exact value=" + repr(gudhi.bottleneck_distance(diag1, diag2, 0)) + message = "Bottleneck distance exact value=" + '%.2f' % gudhi.bottleneck_distance(diag1, diag2, 0) print(message) The output is: .. testoutput:: - Bottleneck distance approximation=0.8081763781405569 + Bottleneck distance approximation=0.81 Bottleneck distance exact value=0.75 diff --git a/src/cython/doc/cubical_complex_user.rst b/src/cython/doc/cubical_complex_user.rst index 692acdd9..344b9554 100644 --- a/src/cython/doc/cubical_complex_user.rst +++ b/src/cython/doc/cubical_complex_user.rst @@ -1,4 +1,3 @@ -=========================== Cubical complex user manual =========================== Definition @@ -154,7 +153,7 @@ Examples. End user programs are available in cython/example/ folder. Bibliography -************ +============ .. bibliography:: bibliography.bib :filter: docnames diff --git a/src/cython/doc/index.rst b/src/cython/doc/index.rst index fca63d65..f6d10567 100644 --- a/src/cython/doc/index.rst +++ b/src/cython/doc/index.rst @@ -1,5 +1,5 @@ -GUDHI documentation -################### +GUDHI Python module documentation +################################# .. image:: img/Gudhi_banner.png :align: center @@ -7,9 +7,9 @@ GUDHI documentation Introduction ************ -The Gudhi library (Geometry Understanding in Higher Dimensions) is a generic -open source `C++ library <http://gudhi.gforge.inria.fr/doc/latest/>`_, with a -`Cython interface <http://gudhi.gforge.inria.fr/cython/latest/>`_, for +The Python interface for the Gudhi library (Geometry Understanding in Higher +Dimensions) is a generic open source +`Python module <http://gudhi.gforge.inria.fr/python/latest/>`_, for Computational Topology and Topological Data Analysis (`TDA <https://en.wikipedia.org/wiki/Topological_data_analysis>`_). The GUDHI library intends to help the development of new algorithmic solutions @@ -20,12 +20,11 @@ data structures. The current release of the GUDHI library includes: * Data structures to represent, construct and manipulate simplicial complexes. -* Algorithms to compute persistent homology and multi-field persistent homology. -* Simplication of simplicial complexes by edge contraction. +* Simplification of simplicial complexes by edge contraction. +* Algorithms to compute persistent homology and bottleneck distance. -All data-structures are generic and several of their aspects can be -parameterized via template classes. We refer to :cite:`gudhilibrary_ICMS14` -for a detailed description of the design of the library. +We refer to :cite:`gudhilibrary_ICMS14` for a detailed description of the +design of the library. Data structures *************** diff --git a/src/cython/doc/installation.rst b/src/cython/doc/installation.rst index 373e0717..f98a5039 100644 --- a/src/cython/doc/installation.rst +++ b/src/cython/doc/installation.rst @@ -33,7 +33,7 @@ To build the GUDHI cython module, run the following commands in a terminal: Test suites =========== -To test your build, `py.test <http://doc.pytest.org>`_ is required. Run the +To test your build, `py.test <http://doc.pytest.org>`_ is optional. Run the following command in a terminal: .. code-block:: bash @@ -41,7 +41,7 @@ following command in a terminal: cd /path-to-gudhi/build/cython # For windows, you have to set PYTHONPATH environment variable export PYTHONPATH='$PYTHONPATH:/path-to-gudhi/build/cython' - py.test + ctest -R py_test Documentation ============= diff --git a/src/cython/doc/persistence_graphical_tools_user.rst b/src/cython/doc/persistence_graphical_tools_user.rst index f713e971..cae18323 100644 --- a/src/cython/doc/persistence_graphical_tools_user.rst +++ b/src/cython/doc/persistence_graphical_tools_user.rst @@ -1,4 +1,3 @@ -======================================= Persistence graphical tools user manual ======================================= Definition diff --git a/src/cython/doc/persistent_cohomology_user.rst b/src/cython/doc/persistent_cohomology_user.rst index 69be3b86..72f1a7f7 100644 --- a/src/cython/doc/persistent_cohomology_user.rst +++ b/src/cython/doc/persistent_cohomology_user.rst @@ -1,4 +1,3 @@ -================================= Persistent cohomology user manual ================================= Definition @@ -108,7 +107,7 @@ We provide several example files: run these examples with -h for details on thei * :download:`tangential_complex_plain_homology_from_off_file_example.py <../example/tangential_complex_plain_homology_from_off_file_example.py>` Bibliography -************ +============ .. bibliography:: bibliography.bib :filter: docnames diff --git a/src/cython/doc/rips_complex_user.rst b/src/cython/doc/rips_complex_user.rst index c89409a0..f9760976 100644 --- a/src/cython/doc/rips_complex_user.rst +++ b/src/cython/doc/rips_complex_user.rst @@ -1,4 +1,3 @@ -========================= Rips complex user manual ========================= Definition @@ -60,8 +59,9 @@ Finally, it is asked to display information about the simplicial complex. repr(simplex_tree.num_simplices()) + ' simplices - ' + \ repr(simplex_tree.num_vertices()) + ' vertices.' print(result_str) + fmt = '%s -> %.2f' for filtered_value in simplex_tree.get_filtration(): - print(filtered_value) + print(fmt % tuple(filtered_value)) When launching (Rips maximal distance between 2 points is 12.0, is expanded until dimension 1 - one skeleton graph in other words), the output is: @@ -69,24 +69,24 @@ until dimension 1 - one skeleton graph in other words), the output is: .. testoutput:: Rips complex is of dimension 1 - 18 simplices - 7 vertices. - ([0], 0.0) - ([1], 0.0) - ([2], 0.0) - ([3], 0.0) - ([4], 0.0) - ([5], 0.0) - ([6], 0.0) - ([2, 3], 5.0) - ([4, 5], 5.385164807134504) - ([0, 2], 5.830951894845301) - ([0, 1], 6.082762530298219) - ([1, 3], 6.324555320336759) - ([1, 2], 6.708203932499369) - ([5, 6], 7.280109889280518) - ([2, 4], 8.94427190999916) - ([0, 3], 9.433981132056603) - ([4, 6], 9.486832980505138) - ([3, 6], 11.0) + [0] -> 0.00 + [1] -> 0.00 + [2] -> 0.00 + [3] -> 0.00 + [4] -> 0.00 + [5] -> 0.00 + [6] -> 0.00 + [2, 3] -> 5.00 + [4, 5] -> 5.39 + [0, 2] -> 5.83 + [0, 1] -> 6.08 + [1, 3] -> 6.32 + [1, 2] -> 6.71 + [5, 6] -> 7.28 + [2, 4] -> 8.94 + [0, 3] -> 9.43 + [4, 6] -> 9.49 + [3, 6] -> 11.00 Example from OFF file ^^^^^^^^^^^^^^^^^^^^^ @@ -107,32 +107,33 @@ Finally, it is asked to display information about the Rips complex. repr(simplex_tree.num_simplices()) + ' simplices - ' + \ repr(simplex_tree.num_vertices()) + ' vertices.' print(result_str) + fmt = '%s -> %.2f' for filtered_value in simplex_tree.get_filtration(): - print(filtered_value) + print(fmt % tuple(filtered_value)) the program output is: .. testoutput:: Rips complex is of dimension 1 - 18 simplices - 7 vertices. - ([0], 0.0) - ([1], 0.0) - ([2], 0.0) - ([3], 0.0) - ([4], 0.0) - ([5], 0.0) - ([6], 0.0) - ([2, 3], 5.0) - ([4, 5], 5.385164807134504) - ([0, 2], 5.830951894845301) - ([0, 1], 6.082762530298219) - ([1, 3], 6.324555320336759) - ([1, 2], 6.708203932499369) - ([5, 6], 7.280109889280518) - ([2, 4], 8.94427190999916) - ([0, 3], 9.433981132056603) - ([4, 6], 9.486832980505138) - ([3, 6], 11.0) + [0] -> 0.00 + [1] -> 0.00 + [2] -> 0.00 + [3] -> 0.00 + [4] -> 0.00 + [5] -> 0.00 + [6] -> 0.00 + [2, 3] -> 5.00 + [4, 5] -> 5.39 + [0, 2] -> 5.83 + [0, 1] -> 6.08 + [1, 3] -> 6.32 + [1, 2] -> 6.71 + [5, 6] -> 7.28 + [2, 4] -> 8.94 + [0, 3] -> 9.43 + [4, 6] -> 9.49 + [3, 6] -> 11.00 Distance matrix --------------- @@ -162,8 +163,9 @@ Finally, it is asked to display information about the simplicial complex. repr(simplex_tree.num_simplices()) + ' simplices - ' + \ repr(simplex_tree.num_vertices()) + ' vertices.' print(result_str) + fmt = '%s -> %.2f' for filtered_value in simplex_tree.get_filtration(): - print(filtered_value) + print(fmt % tuple(filtered_value)) When launching (Rips maximal distance between 2 points is 12.0, is expanded until dimension 1 - one skeleton graph in other words), the output is: @@ -171,24 +173,24 @@ until dimension 1 - one skeleton graph in other words), the output is: .. testoutput:: Rips complex is of dimension 1 - 18 simplices - 7 vertices. - ([0], 0.0) - ([1], 0.0) - ([2], 0.0) - ([3], 0.0) - ([4], 0.0) - ([5], 0.0) - ([6], 0.0) - ([2, 3], 5.0) - ([4, 5], 5.3851648071) - ([0, 2], 5.8309518948) - ([0, 1], 6.0827625303) - ([1, 3], 6.3245553203) - ([1, 2], 6.7082039325) - ([5, 6], 7.2801098893) - ([2, 4], 8.94427191) - ([0, 3], 9.4339811321) - ([4, 6], 9.4868329805) - ([3, 6], 11.0) + [0] -> 0.00 + [1] -> 0.00 + [2] -> 0.00 + [3] -> 0.00 + [4] -> 0.00 + [5] -> 0.00 + [6] -> 0.00 + [2, 3] -> 5.00 + [4, 5] -> 5.39 + [0, 2] -> 5.83 + [0, 1] -> 6.08 + [1, 3] -> 6.32 + [1, 2] -> 6.71 + [5, 6] -> 7.28 + [2, 4] -> 8.94 + [0, 3] -> 9.43 + [4, 6] -> 9.49 + [3, 6] -> 11.00 Example from csv file ^^^^^^^^^^^^^^^^^^^^^ @@ -209,29 +211,30 @@ Finally, it is asked to display information about the Rips complex. repr(simplex_tree.num_simplices()) + ' simplices - ' + \ repr(simplex_tree.num_vertices()) + ' vertices.' print(result_str) + fmt = '%s -> %.2f' for filtered_value in simplex_tree.get_filtration(): - print(filtered_value) + print(fmt % tuple(filtered_value)) the program output is: .. testoutput:: Rips complex is of dimension 1 - 18 simplices - 7 vertices. - ([0], 0.0) - ([1], 0.0) - ([2], 0.0) - ([3], 0.0) - ([4], 0.0) - ([5], 0.0) - ([6], 0.0) - ([2, 3], 5.0) - ([4, 5], 5.3851648071) - ([0, 2], 5.8309518948) - ([0, 1], 6.0827625303) - ([1, 3], 6.3245553203) - ([1, 2], 6.7082039325) - ([5, 6], 7.2801098893) - ([2, 4], 8.94427191) - ([0, 3], 9.4339811321) - ([4, 6], 9.4868329805) - ([3, 6], 11.0) + [0] -> 0.00 + [1] -> 0.00 + [2] -> 0.00 + [3] -> 0.00 + [4] -> 0.00 + [5] -> 0.00 + [6] -> 0.00 + [2, 3] -> 5.00 + [4, 5] -> 5.39 + [0, 2] -> 5.83 + [0, 1] -> 6.08 + [1, 3] -> 6.32 + [1, 2] -> 6.71 + [5, 6] -> 7.28 + [2, 4] -> 8.94 + [0, 3] -> 9.43 + [4, 6] -> 9.49 + [3, 6] -> 11.00 diff --git a/src/cython/doc/simplex_tree_user.rst b/src/cython/doc/simplex_tree_user.rst index b2efca8b..4b1dde19 100644 --- a/src/cython/doc/simplex_tree_user.rst +++ b/src/cython/doc/simplex_tree_user.rst @@ -1,4 +1,3 @@ -======================== Simplex tree user manual ======================== Definition diff --git a/src/cython/doc/tangential_complex_user.rst b/src/cython/doc/tangential_complex_user.rst index 24f68f85..03f9fea6 100644 --- a/src/cython/doc/tangential_complex_user.rst +++ b/src/cython/doc/tangential_complex_user.rst @@ -1,4 +1,3 @@ -============================== Tangential complex user manual ============================== .. include:: tangential_complex_sum.rst @@ -134,7 +133,7 @@ This example builds the Tangential complex of point set read in an OFF file. repr(st.num_vertices()) + ' vertices.' print(result_str) for filtered_value in st.get_filtration(): - print(filtered_value) + print(filtered_value[0]) The output is: @@ -142,21 +141,21 @@ The output is: Tangential contains 12 simplices - 7 vertices. Simplex tree is of dimension 1 - 15 simplices - 7 vertices. - ([0], 0.0) - ([1], 0.0) - ([0, 1], 0.0) - ([2], 0.0) - ([0, 2], 0.0) - ([1, 2], 0.0) - ([3], 0.0) - ([1, 3], 0.0) - ([4], 0.0) - ([2, 4], 0.0) - ([5], 0.0) - ([4, 5], 0.0) - ([6], 0.0) - ([3, 6], 0.0) - ([5, 6], 0.0) + [0] + [1] + [0, 1] + [2] + [0, 2] + [1, 2] + [3] + [1, 3] + [4] + [2, 4] + [5] + [4, 5] + [6] + [3, 6] + [5, 6] Example with perturbation @@ -187,8 +186,9 @@ The output is: Tangential contains 4 vertices. Inconsistencies has been fixed. + Bibliography -************ +============ .. bibliography:: bibliography.bib :filter: docnames diff --git a/src/cython/doc/witness_complex_user.rst b/src/cython/doc/witness_complex_user.rst index 07945361..aa9cbb2c 100644 --- a/src/cython/doc/witness_complex_user.rst +++ b/src/cython/doc/witness_complex_user.rst @@ -1,12 +1,8 @@ -=========================== Witness complex user manual =========================== -Definition ----------- .. include:: witness_complex_sum.rst - Definitions ----------- @@ -128,7 +124,7 @@ Here is an example of constructing a strong witness complex filtration and compu * :download:`euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py <../example/periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py>` Bibliography -************ +============ .. bibliography:: bibliography.bib :filter: docnames diff --git a/src/cython/example/rips_complex_diagram_persistence_from_distance_matrix_file_example.py b/src/cython/example/rips_complex_diagram_persistence_from_distance_matrix_file_example.py index 664eb5c4..984dbf1b 100755 --- a/src/cython/example/rips_complex_diagram_persistence_from_distance_matrix_file_example.py +++ b/src/cython/example/rips_complex_diagram_persistence_from_distance_matrix_file_example.py @@ -43,29 +43,22 @@ parser.add_argument('--no-diagram', default=False, action='store_true' , help='F args = parser.parse_args() -with open(args.file, 'r') as f: - first_line = f.readline() - if (first_line == 'OFF\n') or (first_line == 'nOFF\n'): - print("#####################################################################") - print("RipsComplex creation from distance matrix read in a csv file") - - message = "RipsComplex with max_edge_length=" + repr(args.max_edge_length) - print(message) - - rips_complex = gudhi.RipsComplex(off_file=args.file, max_edge_length=args.max_edge_length) - simplex_tree = rips_complex.create_simplex_tree(max_dimension=args.max_dimension) - - message = "Number of simplices=" + repr(simplex_tree.num_simplices()) - print(message) - - diag = simplex_tree.persistence() - - print("betti_numbers()=") - print(simplex_tree.betti_numbers()) - - if args.no_diagram == False: - gudhi.plot_persistence_diagram(diag) - else: - print(args.file, "is not a valid OFF file") - - f.close() +print("#####################################################################") +print("RipsComplex creation from distance matrix read in a csv file") + +message = "RipsComplex with max_edge_length=" + repr(args.max_edge_length) +print(message) + +rips_complex = gudhi.RipsComplex(csv_file=args.file, max_edge_length=args.max_edge_length) +simplex_tree = rips_complex.create_simplex_tree(max_dimension=args.max_dimension) + +message = "Number of simplices=" + repr(simplex_tree.num_simplices()) +print(message) + +diag = simplex_tree.persistence() + +print("betti_numbers()=") +print(simplex_tree.betti_numbers()) + +if args.no_diagram == False: + gudhi.plot_persistence_diagram(diag) |