-- cgit v1.2.3 From b06c5d015ba1524fe63997eefe7b461e06dd9966 Mon Sep 17 00:00:00 2001 From: cjamin Date: Thu, 13 Apr 2017 09:31:33 +0000 Subject: Add radius search git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/Spatial_searching-Add_radius_search@2341 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: c30c32b27b8c3c1c8dd65e45d2bdd49738794062 --- .../doc/Intro_spatial_searching.h | 2 +- .../example/example_spatial_searching.cpp | 8 +++ .../include/gudhi/Kd_tree_search.h | 57 +++++++++++++++------- src/Spatial_searching/test/test_Kd_tree_search.cpp | 8 +++ 4 files changed, 56 insertions(+), 19 deletions(-) diff --git a/src/Spatial_searching/doc/Intro_spatial_searching.h b/src/Spatial_searching/doc/Intro_spatial_searching.h index 23705378..9a3c1b65 100644 --- a/src/Spatial_searching/doc/Intro_spatial_searching.h +++ b/src/Spatial_searching/doc/Intro_spatial_searching.h @@ -46,7 +46,7 @@ namespace spatial_searching { * * \section spatial_searching_examples Example * - * This example generates 500 random points, then performs queries for nearest and farthest points using different methods. + * This example generates 500 random points, then performs radius search, and queries for nearest and farthest points using different methods. * * \include Spatial_searching/example_spatial_searching.cpp * diff --git a/src/Spatial_searching/example/example_spatial_searching.cpp b/src/Spatial_searching/example/example_spatial_searching.cpp index 14b324ae..9e6a8f32 100644 --- a/src/Spatial_searching/example/example_spatial_searching.cpp +++ b/src/Spatial_searching/example/example_spatial_searching.cpp @@ -48,5 +48,13 @@ int main(void) { for (auto ifs_iterator = ifn_range.begin(); ifs_iterator->first != 0; ++ifs_iterator) std::cout << ifs_iterator->first << " (sq. dist. = " << ifs_iterator->second << ")\n"; + // Radius search + std::cout << "Radius search:\n"; + std::vector rs_result; + points_ds.radius_search(points[45], 0.5, std::back_inserter(rs_result)); + K k; + for (auto const& p_idx : rs_result) + std::cout << p_idx << " (sq. dist. = " << k.squared_distance_d_object()(points[p_idx], points[45]) << ")\n"; + return 0; } diff --git a/src/Spatial_searching/include/gudhi/Kd_tree_search.h b/src/Spatial_searching/include/gudhi/Kd_tree_search.h index 6728d56e..374ebed6 100644 --- a/src/Spatial_searching/include/gudhi/Kd_tree_search.h +++ b/src/Spatial_searching/include/gudhi/Kd_tree_search.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -104,6 +105,7 @@ class Kd_tree_search { /// of a point P and `second` is the squared distance between P and the query point. typedef Incremental_neighbor_search INS_range; + typedef CGAL::Fuzzy_sphere Fuzzy_sphere; /// \brief Constructor /// @param[in] points Const reference to the point range. This range /// is not copied, so it should not be destroyed or modified afterwards. @@ -164,9 +166,9 @@ class Kd_tree_search { /// @param[in] k Number of nearest points to search. /// @param[in] sorted Indicates if the computed sequence of k-nearest neighbors needs to be sorted. /// @param[in] eps Approximation factor. - /// @return A range containing the k-nearest neighbors. - KNS_range query_k_nearest_neighbors(const - Point &p, + /// @return A range (whose `value_type` is `std::size_t`) containing the k-nearest neighbors. + KNS_range query_k_nearest_neighbors( + Point const& p, unsigned int k, bool sorted = true, FT eps = FT(0)) const { @@ -179,8 +181,7 @@ class Kd_tree_search { k, eps, true, - CGAL::Distance_adapter >( - std::begin(m_points)), sorted); + Orthogonal_distance(std::begin(m_points)), sorted); return search; } @@ -188,10 +189,11 @@ class Kd_tree_search { /// \brief Search incrementally for the nearest neighbors from a query point. /// @param[in] p The query point. /// @param[in] eps Approximation factor. - /// @return A range containing the neighbors sorted by their distance to p. + /// @return A range (whose `value_type` is `std::size_t`) containing the + /// neighbors sorted by their distance to p. /// All the neighbors are not computed by this function, but they will be /// computed incrementally when the iterator on the range is incremented. - INS_range query_incremental_nearest_neighbors(const Point &p, FT eps = FT(0)) const { + INS_range query_incremental_nearest_neighbors(Point const& p, FT eps = FT(0)) const { // Initialize the search structure, and search all N points // Note that we need to pass the Distance explicitly since it needs to // know the property map @@ -200,8 +202,7 @@ class Kd_tree_search { p, eps, true, - CGAL::Distance_adapter >( - std::begin(m_points)) ); + Orthogonal_distance(std::begin(m_points)) ); return search; } @@ -211,9 +212,9 @@ class Kd_tree_search { /// @param[in] k Number of farthest points to search. /// @param[in] sorted Indicates if the computed sequence of k-farthest neighbors needs to be sorted. /// @param[in] eps Approximation factor. - /// @return A range containing the k-farthest neighbors. - KNS_range query_k_farthest_neighbors(const - Point &p, + /// @return A range (whose `value_type` is `std::size_t`) containing the k-farthest neighbors. + KNS_range query_k_farthest_neighbors( + Point const& p, unsigned int k, bool sorted = true, FT eps = FT(0)) const { @@ -226,8 +227,7 @@ class Kd_tree_search { k, eps, false, - CGAL::Distance_adapter >( - std::begin(m_points)), sorted); + Orthogonal_distance(std::begin(m_points)), sorted); return search; } @@ -235,10 +235,11 @@ class Kd_tree_search { /// \brief Search incrementally for the farthest neighbors from a query point. /// @param[in] p The query point. /// @param[in] eps Approximation factor. - /// @return A range containing the neighbors sorted by their distance to p. + /// @return A range (whose `value_type` is `std::size_t`) + /// containing the neighbors sorted by their distance to p. /// All the neighbors are not computed by this function, but they will be /// computed incrementally when the iterator on the range is incremented. - INS_range query_incremental_farthest_neighbors(const Point &p, FT eps = FT(0)) const { + INS_range query_incremental_farthest_neighbors(Point const& p, FT eps = FT(0)) const { // Initialize the search structure, and search all N points // Note that we need to pass the Distance explicitly since it needs to // know the property map @@ -247,12 +248,32 @@ class Kd_tree_search { p, eps, false, - CGAL::Distance_adapter >( - std::begin(m_points)) ); + Orthogonal_distance(std::begin(m_points)) ); return search; } + /// \brief Search for all the neighbors in a ball. + /// @param[in] p The query point. + /// @param[in] radius The search radius + /// @param[out] it The points that lie inside the sphere of center `p` and radius `radius`. + /// The `value_type` of the iterator must be `Point`. + /// @param[in] eps Approximation factor. + template + void radius_search( + Point const& p, + FT radius, + OutputIterator it, + FT eps = FT(0)) const { + + m_tree.search(it, Fuzzy_sphere(p, radius, eps, m_tree.traits())); + } + + int tree_depth() const + { + return m_tree.root()->depth(); + } + private: Point_range const& m_points; Tree m_tree; diff --git a/src/Spatial_searching/test/test_Kd_tree_search.cpp b/src/Spatial_searching/test/test_Kd_tree_search.cpp index 0ef22023..f79114bc 100644 --- a/src/Spatial_searching/test/test_Kd_tree_search.cpp +++ b/src/Spatial_searching/test/test_Kd_tree_search.cpp @@ -109,4 +109,12 @@ BOOST_AUTO_TEST_CASE(test_Kd_tree_search) { // Same result for KFN and IFN? BOOST_CHECK(kfn_result == ifn_result); + + // Test radius search + Point rs_q(rd.get_double(-1., 1), rd.get_double(-1., 1), rd.get_double(-1., 1), rd.get_double(-1., 1)); + std::vector rs_result; + points_ds.radius_search(rs_q, 0.5, std::back_inserter(rs_result)); + K k; + for (auto const& p_idx : rs_result) + BOOST_CHECK(k.squared_distance_d_object()(points[p_idx], rs_q) <= 0.5); } -- cgit v1.2.3 From 2efd0154ec5299a175ea2633db0dd739a620762d Mon Sep 17 00:00:00 2001 From: cjamin Date: Mon, 24 Apr 2017 15:19:09 +0000 Subject: Fix doc of the output iterator git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/Spatial_searching-Add_radius_search@2378 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: dda01f1c99debbf21ccd57cb961055dfe34036a8 --- src/Spatial_searching/include/gudhi/Kd_tree_search.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Spatial_searching/include/gudhi/Kd_tree_search.h b/src/Spatial_searching/include/gudhi/Kd_tree_search.h index 374ebed6..c4a15876 100644 --- a/src/Spatial_searching/include/gudhi/Kd_tree_search.h +++ b/src/Spatial_searching/include/gudhi/Kd_tree_search.h @@ -257,7 +257,7 @@ class Kd_tree_search { /// @param[in] p The query point. /// @param[in] radius The search radius /// @param[out] it The points that lie inside the sphere of center `p` and radius `radius`. - /// The `value_type` of the iterator must be `Point`. + /// Note: `it` is used this way: `*it++ = each_point`. /// @param[in] eps Approximation factor. template void radius_search( -- cgit v1.2.3 From 4e1c05f5ecf26322560c40c7517a3ff32cfeb651 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 16 May 2017 11:22:05 +0000 Subject: Add MathJax for distribution git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/doxygen_using_mathjax@2432 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: c0f73996dfdfe217ae2dfc2250e7866d680ae1f7 --- src/common/doc/MathJax.COPYRIGHT | 55 ++++++++++++++++++++++++++++++++++++++++ src/common/doc/MathJax.js | 53 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 src/common/doc/MathJax.COPYRIGHT create mode 100644 src/common/doc/MathJax.js diff --git a/src/common/doc/MathJax.COPYRIGHT b/src/common/doc/MathJax.COPYRIGHT new file mode 100644 index 00000000..077d6dc5 --- /dev/null +++ b/src/common/doc/MathJax.COPYRIGHT @@ -0,0 +1,55 @@ +Apache License + +Version 2.0, January 2004 + +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + + You must give any other recipients of the Work or Derivative Works a copy of this License; and + You must cause any modified files to carry prominent notices stating that You changed the files; and + You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and + If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + + You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + diff --git a/src/common/doc/MathJax.js b/src/common/doc/MathJax.js new file mode 100644 index 00000000..35e1994e --- /dev/null +++ b/src/common/doc/MathJax.js @@ -0,0 +1,53 @@ +(function () { + var newMathJax = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js'; + var oldMathJax = 'cdn.mathjax.org/mathjax/latest/MathJax.js'; + + var replaceScript = function (script, src) { + // + // Make redirected script + // + var newScript = document.createElement('script'); + newScript.src = newMathJax + src.replace(/.*?(\?|$)/, '$1'); + // + // Move onload and onerror handlers to new script + // + newScript.onload = script.onload; + newScript.onerror = script.onerror; + script.onload = script.onerror = null; + // + // Move any content (old-style configuration scripts) + // + while (script.firstChild) newScript.appendChild(script.firstChild); + // + // Copy script id + // + if (script.id != null) newScript.id = script.id; + // + // Replace original script with new one + // + script.parentNode.replaceChild(newScript, script); + // + // Issue a console warning + // + console.warn('WARNING: cdn.mathjax.org has been retired. Check https://www.mathjax.org/cdn-shutting-down/ for migration tips.') + } + + if (document.currentScript) { + var script = document.currentScript; + replaceScript(script, script.src); + } else { + // + // Look for current script by searching for one with the right source + // + var n = oldMathJax.length; + var scripts = document.getElementsByTagName('script'); + for (var i = 0; i < scripts.length; i++) { + var script = scripts[i]; + var src = (script.src || '').replace(/.*?:\/\//,''); + if (src.substr(0, n) === oldMathJax) { + replaceScript(script, src); + break; + } + } + } +})(); \ No newline at end of file -- cgit v1.2.3 From d0474601cbd24227556754ab34d4d48d574eeb3a Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 16 May 2017 11:55:09 +0000 Subject: Modify Doxyfile to make it work with distributed MathJax.js git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/doxygen_using_mathjax@2433 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 386ef39799695204b98d43b5a2f36a1a9e91f04e --- src/Doxyfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Doxyfile b/src/Doxyfile index 9cd3894c..2fecf5fb 100644 --- a/src/Doxyfile +++ b/src/Doxyfile @@ -1450,14 +1450,14 @@ MATHJAX_FORMAT = HTML-CSS # The default value is: http://cdn.mathjax.org/mathjax/latest. # This tag requires that the tag USE_MATHJAX is set to YES. -MATHJAX_RELPATH = http://gudhi.gforge.inria.fr/doc +MATHJAX_RELPATH = ../common # The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax # extension names that should be enabled during MathJax rendering. For example # MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols # This tag requires that the tag USE_MATHJAX is set to YES. -MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols TeX/algorithm TeX/algpseudocode +MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols # The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces # of code that will be used on startup of the MathJax code. See the MathJax site @@ -1612,7 +1612,7 @@ PAPER_TYPE = a4 # If left blank no extra packages will be included. # This tag requires that the tag GENERATE_LATEX is set to YES. -EXTRA_PACKAGES = amsfonts amsmath amssymb algorithm algpseudocode +EXTRA_PACKAGES = amsfonts amsmath amssymb # The LATEX_HEADER tag can be used to specify a personal LaTeX header for the # generated LaTeX document. The header should contain everything until the first -- cgit v1.2.3 -- cgit v1.2.3 From e7162cf121d5e1619ca4b7b54b9cef4d9ff1c9f7 Mon Sep 17 00:00:00 2001 From: cjamin Date: Tue, 16 May 2017 14:25:19 +0000 Subject: Add read_persistence_diagram_from_file git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/read_persistence_from_file@2439 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 026fbb0528343a15a46935ded3aaf13297afeff5 --- src/common/include/gudhi/reader_utils.h | 38 ++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index 97a87edd..ceee8daf 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -2,7 +2,7 @@ * (Geometric Understanding in Higher Dimensions) is a generic C++ * library for computational topology. * - * Author(s): Clement Maria, Pawel Dlotko + * Author(s): Clement Maria, Pawel Dlotko, Clement Jamin * * Copyright (C) 2014 INRIA * @@ -295,4 +295,40 @@ std::vector< std::vector< Filtration_value > > read_lower_triangular_matrix_from return result; } // read_lower_triangular_matrix_from_csv_file +/** +Reads a file containing persistance intervals. +Each line might contain 2, 3 or 4 values: [field] [dimension] birth death +**/ + +std::vector< std::pair > read_persistence_diagram_from_file(std::string const& filename) { + + std::vector< std::pair > result; + + std::ifstream in; + in.open(filename); + if (!in.is_open()) { +#ifdef DEBUG_TRACES + std::cerr << "File \"" << filename << "\" does not exist.\n"; +#endif // DEBUG_TRACES + return result; + } + + std::string line; + while (!in.eof()) { + getline(in, line); + if (line.length() != 0 && line[0] != '#') { + double numbers[4]; + int n = sscanf(line.c_str(), "%lf %lf %lf %lf", &numbers[0], &numbers[1], &numbers[2], &numbers[3]); + result.push_back(std::make_pair(numbers[n - 2], numbers[n - 1])); +#ifdef DEBUG_TRACES + std::cerr << numbers[n - 2] << " - " << numbers[n - 1] << "\n"; +#endif // DEBUG_TRACES + } + } + + in.close(); + return result; +} // read_diagram_from_file + + #endif // READER_UTILS_H_ -- cgit v1.2.3 From 884d91ed81876af1a3d986843253acaaff443834 Mon Sep 17 00:00:00 2001 From: cjamin Date: Tue, 16 May 2017 14:26:11 +0000 Subject: Use read_persistence_diagram_from_file in this example git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/read_persistence_from_file@2440 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: cb5cbba3f968c6cd16025250076bbe1df4f2e11a --- .../example/bottleneck_read_file_example.cpp | 31 +++------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp b/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp index bde05825..e50a243d 100644 --- a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp +++ b/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp @@ -21,8 +21,10 @@ */ #define CGAL_HAS_THREADS +#define DEBUG_TRACES #include +#include #include #include #include // for pair @@ -30,39 +32,14 @@ #include #include -std::vector< std::pair > read_diagram_from_file(const char* filename) { - std::ifstream in; - in.open(filename); - std::vector< std::pair > result; - if (!in.is_open()) { - std::cerr << "File : " << filename << " do not exist. The program will now terminate \n"; - throw "File do not exist \n"; - } - - std::string line; - while (!in.eof()) { - getline(in, line); - if (line.length() != 0) { - std::stringstream lineSS; - lineSS << line; - double beginn, endd; - lineSS >> beginn; - lineSS >> endd; - result.push_back(std::make_pair(beginn, endd)); - } - } - in.close(); - return result; -} // read_diagram_from_file - int main(int argc, char** argv) { if (argc < 3) { std::cout << "To run this program please provide as an input two files with persistence diagrams. Each file " << "should contain a birth-death pair per line. Third, optional parameter is an error bound on a bottleneck" << " distance (set by default to zero). The program will now terminate \n"; } - std::vector< std::pair< double, double > > diag1 = read_diagram_from_file(argv[1]); - std::vector< std::pair< double, double > > diag2 = read_diagram_from_file(argv[2]); + std::vector< std::pair< double, double > > diag1 = read_persistence_diagram_from_file(argv[1]); + std::vector< std::pair< double, double > > diag2 = read_persistence_diagram_from_file(argv[2]); double tolerance = 0.; if (argc == 4) { tolerance = atof(argv[3]); -- cgit v1.2.3 -- cgit v1.2.3 From d6bb19de457fa74c84dbd6d8afa63074fefb4552 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 18 May 2017 08:47:16 +0000 Subject: Modify the way cmake handles utilities, examples, test and benchmarks with new options to activate/desactivate them. Move hypergenerator as a common utility. Move random point generation from hypergenerator in src/common/include/gudhi/random_point_generators.h git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cmake_modules_for_gudhi@2442 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: e2d13e4b0c09455fb604b684f6d71530352271eb --- CMakeLists.txt | 76 +++------ data/points/generator/CMakeLists.txt | 15 -- data/points/generator/README | 29 ---- data/points/generator/hypergenerator.cpp | 133 --------------- src/CMakeLists.txt | 34 ++-- src/cmake/modules/GUDHI_modules.cmake | 43 +++++ src/cmake/modules/GUDHI_user_version_target.cmake | 90 ++++++++++ src/cmake/modules/GUDHI_user_version_target.txt | 91 ---------- src/common/include/gudhi/random_point_generators.h | 32 ++++ src/common/utilities/CMakeLists.txt | 15 ++ src/common/utilities/README | 19 +++ src/common/utilities/hypergenerator.cpp | 189 +++++++++++++++++++++ 12 files changed, 430 insertions(+), 336 deletions(-) delete mode 100644 data/points/generator/CMakeLists.txt delete mode 100644 data/points/generator/hypergenerator.cpp create mode 100644 src/cmake/modules/GUDHI_modules.cmake create mode 100644 src/cmake/modules/GUDHI_user_version_target.cmake delete mode 100644 src/cmake/modules/GUDHI_user_version_target.txt create mode 100644 src/common/utilities/CMakeLists.txt create mode 100644 src/common/utilities/README create mode 100644 src/common/utilities/hypergenerator.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 324f8648..360eb87a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,10 +10,6 @@ message("CMAKE_MODULE_PATH = ${CMAKE_MODULE_PATH}") enable_testing() -# For "make user_version" -include("${CMAKE_MODULE_PATH}/GUDHI_user_version_target.txt") -# For "make doxygen" -include(GUDHI_doxygen_target) # This variable is used by Cython CMakeLists.txt to know its path set(GUDHI_CYTHON_PATH "src/cython") # For third parties libraries management - To be done last as CGAL updates CMAKE_MODULE_PATH @@ -38,54 +34,34 @@ if (DEBUG_TRACES) add_definitions(-DDEBUG_TRACES) endif() -include_directories(src/common/include/) -include_directories(src/Alpha_complex/include/) -include_directories(src/Bitmap_cubical_complex/include/) -include_directories(src/Bottleneck_distance/include/) -include_directories(src/Contraction/include/) -include_directories(src/Hasse_complex/include/) -include_directories(src/Persistent_cohomology/include/) -include_directories(src/Rips_complex/include/) -include_directories(src/Simplex_tree/include/) -include_directories(src/Skeleton_blocker/include/) -include_directories(src/Spatial_searching/include/) -include_directories(src/Subsampling/include/) -include_directories(src/Tangential_complex/include/) -include_directories(src/Witness_complex/include/) +# Modules list can be found in CMAKE_MODULE_PATH/GUDHI_modules.cmake +include(GUDHI_modules) -add_subdirectory(src/common/example) -add_subdirectory(src/common/test) -add_subdirectory(src/Simplex_tree/test) -add_subdirectory(src/Simplex_tree/example) -add_subdirectory(src/Persistent_cohomology/test) -add_subdirectory(src/Persistent_cohomology/example) -add_subdirectory(src/Persistent_cohomology/benchmark) -add_subdirectory(src/Skeleton_blocker/test) -add_subdirectory(src/Skeleton_blocker/example) -add_subdirectory(src/Contraction/example) -add_subdirectory(src/Witness_complex/test) -add_subdirectory(src/Witness_complex/example) -add_subdirectory(src/Bitmap_cubical_complex/test) -add_subdirectory(src/Bitmap_cubical_complex/example) -add_subdirectory(src/Alpha_complex/example) -add_subdirectory(src/Alpha_complex/test) -add_subdirectory(src/Spatial_searching/example) -add_subdirectory(src/Spatial_searching/test) -add_subdirectory(src/Subsampling/example) -add_subdirectory(src/Subsampling/test) -add_subdirectory(src/Tangential_complex/example) -add_subdirectory(src/Tangential_complex/test) -add_subdirectory(src/Tangential_complex/benchmark) -add_subdirectory(src/Bottleneck_distance/example) -add_subdirectory(src/Bottleneck_distance/test) -add_subdirectory(src/Bottleneck_distance/benchmark) -add_subdirectory(src/Rips_complex/example) -add_subdirectory(src/Rips_complex/test) +# Include module headers +foreach(GUDHI_MODULE ${GUDHI_MODULES}) + if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/src/${GUDHI_MODULE}/include/) + include_directories(src/${GUDHI_MODULE}/include/) + endif() +endforeach() -# data points generator -add_subdirectory(data/points/generator) +# Include module CMake subdirectories +# GUDHI_SUB_DIRECTORIES is managed in CMAKE_MODULE_PATH/GUDHI_modules.cmake +foreach(GUDHI_MODULE ${GUDHI_MODULES}) + foreach(GUDHI_SUB_DIRECTORY ${GUDHI_SUB_DIRECTORIES}) + if(EXISTS ${CMAKE_SOURCE_DIR}/src/${GUDHI_MODULE}/${GUDHI_SUB_DIRECTORY}/CMakeLists.txt) + add_subdirectory(src/${GUDHI_MODULE}/${GUDHI_SUB_DIRECTORY}/) + endif() + endforeach() +endforeach() add_subdirectory(src/GudhUI) -# specific for cython module -add_subdirectory(${GUDHI_CYTHON_PATH}) +if (NOT WITHOUT_GUDHI_PYTHON) + # specific for cython module + add_subdirectory(${GUDHI_CYTHON_PATH}) +endif() + +# For "make user_version" - Requires GUDHI_modules to be performed +include(GUDHI_user_version_target) +# For "make doxygen" - Requires GUDHI_user_version_target to be performed +include(GUDHI_doxygen_target) diff --git a/data/points/generator/CMakeLists.txt b/data/points/generator/CMakeLists.txt deleted file mode 100644 index 88d377a7..00000000 --- a/data/points/generator/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -cmake_minimum_required(VERSION 2.6) -project(data_points_generator) - -if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.6.0) - add_executable ( data_points_generator hypergenerator.cpp ) - target_link_libraries(data_points_generator ${Boost_SYSTEM_LIBRARY}) - add_test(NAME data_points_generator_on_sphere_1000_3_15.2 COMMAND $ - "on" "sphere" "onSphere.off" "1000" "3" "15.2") - add_test(NAME data_points_generator_in_sphere_100_2 COMMAND $ - "in" "sphere" "inSphere.off" "100" "2") - - # on cube is not available in CGAL - add_test(NAME data_points_generator_in_cube_10000_3_5.8 COMMAND $ - "in" "cube" "inCube.off" "10000" "3" "5.8") -endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.6.0) diff --git a/data/points/generator/README b/data/points/generator/README index 951bcfe1..3183a51f 100644 --- a/data/points/generator/README +++ b/data/points/generator/README @@ -1,32 +1,3 @@ -=========================== C++ generators ===================================== - -To build the C++ generators, run in a Terminal: - -cd /path-to-gudhi/ -cmake . -cd /path-to-data-generator/ -make - -======================= data_points_generator ================================== - -Example of use : - -*** Hyper sphere|cube generator - -./data_points_generator on sphere onSphere.off 1000 3 15.2 - - => generates a onSphere.off file with 1000 points randomized on a sphere of dimension 3 and radius 15.2 - -./data_points_generator in sphere inSphere.off 100 2 - - => generates a inSphere.off file with 100 points randomized in a sphere of dimension 2 (circle) and radius 1.0 (default) - -./data_points_generator in cube inCube.off 10000 3 5.8 - - => generates a inCube.off file with 10000 points randomized in a cube of dimension 3 and side 5.8 - -!! Warning: hypegenerator on cube is not available !! - ===================== aurelien_alvarez_surfaces_in_R8 ========================== This generator is written in Python. diff --git a/data/points/generator/hypergenerator.cpp b/data/points/generator/hypergenerator.cpp deleted file mode 100644 index 5831de18..00000000 --- a/data/points/generator/hypergenerator.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* This file is part of the Gudhi Library. The Gudhi library - * (Geometric Understanding in Higher Dimensions) is a generic C++ - * library for computational topology. - * - * Author(s): Vincent Rouvreau - * - * Copyright (C) 2014 INRIA Saclay (France) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include - -#include -#include -#include -#include // for std::ofstream -#include - -typedef CGAL::Epick_d< CGAL::Dynamic_dimension_tag > K; -typedef K::Point_d Point; - -void usage(char * const progName) { - std::cerr << "Usage: " << progName << " in|on sphere|cube off_file_name points_number[integer > 0] " << - "dimension[integer > 1] radius[double > 0.0 | default = 1.0]" << std::endl; - exit(-1); -} - -int main(int argc, char **argv) { - // program args management - if ((argc != 6) && (argc != 7)) { - std::cerr << "Error: Number of arguments (" << argc << ") is not correct" << std::endl; - usage(argv[0]); - } - - int points_number = atoi(argv[4]); - if (points_number <= 0) { - std::cerr << "Error: " << argv[4] << " is not correct" << std::endl; - usage(argv[0]); - } - - int dimension = atoi(argv[5]); - if (dimension <= 0) { - std::cerr << "Error: " << argv[5] << " is not correct" << std::endl; - usage(argv[0]); - } - - double radius = 1.0; - if (argc == 7) { - radius = atof(argv[6]); - if (radius <= 0.0) { - std::cerr << "Error: " << argv[6] << " is not correct" << std::endl; - usage(argv[0]); - } - } - - bool in = false; - if (strcmp(argv[1], "in") == 0) { - in = true; - } else if (strcmp(argv[1], "on") != 0) { - std::cerr << "Error: " << argv[1] << " is not correct" << std::endl; - usage(argv[0]); - } - - bool sphere = false; - if (memcmp(argv[2], "sphere", sizeof("sphere")) == 0) { - sphere = true; - } else if (memcmp(argv[2], "cube", sizeof("cube")) != 0) { - std::cerr << "Error: " << argv[2] << " is not correct" << std::endl; - usage(argv[0]); - } - - std::ofstream diagram_out(argv[3]); - if (dimension == 3) { - diagram_out << "OFF" << std::endl; - diagram_out << points_number << " 0 0" << std::endl; - } else { - diagram_out << "nOFF" << std::endl; - diagram_out << dimension << " " << points_number << " 0 0" << std::endl; - } - - if (diagram_out.is_open()) { - // Instanciate a random point generator - CGAL::Random rng(0); - // Generate "points_number" random points in a vector - std::vector points; - if (in) { - if (sphere) { - CGAL::Random_points_in_ball_d rand_it(dimension, radius, rng); - CGAL::cpp11::copy_n(rand_it, points_number, std::back_inserter(points)); - } else { - CGAL::Random_points_in_cube_d rand_it(dimension, radius, rng); - CGAL::cpp11::copy_n(rand_it, points_number, std::back_inserter(points)); - } - } else { // means "on" - if (sphere) { - CGAL::Random_points_on_sphere_d rand_it(dimension, radius, rng); - CGAL::cpp11::copy_n(rand_it, points_number, std::back_inserter(points)); - } else { - std::cerr << "Sorry: on cube is not available" << std::endl; - usage(argv[0]); - } - } - - for (auto thePoint : points) { - int i = 0; - for (; i < dimension - 1; i++) { - diagram_out << thePoint[i] << " "; - } - diagram_out << thePoint[i] << std::endl; // last point + Carriage Return - } - } else { - std::cerr << "Error: " << argv[3] << " cannot be opened" << std::endl; - usage(argv[0]); - } - - return 0; -} - diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ebcb6888..77a03c17 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,6 +7,9 @@ enable_testing() list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/") +# To be done first - Modules list can be found in CMAKE_MODULE_PATH/GUDHI_modules.cmake +include(GUDHI_modules) + # For "make doxygen" set(GUDHI_USER_VERSION_DIR ${CMAKE_SOURCE_DIR}) include(GUDHI_doxygen_target) @@ -39,27 +42,22 @@ endif() # Gudhi compilation part include_directories(include) -add_subdirectory(example/common) -add_subdirectory(example/Simplex_tree) -add_subdirectory(example/Persistent_cohomology) -add_subdirectory(example/Skeleton_blocker) -add_subdirectory(example/Contraction) -add_subdirectory(example/Bitmap_cubical_complex) -add_subdirectory(example/Witness_complex) -add_subdirectory(example/Alpha_complex) -add_subdirectory(example/Rips_complex) -add_subdirectory(example/Spatial_searching) -add_subdirectory(example/Subsampling) -add_subdirectory(example/Tangential_complex) -add_subdirectory(example/Bottleneck_distance) - -# data points generator -add_subdirectory(data/points/generator) +# Include module CMake subdirectories +# GUDHI_SUB_DIRECTORIES is managed in CMAKE_MODULE_PATH/GUDHI_modules.cmake +foreach(GUDHI_MODULE ${GUDHI_MODULES}) + foreach(GUDHI_SUB_DIRECTORY ${GUDHI_SUB_DIRECTORIES}) + if(EXISTS ${CMAKE_SOURCE_DIR}/${GUDHI_SUB_DIRECTORY}/${GUDHI_MODULE}/CMakeLists.txt) + add_subdirectory(src/${GUDHI_MODULE}/${GUDHI_SUB_DIRECTORY}/) + endif(EXISTS ${CMAKE_SOURCE_DIR}/${GUDHI_SUB_DIRECTORY}/${GUDHI_MODULE}/CMakeLists.txt) + endforeach(GUDHI_SUB_DIRECTORY ${GUDHI_SUB_DIRECTORIES}) +endforeach(GUDHI_MODULE ${GUDHI_MODULES}) add_subdirectory(GudhUI) -# specific for cython module -add_subdirectory(${GUDHI_CYTHON_PATH}) +if (NOT WITHOUT_GUDHI_PYTHON) + # specific for cython module + add_subdirectory(${GUDHI_CYTHON_PATH}) +endif() #--------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------- diff --git a/src/cmake/modules/GUDHI_modules.cmake b/src/cmake/modules/GUDHI_modules.cmake new file mode 100644 index 00000000..6a26d7bf --- /dev/null +++ b/src/cmake/modules/GUDHI_modules.cmake @@ -0,0 +1,43 @@ +# A function to add a new module in GUDHI + +set(GUDHI_MODULES "") +function(add_gudhi_module file_path) + set(GUDHI_MODULES ${GUDHI_MODULES} ${file_path} PARENT_SCOPE) +endfunction(add_gudhi_module) + +# Add your new module in the list, order is not important + +add_gudhi_module(common) +add_gudhi_module(Alpha_complex) +add_gudhi_module(Bitmap_cubical_complex) +add_gudhi_module(Bottleneck_distance) +add_gudhi_module(Contraction) +add_gudhi_module(Hasse_complex) +add_gudhi_module(Persistent_cohomology) +add_gudhi_module(Rips_complex) +add_gudhi_module(Simplex_tree) +add_gudhi_module(Skeleton_blocker) +add_gudhi_module(Spatial_searching) +add_gudhi_module(Subsampling) +add_gudhi_module(Tangential_complex) +add_gudhi_module(Witness_complex) + +# message("++ GUDHI_MODULES list is:\"${GUDHI_MODULES}\"") + +if (WITH_GUDHI_BENCHMARK) + set(GUDHI_SUB_DIRECTORIES "${GUDHI_SUB_DIRECTORIES};benchmark") +endif() +if (WITH_GUDHI_EXAMPLE) + set(GUDHI_SUB_DIRECTORIES "${GUDHI_SUB_DIRECTORIES};example") +endif() +if (NOT WITHOUT_GUDHI_TEST) + set(GUDHI_SUB_DIRECTORIES "${GUDHI_SUB_DIRECTORIES};test") +endif() +if (NOT WITHOUT_GUDHI_UTILITIES) + set(GUDHI_SUB_DIRECTORIES "${GUDHI_SUB_DIRECTORIES};utilities") +endif() + +message("++ GUDHI_SUB_DIRECTORIES list is:\"${GUDHI_SUB_DIRECTORIES}\"") + + + diff --git a/src/cmake/modules/GUDHI_user_version_target.cmake b/src/cmake/modules/GUDHI_user_version_target.cmake new file mode 100644 index 00000000..a764e88a --- /dev/null +++ b/src/cmake/modules/GUDHI_user_version_target.cmake @@ -0,0 +1,90 @@ +# Some functionnalities requires CMake 2.8.11 minimum +if (NOT CMAKE_VERSION VERSION_LESS 2.8.11) + + # Definition of the custom target user_version + add_custom_target(user_version) + + if(DEFINED USER_VERSION_DIR) + # set the GUDHI_USER_VERSION_DIR with USER_VERSION_DIR defined by the user + set(GUDHI_USER_VERSION_DIR ${CMAKE_CURRENT_BINARY_DIR}/${USER_VERSION_DIR}) + else() + # set the GUDHI_USER_VERSION_DIR with timestamp and Gudhi version number + string(TIMESTAMP DATE_AND_TIME "%Y-%m-%d-%H-%M-%S") + set(GUDHI_USER_VERSION_DIR ${CMAKE_CURRENT_BINARY_DIR}/${DATE_AND_TIME}_GUDHI_${GUDHI_VERSION}) + endif() + + set(GUDHI_DOXYGEN_DEPENDENCY user_version) + + add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E + make_directory ${GUDHI_USER_VERSION_DIR} + COMMENT "user_version creation in ${GUDHI_USER_VERSION_DIR}") + + add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E + copy ${CMAKE_SOURCE_DIR}/Conventions.txt ${GUDHI_USER_VERSION_DIR}/Conventions.txt) + add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E + copy ${CMAKE_SOURCE_DIR}/README ${GUDHI_USER_VERSION_DIR}/README) + add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E + copy ${CMAKE_SOURCE_DIR}/COPYING ${GUDHI_USER_VERSION_DIR}/COPYING) + add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E + copy ${CMAKE_SOURCE_DIR}/src/CMakeLists.txt ${GUDHI_USER_VERSION_DIR}/CMakeLists.txt) + add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E + copy ${CMAKE_SOURCE_DIR}/src/Doxyfile ${GUDHI_USER_VERSION_DIR}/Doxyfile) + add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E + copy ${CMAKE_SOURCE_DIR}/src/GUDHIConfigVersion.cmake.in ${GUDHI_USER_VERSION_DIR}/GUDHIConfigVersion.cmake.in) + add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E + copy ${CMAKE_SOURCE_DIR}/src/GUDHIConfig.cmake.in ${GUDHI_USER_VERSION_DIR}/GUDHIConfig.cmake.in) + add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E + copy ${CMAKE_SOURCE_DIR}/CMakeGUDHIVersion.txt ${GUDHI_USER_VERSION_DIR}/CMakeGUDHIVersion.txt) + + add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E + copy_directory ${CMAKE_SOURCE_DIR}/biblio ${GUDHI_USER_VERSION_DIR}/biblio) + add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E + copy_directory ${CMAKE_SOURCE_DIR}/src/cython ${GUDHI_USER_VERSION_DIR}/cython) + add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E + copy_directory ${CMAKE_SOURCE_DIR}/data ${GUDHI_USER_VERSION_DIR}/data) + add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E + copy_directory ${CMAKE_SOURCE_DIR}/src/cmake ${GUDHI_USER_VERSION_DIR}/cmake) + add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E + copy_directory ${CMAKE_SOURCE_DIR}/src/GudhUI ${GUDHI_USER_VERSION_DIR}/GudhUI) + + set(GUDHI_DIRECTORIES "doc;example;concept") + set(GUDHI_INCLUDE_DIRECTORIES "include/gudhi;include/gudhi_patches") + + foreach(GUDHI_MODULE ${GUDHI_MODULES}) + foreach(GUDHI_DIRECTORY ${GUDHI_DIRECTORIES}) + # Find files + file(GLOB GUDHI_FILES ${CMAKE_SOURCE_DIR}/src/${GUDHI_MODULE}/${GUDHI_DIRECTORY}/*) + + foreach(GUDHI_FILE ${GUDHI_FILES}) + get_filename_component(GUDHI_FILE_NAME ${GUDHI_FILE} NAME) + # GUDHI_FILE can be a file or a directory + if(IS_DIRECTORY ${GUDHI_FILE}) + add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E + copy_directory ${GUDHI_FILE} ${GUDHI_USER_VERSION_DIR}/${GUDHI_DIRECTORY}/${GUDHI_MODULE}/${GUDHI_FILE_NAME}) + else() + add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E + copy ${GUDHI_FILE} ${GUDHI_USER_VERSION_DIR}/${GUDHI_DIRECTORY}/${GUDHI_MODULE}/${GUDHI_FILE_NAME}) + endif() + endforeach() + endforeach(GUDHI_DIRECTORY ${GUDHI_DIRECTORIES}) + + foreach(GUDHI_INCLUDE_DIRECTORY ${GUDHI_INCLUDE_DIRECTORIES}) + # include files + file(GLOB GUDHI_INCLUDE_FILES ${CMAKE_SOURCE_DIR}/src/${GUDHI_MODULE}/${GUDHI_INCLUDE_DIRECTORY}/*) + + foreach(GUDHI_INCLUDE_FILE ${GUDHI_INCLUDE_FILES}) + get_filename_component(GUDHI_INCLUDE_FILE_NAME ${GUDHI_INCLUDE_FILE} NAME) + # GUDHI_INCLUDE_FILE can be a file or a directory + if(IS_DIRECTORY ${GUDHI_INCLUDE_FILE}) + add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E + copy_directory ${GUDHI_INCLUDE_FILE} ${GUDHI_USER_VERSION_DIR}/${GUDHI_INCLUDE_DIRECTORY}/${GUDHI_INCLUDE_FILE_NAME}) + else() + add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E + copy ${GUDHI_INCLUDE_FILE} ${GUDHI_USER_VERSION_DIR}/${GUDHI_INCLUDE_DIRECTORY}/${GUDHI_INCLUDE_FILE_NAME}) + endif() + endforeach() + endforeach(GUDHI_INCLUDE_DIRECTORY ${GUDHI_INCLUDE_DIRECTORIES}) + + endforeach(GUDHI_MODULE ${GUDHI_MODULES}) + +endif() diff --git a/src/cmake/modules/GUDHI_user_version_target.txt b/src/cmake/modules/GUDHI_user_version_target.txt deleted file mode 100644 index ca6bcd34..00000000 --- a/src/cmake/modules/GUDHI_user_version_target.txt +++ /dev/null @@ -1,91 +0,0 @@ -# Some functionnalities requires CMake 2.8.11 minimum -if (NOT CMAKE_VERSION VERSION_LESS 2.8.11) - - # Definition of the custom target user_version - add_custom_target(user_version) - - if(DEFINED USER_VERSION_DIR) - # set the GUDHI_USER_VERSION_DIR with USER_VERSION_DIR defined by the user - set(GUDHI_USER_VERSION_DIR ${CMAKE_CURRENT_BINARY_DIR}/${USER_VERSION_DIR}) - else() - # set the GUDHI_USER_VERSION_DIR with timestamp and Gudhi version number - string(TIMESTAMP DATE_AND_TIME "%Y-%m-%d-%H-%M-%S") - set(GUDHI_USER_VERSION_DIR ${CMAKE_CURRENT_BINARY_DIR}/${DATE_AND_TIME}_GUDHI_${GUDHI_VERSION}) - endif() - - set(GUDHI_DOXYGEN_DEPENDENCY user_version) - - add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E - make_directory ${GUDHI_USER_VERSION_DIR} - COMMENT "user_version creation in ${GUDHI_USER_VERSION_DIR}") - - add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E - copy ${CMAKE_SOURCE_DIR}/Conventions.txt ${GUDHI_USER_VERSION_DIR}/Conventions.txt) - add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E - copy ${CMAKE_SOURCE_DIR}/README ${GUDHI_USER_VERSION_DIR}/README) - add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E - copy ${CMAKE_SOURCE_DIR}/COPYING ${GUDHI_USER_VERSION_DIR}/COPYING) - add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E - copy ${CMAKE_SOURCE_DIR}/src/CMakeLists.txt ${GUDHI_USER_VERSION_DIR}/CMakeLists.txt) - add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E - copy ${CMAKE_SOURCE_DIR}/src/Doxyfile ${GUDHI_USER_VERSION_DIR}/Doxyfile) - add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E - copy ${CMAKE_SOURCE_DIR}/src/GUDHIConfigVersion.cmake.in ${GUDHI_USER_VERSION_DIR}/GUDHIConfigVersion.cmake.in) - add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E - copy ${CMAKE_SOURCE_DIR}/src/GUDHIConfig.cmake.in ${GUDHI_USER_VERSION_DIR}/GUDHIConfig.cmake.in) - add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E - copy ${CMAKE_SOURCE_DIR}/CMakeGUDHIVersion.txt ${GUDHI_USER_VERSION_DIR}/CMakeGUDHIVersion.txt) - - add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E - copy_directory ${CMAKE_SOURCE_DIR}/biblio ${GUDHI_USER_VERSION_DIR}/biblio) - add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E - copy_directory ${CMAKE_SOURCE_DIR}/src/cython ${GUDHI_USER_VERSION_DIR}/cython) - add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E - copy_directory ${CMAKE_SOURCE_DIR}/data ${GUDHI_USER_VERSION_DIR}/data) - add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E - copy_directory ${CMAKE_SOURCE_DIR}/src/cmake ${GUDHI_USER_VERSION_DIR}/cmake) - add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E - copy_directory ${CMAKE_SOURCE_DIR}/src/GudhUI ${GUDHI_USER_VERSION_DIR}/GudhUI) - - set(GUDHI_MODULES "common;Alpha_complex;Bitmap_cubical_complex;Bottleneck_distance;Contraction;Hasse_complex;Persistent_cohomology;Rips_complex;Simplex_tree;Skeleton_blocker;Spatial_searching;Subsampling;Tangential_complex;Witness_complex") - set(GUDHI_DIRECTORIES "doc;example;concept") - set(GUDHI_INCLUDE_DIRECTORIES "include/gudhi;include/gudhi_patches") - - foreach(GUDHI_MODULE ${GUDHI_MODULES}) - foreach(GUDHI_DIRECTORY ${GUDHI_DIRECTORIES}) - # Find files - file(GLOB GUDHI_FILES ${CMAKE_SOURCE_DIR}/src/${GUDHI_MODULE}/${GUDHI_DIRECTORY}/*) - - foreach(GUDHI_FILE ${GUDHI_FILES}) - get_filename_component(GUDHI_FILE_NAME ${GUDHI_FILE} NAME) - # GUDHI_FILE can be a file or a directory - if(IS_DIRECTORY ${GUDHI_FILE}) - add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E - copy_directory ${GUDHI_FILE} ${GUDHI_USER_VERSION_DIR}/${GUDHI_DIRECTORY}/${GUDHI_MODULE}/${GUDHI_FILE_NAME}) - else() - add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E - copy ${GUDHI_FILE} ${GUDHI_USER_VERSION_DIR}/${GUDHI_DIRECTORY}/${GUDHI_MODULE}/${GUDHI_FILE_NAME}) - endif() - endforeach() - endforeach(GUDHI_DIRECTORY ${GUDHI_DIRECTORIES}) - - foreach(GUDHI_INCLUDE_DIRECTORY ${GUDHI_INCLUDE_DIRECTORIES}) - # include files - file(GLOB GUDHI_INCLUDE_FILES ${CMAKE_SOURCE_DIR}/src/${GUDHI_MODULE}/${GUDHI_INCLUDE_DIRECTORY}/*) - - foreach(GUDHI_INCLUDE_FILE ${GUDHI_INCLUDE_FILES}) - get_filename_component(GUDHI_INCLUDE_FILE_NAME ${GUDHI_INCLUDE_FILE} NAME) - # GUDHI_INCLUDE_FILE can be a file or a directory - if(IS_DIRECTORY ${GUDHI_INCLUDE_FILE}) - add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E - copy_directory ${GUDHI_INCLUDE_FILE} ${GUDHI_USER_VERSION_DIR}/${GUDHI_INCLUDE_DIRECTORY}/${GUDHI_INCLUDE_FILE_NAME}) - else() - add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E - copy ${GUDHI_INCLUDE_FILE} ${GUDHI_USER_VERSION_DIR}/${GUDHI_INCLUDE_DIRECTORY}/${GUDHI_INCLUDE_FILE_NAME}) - endif() - endforeach() - endforeach(GUDHI_INCLUDE_DIRECTORY ${GUDHI_INCLUDE_DIRECTORIES}) - - endforeach(GUDHI_MODULE ${GUDHI_MODULES}) - -endif() diff --git a/src/common/include/gudhi/random_point_generators.h b/src/common/include/gudhi/random_point_generators.h index 2ec465ef..9df77760 100644 --- a/src/common/include/gudhi/random_point_generators.h +++ b/src/common/include/gudhi/random_point_generators.h @@ -281,6 +281,38 @@ std::vector generate_points_on_sphere_d(std::size_t nu return points; } +template +std::vector generate_points_in_ball_d(std::size_t num_points, int dim, double radius) { + typedef typename Kernel::Point_d Point; + Kernel k; + CGAL::Random rng; + CGAL::Random_points_in_ball_d generator(dim, radius); + std::vector points; + points.reserve(num_points); + for (std::size_t i = 0; i < num_points;) { + Point p = *generator++; + points.push_back(p); + ++i; + } + return points; +} + +template +std::vector generate_points_in_cube_d(std::size_t num_points, int dim, double radius) { + typedef typename Kernel::Point_d Point; + Kernel k; + CGAL::Random rng; + CGAL::Random_points_in_cube_d generator(dim, radius); + std::vector points; + points.reserve(num_points); + for (std::size_t i = 0; i < num_points;) { + Point p = *generator++; + points.push_back(p); + ++i; + } + return points; +} + template std::vector generate_points_on_two_spheres_d(std::size_t num_points, int dim, double radius, double distance_between_centers, diff --git a/src/common/utilities/CMakeLists.txt b/src/common/utilities/CMakeLists.txt new file mode 100644 index 00000000..88d377a7 --- /dev/null +++ b/src/common/utilities/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 2.6) +project(data_points_generator) + +if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.6.0) + add_executable ( data_points_generator hypergenerator.cpp ) + target_link_libraries(data_points_generator ${Boost_SYSTEM_LIBRARY}) + add_test(NAME data_points_generator_on_sphere_1000_3_15.2 COMMAND $ + "on" "sphere" "onSphere.off" "1000" "3" "15.2") + add_test(NAME data_points_generator_in_sphere_100_2 COMMAND $ + "in" "sphere" "inSphere.off" "100" "2") + + # on cube is not available in CGAL + add_test(NAME data_points_generator_in_cube_10000_3_5.8 COMMAND $ + "in" "cube" "inCube.off" "10000" "3" "5.8") +endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.6.0) diff --git a/src/common/utilities/README b/src/common/utilities/README new file mode 100644 index 00000000..f2ece556 --- /dev/null +++ b/src/common/utilities/README @@ -0,0 +1,19 @@ +======================= data_points_generator ================================== + +Example of use : + +*** Hyper sphere|cube generator + +./data_points_generator on sphere onSphere.off 1000 3 15.2 + + => generates a onSphere.off file with 1000 points randomized on a sphere of dimension 3 and radius 15.2 + +./data_points_generator in sphere inSphere.off 100 2 + + => generates a inSphere.off file with 100 points randomized in a sphere of dimension 2 (circle) and radius 1.0 (default) + +./data_points_generator in cube inCube.off 10000 3 5.8 + + => generates a inCube.off file with 10000 points randomized in a cube of dimension 3 and side 5.8 + +!! Warning: hypegenerator on cube is not available !! diff --git a/src/common/utilities/hypergenerator.cpp b/src/common/utilities/hypergenerator.cpp new file mode 100644 index 00000000..0f310a13 --- /dev/null +++ b/src/common/utilities/hypergenerator.cpp @@ -0,0 +1,189 @@ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): Vincent Rouvreau + * + * Copyright (C) 2014 INRIA Saclay (France) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include + +#include +#include +#include + +#include +#include +#include +#include // for std::ofstream +#include + +typedef CGAL::Epick_d< CGAL::Dynamic_dimension_tag > K; +typedef K::Point_d Point; + +void usage(char * const progName) { + std::cerr << "Usage: " << progName << " in|on sphere|cube off_file_name points_number[integer > 0] " << + "dimension[integer > 1] radius[double > 0.0 | default = 1.0]" << std::endl; + exit(-1); +} + +int main(int argc, char **argv) { + // program args management + if ((argc != 6) && (argc != 7)) { + std::cerr << "Error: Number of arguments (" << argc << ") is not correct" << std::endl; + usage(argv[0]); + } + + int points_number = atoi(argv[4]); + if (points_number <= 0) { + std::cerr << "Error: " << argv[4] << " is not correct" << std::endl; + usage(argv[0]); + } + + int dimension = atoi(argv[5]); + if (dimension <= 0) { + std::cerr << "Error: " << argv[5] << " is not correct" << std::endl; + usage(argv[0]); + } + + double radius = 1.0; + if (argc == 7) { + radius = atof(argv[6]); + if (radius <= 0.0) { + std::cerr << "Error: " << argv[6] << " is not correct" << std::endl; + usage(argv[0]); + } + } + + bool in = false; + if (strcmp(argv[1], "in") == 0) { + in = true; + } else if (strcmp(argv[1], "on") != 0) { + std::cerr << "Error: " << argv[1] << " is not correct" << std::endl; + usage(argv[0]); + } + + enum class Data_shape { sphere, cube, curve, torus, klein, undefined } ; + + Data_shape shape = Data_shape::undefined; + if (memcmp(argv[2], "sphere", sizeof("sphere")) == 0) { + shape = Data_shape::sphere; + } else if (memcmp(argv[2], "cube", sizeof("cube")) == 0) { + shape = Data_shape::cube; + } else if (memcmp(argv[2], "curve", sizeof("curve")) == 0) { + shape = Data_shape::curve; + } else if (memcmp(argv[2], "torus", sizeof("torus")) == 0) { + shape = Data_shape::torus; + } else if (memcmp(argv[2], "klein", sizeof("klein")) == 0) { + shape = Data_shape::klein; + } else { + std::cerr << "Error: " << argv[2] << " is not correct" << std::endl; + usage(argv[0]); + } + + std::ofstream diagram_out(argv[3]); + if (dimension == 3) { + diagram_out << "OFF" << std::endl; + diagram_out << points_number << " 0 0" << std::endl; + } else { + diagram_out << "nOFF" << std::endl; + diagram_out << dimension << " " << points_number << " 0 0" << std::endl; + } + + if (diagram_out.is_open()) { + // Generate "points_number" random points in a vector + std::vector points; + if (in) { + switch (shape) { + case Data_shape::sphere: + points = Gudhi::generate_points_in_ball_d(points_number, dimension, radius); + break; + case Data_shape::cube: + points = Gudhi::generate_points_in_ball_d(points_number, dimension, radius); + break; + case Data_shape::curve: + std::cerr << "Sorry: in curve is not available" << std::endl; + usage(argv[0]); + break; + case Data_shape::torus: + std::cerr << "Sorry: in torus is not available" << std::endl; + usage(argv[0]); + break; + case Data_shape::klein: + std::cerr << "Sorry: in klein is not available" << std::endl; + usage(argv[0]); + break; + default: + usage(argv[0]); + break; + } + } else { // means "on" + switch (shape) { + case Data_shape::sphere: + points = Gudhi::generate_points_on_sphere_d(points_number, dimension, radius); + break; + case Data_shape::cube: + std::cerr << "Sorry: on cube is not available" << std::endl; + usage(argv[0]); + break; + case Data_shape::curve: + points = Gudhi::generate_points_on_moment_curve(points_number, dimension, -radius/2., radius/2.); + break; + case Data_shape::torus: + if (dimension == 3) + points = Gudhi::generate_points_on_torus_3D(points_number, dimension, radius, radius/2.); + else + points = Gudhi::generate_points_on_torus_d(points_number, dimension, true); + break; + case Data_shape::klein: + switch (dimension) { + case 3: + points = Gudhi::generate_points_on_klein_bottle_3D(points_number, radius, radius/2., true); + break; + case 4: + points = Gudhi::generate_points_on_klein_bottle_4D(points_number, radius, radius/2., 0., true); + break; + case 5: + points = Gudhi::generate_points_on_klein_bottle_variant_5D(points_number, radius, radius/2., true); + break; + default: + std::cerr << "Sorry: on klein is only available for dimension 3, 4 and 5" << std::endl; + usage(argv[0]); + break; + } + break; + default: + usage(argv[0]); + break; + } + } + + for (auto thePoint : points) { + int i = 0; + for (; i < dimension - 1; i++) { + diagram_out << thePoint[i] << " "; + } + diagram_out << thePoint[i] << std::endl; // last point + Carriage Return + } + } else { + std::cerr << "Error: " << argv[3] << " cannot be opened" << std::endl; + usage(argv[0]); + } + + return 0; +} + -- cgit v1.2.3 From f8992aa852dc1a5ef1392837581f55650cccaebf Mon Sep 17 00:00:00 2001 From: cjamin Date: Fri, 19 May 2017 08:52:58 +0000 Subject: Remove DEBUG_TRACES git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/read_persistence_from_file@2446 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 2290435a73db6bea9297fa79e10f7e36be10a43e --- src/Bottleneck_distance/example/bottleneck_read_file_example.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp b/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp index e50a243d..67bd27db 100644 --- a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp +++ b/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp @@ -21,7 +21,6 @@ */ #define CGAL_HAS_THREADS -#define DEBUG_TRACES #include #include -- cgit v1.2.3 From ec3f93103f5a1937d3f8bbf37af3837a1089bf03 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 19 May 2017 16:13:50 +0000 Subject: Move src/common/utilities/hypergenerator.cpp in src/common/utilities Management of Python distribution packages make install is now installing utilities and GUDHI python module git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cmake_modules_for_gudhi@2453 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: a85576c7ae062718900f0db2bfb0dd3f26e87177 --- CMakeLists.txt | 19 ++- src/CMakeLists.txt | 27 ++- src/GudhUI/CMakeLists.txt | 2 + src/cmake/modules/GUDHI_modules.cmake | 17 -- .../modules/GUDHI_third_party_libraries.cmake | 7 +- src/cmake/modules/GUDHI_user_version_target.cmake | 2 +- src/common/utilities/CMakeLists.txt | 15 +- src/common/utilities/README | 10 +- src/common/utilities/hypergenerator.cpp | 189 --------------------- .../utilities/off_file_from_shape_generator.cpp | 189 +++++++++++++++++++++ src/cython/CMakeLists.txt | 10 +- 11 files changed, 260 insertions(+), 227 deletions(-) delete mode 100644 src/common/utilities/hypergenerator.cpp create mode 100644 src/common/utilities/off_file_from_shape_generator.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 360eb87a..c9ceb92b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,23 @@ endif() # Modules list can be found in CMAKE_MODULE_PATH/GUDHI_modules.cmake include(GUDHI_modules) +# Add your new module in the list, order is not important + +add_gudhi_module(common) +add_gudhi_module(Alpha_complex) +add_gudhi_module(Bitmap_cubical_complex) +add_gudhi_module(Bottleneck_distance) +add_gudhi_module(Contraction) +add_gudhi_module(Hasse_complex) +add_gudhi_module(Persistent_cohomology) +add_gudhi_module(Rips_complex) +add_gudhi_module(Simplex_tree) +add_gudhi_module(Skeleton_blocker) +add_gudhi_module(Spatial_searching) +add_gudhi_module(Subsampling) +add_gudhi_module(Tangential_complex) +add_gudhi_module(Witness_complex) + # Include module headers foreach(GUDHI_MODULE ${GUDHI_MODULES}) if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/src/${GUDHI_MODULE}/include/) @@ -63,5 +80,5 @@ endif() # For "make user_version" - Requires GUDHI_modules to be performed include(GUDHI_user_version_target) -# For "make doxygen" - Requires GUDHI_user_version_target to be performed +# For "make doxygen" - Requires GUDHI_USER_VERSION_DIR to be set - Done in GUDHI_user_version_target for dev version include(GUDHI_doxygen_target) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 77a03c17..8abfcf44 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,7 +10,24 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/") # To be done first - Modules list can be found in CMAKE_MODULE_PATH/GUDHI_modules.cmake include(GUDHI_modules) -# For "make doxygen" +# Add your new module in the list, order is not important + +add_gudhi_module(common) +add_gudhi_module(Alpha_complex) +add_gudhi_module(Bitmap_cubical_complex) +add_gudhi_module(Bottleneck_distance) +add_gudhi_module(Contraction) +add_gudhi_module(Hasse_complex) +add_gudhi_module(Persistent_cohomology) +add_gudhi_module(Rips_complex) +add_gudhi_module(Simplex_tree) +add_gudhi_module(Skeleton_blocker) +add_gudhi_module(Spatial_searching) +add_gudhi_module(Subsampling) +add_gudhi_module(Tangential_complex) +add_gudhi_module(Witness_complex) + +# For "make doxygen" - Requires GUDHI_USER_VERSION_DIR to be set set(GUDHI_USER_VERSION_DIR ${CMAKE_SOURCE_DIR}) include(GUDHI_doxygen_target) @@ -47,10 +64,10 @@ include_directories(include) foreach(GUDHI_MODULE ${GUDHI_MODULES}) foreach(GUDHI_SUB_DIRECTORY ${GUDHI_SUB_DIRECTORIES}) if(EXISTS ${CMAKE_SOURCE_DIR}/${GUDHI_SUB_DIRECTORY}/${GUDHI_MODULE}/CMakeLists.txt) - add_subdirectory(src/${GUDHI_MODULE}/${GUDHI_SUB_DIRECTORY}/) - endif(EXISTS ${CMAKE_SOURCE_DIR}/${GUDHI_SUB_DIRECTORY}/${GUDHI_MODULE}/CMakeLists.txt) - endforeach(GUDHI_SUB_DIRECTORY ${GUDHI_SUB_DIRECTORIES}) -endforeach(GUDHI_MODULE ${GUDHI_MODULES}) + add_subdirectory(${CMAKE_SOURCE_DIR}/${GUDHI_SUB_DIRECTORY}/${GUDHI_MODULE}/) + endif() + endforeach() +endforeach() add_subdirectory(GudhUI) diff --git a/src/GudhUI/CMakeLists.txt b/src/GudhUI/CMakeLists.txt index ca2e47c1..57861946 100644 --- a/src/GudhUI/CMakeLists.txt +++ b/src/GudhUI/CMakeLists.txt @@ -56,6 +56,8 @@ if (TBB_FOUND) target_link_libraries( GudhUI ${TBB_LIBRARIES}) endif() + install(TARGETS GudhUI DESTINATION bin) + ############################################################################### else() diff --git a/src/cmake/modules/GUDHI_modules.cmake b/src/cmake/modules/GUDHI_modules.cmake index 6a26d7bf..20fc8d17 100644 --- a/src/cmake/modules/GUDHI_modules.cmake +++ b/src/cmake/modules/GUDHI_modules.cmake @@ -5,23 +5,6 @@ function(add_gudhi_module file_path) set(GUDHI_MODULES ${GUDHI_MODULES} ${file_path} PARENT_SCOPE) endfunction(add_gudhi_module) -# Add your new module in the list, order is not important - -add_gudhi_module(common) -add_gudhi_module(Alpha_complex) -add_gudhi_module(Bitmap_cubical_complex) -add_gudhi_module(Bottleneck_distance) -add_gudhi_module(Contraction) -add_gudhi_module(Hasse_complex) -add_gudhi_module(Persistent_cohomology) -add_gudhi_module(Rips_complex) -add_gudhi_module(Simplex_tree) -add_gudhi_module(Skeleton_blocker) -add_gudhi_module(Spatial_searching) -add_gudhi_module(Subsampling) -add_gudhi_module(Tangential_complex) -add_gudhi_module(Witness_complex) - # message("++ GUDHI_MODULES list is:\"${GUDHI_MODULES}\"") if (WITH_GUDHI_BENCHMARK) diff --git a/src/cmake/modules/GUDHI_third_party_libraries.cmake b/src/cmake/modules/GUDHI_third_party_libraries.cmake index 5f84c602..8cb01d3c 100644 --- a/src/cmake/modules/GUDHI_third_party_libraries.cmake +++ b/src/cmake/modules/GUDHI_third_party_libraries.cmake @@ -135,10 +135,15 @@ if(PYTHONINTERP_FOUND AND CYTHON_FOUND) # Documentation generation is available through sphinx find_program( SPHINX_PATH sphinx-build ) elseif(PYTHON_VERSION_MAJOR EQUAL 3) - # Documentation generation is available through sphinx + # No sphinx-build in Pyton3, just hack it set(SPHINX_PATH "${CMAKE_SOURCE_DIR}/${GUDHI_CYTHON_PATH}/doc/python3-sphinx-build") else() message(FATAL_ERROR "ERROR: Try to compile the Cython interface. Python version ${PYTHON_VERSION_STRING} is not valid.") endif(PYTHON_VERSION_MAJOR EQUAL 2) + # get PYTHON_SITE_PACKAGES relative path from a python command line + execute_process( + COMMAND "${PYTHON_EXECUTABLE}" -c "from distutils.sysconfig import get_python_lib; print (get_python_lib(prefix='', plat_specific=True))" + OUTPUT_VARIABLE PYTHON_SITE_PACKAGES + OUTPUT_STRIP_TRAILING_WHITESPACE) endif(PYTHONINTERP_FOUND AND CYTHON_FOUND) diff --git a/src/cmake/modules/GUDHI_user_version_target.cmake b/src/cmake/modules/GUDHI_user_version_target.cmake index a764e88a..8642d3bf 100644 --- a/src/cmake/modules/GUDHI_user_version_target.cmake +++ b/src/cmake/modules/GUDHI_user_version_target.cmake @@ -47,7 +47,7 @@ if (NOT CMAKE_VERSION VERSION_LESS 2.8.11) add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/src/GudhUI ${GUDHI_USER_VERSION_DIR}/GudhUI) - set(GUDHI_DIRECTORIES "doc;example;concept") + set(GUDHI_DIRECTORIES "doc;example;concept;utilities") set(GUDHI_INCLUDE_DIRECTORIES "include/gudhi;include/gudhi_patches") foreach(GUDHI_MODULE ${GUDHI_MODULES}) diff --git a/src/common/utilities/CMakeLists.txt b/src/common/utilities/CMakeLists.txt index 88d377a7..c2e07e7e 100644 --- a/src/common/utilities/CMakeLists.txt +++ b/src/common/utilities/CMakeLists.txt @@ -1,15 +1,18 @@ cmake_minimum_required(VERSION 2.6) -project(data_points_generator) +project(off_file_from_shape_generator) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.6.0) - add_executable ( data_points_generator hypergenerator.cpp ) - target_link_libraries(data_points_generator ${Boost_SYSTEM_LIBRARY}) - add_test(NAME data_points_generator_on_sphere_1000_3_15.2 COMMAND $ + add_executable ( off_file_from_shape_generator off_file_from_shape_generator.cpp ) + target_link_libraries(off_file_from_shape_generator ${Boost_SYSTEM_LIBRARY}) + add_test(NAME off_file_from_shape_generator_on_sphere_1000_3_15.2 COMMAND $ "on" "sphere" "onSphere.off" "1000" "3" "15.2") - add_test(NAME data_points_generator_in_sphere_100_2 COMMAND $ + add_test(NAME off_file_from_shape_generator_in_sphere_100_2 COMMAND $ "in" "sphere" "inSphere.off" "100" "2") # on cube is not available in CGAL - add_test(NAME data_points_generator_in_cube_10000_3_5.8 COMMAND $ + add_test(NAME off_file_from_shape_generator_in_cube_10000_3_5.8 COMMAND $ "in" "cube" "inCube.off" "10000" "3" "5.8") + + install(TARGETS off_file_from_shape_generator DESTINATION bin) + endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.6.0) diff --git a/src/common/utilities/README b/src/common/utilities/README index f2ece556..dc841521 100644 --- a/src/common/utilities/README +++ b/src/common/utilities/README @@ -1,18 +1,18 @@ -======================= data_points_generator ================================== +======================= off_file_from_shape_generator ================================== Example of use : -*** Hyper sphere|cube generator +*** on|in sphere|cube|curve|torus|klein generator -./data_points_generator on sphere onSphere.off 1000 3 15.2 +./off_file_from_shape_generator on sphere onSphere.off 1000 3 15.2 => generates a onSphere.off file with 1000 points randomized on a sphere of dimension 3 and radius 15.2 -./data_points_generator in sphere inSphere.off 100 2 +./off_file_from_shape_generator in sphere inSphere.off 100 2 => generates a inSphere.off file with 100 points randomized in a sphere of dimension 2 (circle) and radius 1.0 (default) -./data_points_generator in cube inCube.off 10000 3 5.8 +./off_file_from_shape_generator in cube inCube.off 10000 3 5.8 => generates a inCube.off file with 10000 points randomized in a cube of dimension 3 and side 5.8 diff --git a/src/common/utilities/hypergenerator.cpp b/src/common/utilities/hypergenerator.cpp deleted file mode 100644 index 0f310a13..00000000 --- a/src/common/utilities/hypergenerator.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/* This file is part of the Gudhi Library. The Gudhi library - * (Geometric Understanding in Higher Dimensions) is a generic C++ - * library for computational topology. - * - * Author(s): Vincent Rouvreau - * - * Copyright (C) 2014 INRIA Saclay (France) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include - -#include -#include -#include - -#include -#include -#include -#include // for std::ofstream -#include - -typedef CGAL::Epick_d< CGAL::Dynamic_dimension_tag > K; -typedef K::Point_d Point; - -void usage(char * const progName) { - std::cerr << "Usage: " << progName << " in|on sphere|cube off_file_name points_number[integer > 0] " << - "dimension[integer > 1] radius[double > 0.0 | default = 1.0]" << std::endl; - exit(-1); -} - -int main(int argc, char **argv) { - // program args management - if ((argc != 6) && (argc != 7)) { - std::cerr << "Error: Number of arguments (" << argc << ") is not correct" << std::endl; - usage(argv[0]); - } - - int points_number = atoi(argv[4]); - if (points_number <= 0) { - std::cerr << "Error: " << argv[4] << " is not correct" << std::endl; - usage(argv[0]); - } - - int dimension = atoi(argv[5]); - if (dimension <= 0) { - std::cerr << "Error: " << argv[5] << " is not correct" << std::endl; - usage(argv[0]); - } - - double radius = 1.0; - if (argc == 7) { - radius = atof(argv[6]); - if (radius <= 0.0) { - std::cerr << "Error: " << argv[6] << " is not correct" << std::endl; - usage(argv[0]); - } - } - - bool in = false; - if (strcmp(argv[1], "in") == 0) { - in = true; - } else if (strcmp(argv[1], "on") != 0) { - std::cerr << "Error: " << argv[1] << " is not correct" << std::endl; - usage(argv[0]); - } - - enum class Data_shape { sphere, cube, curve, torus, klein, undefined } ; - - Data_shape shape = Data_shape::undefined; - if (memcmp(argv[2], "sphere", sizeof("sphere")) == 0) { - shape = Data_shape::sphere; - } else if (memcmp(argv[2], "cube", sizeof("cube")) == 0) { - shape = Data_shape::cube; - } else if (memcmp(argv[2], "curve", sizeof("curve")) == 0) { - shape = Data_shape::curve; - } else if (memcmp(argv[2], "torus", sizeof("torus")) == 0) { - shape = Data_shape::torus; - } else if (memcmp(argv[2], "klein", sizeof("klein")) == 0) { - shape = Data_shape::klein; - } else { - std::cerr << "Error: " << argv[2] << " is not correct" << std::endl; - usage(argv[0]); - } - - std::ofstream diagram_out(argv[3]); - if (dimension == 3) { - diagram_out << "OFF" << std::endl; - diagram_out << points_number << " 0 0" << std::endl; - } else { - diagram_out << "nOFF" << std::endl; - diagram_out << dimension << " " << points_number << " 0 0" << std::endl; - } - - if (diagram_out.is_open()) { - // Generate "points_number" random points in a vector - std::vector points; - if (in) { - switch (shape) { - case Data_shape::sphere: - points = Gudhi::generate_points_in_ball_d(points_number, dimension, radius); - break; - case Data_shape::cube: - points = Gudhi::generate_points_in_ball_d(points_number, dimension, radius); - break; - case Data_shape::curve: - std::cerr << "Sorry: in curve is not available" << std::endl; - usage(argv[0]); - break; - case Data_shape::torus: - std::cerr << "Sorry: in torus is not available" << std::endl; - usage(argv[0]); - break; - case Data_shape::klein: - std::cerr << "Sorry: in klein is not available" << std::endl; - usage(argv[0]); - break; - default: - usage(argv[0]); - break; - } - } else { // means "on" - switch (shape) { - case Data_shape::sphere: - points = Gudhi::generate_points_on_sphere_d(points_number, dimension, radius); - break; - case Data_shape::cube: - std::cerr << "Sorry: on cube is not available" << std::endl; - usage(argv[0]); - break; - case Data_shape::curve: - points = Gudhi::generate_points_on_moment_curve(points_number, dimension, -radius/2., radius/2.); - break; - case Data_shape::torus: - if (dimension == 3) - points = Gudhi::generate_points_on_torus_3D(points_number, dimension, radius, radius/2.); - else - points = Gudhi::generate_points_on_torus_d(points_number, dimension, true); - break; - case Data_shape::klein: - switch (dimension) { - case 3: - points = Gudhi::generate_points_on_klein_bottle_3D(points_number, radius, radius/2., true); - break; - case 4: - points = Gudhi::generate_points_on_klein_bottle_4D(points_number, radius, radius/2., 0., true); - break; - case 5: - points = Gudhi::generate_points_on_klein_bottle_variant_5D(points_number, radius, radius/2., true); - break; - default: - std::cerr << "Sorry: on klein is only available for dimension 3, 4 and 5" << std::endl; - usage(argv[0]); - break; - } - break; - default: - usage(argv[0]); - break; - } - } - - for (auto thePoint : points) { - int i = 0; - for (; i < dimension - 1; i++) { - diagram_out << thePoint[i] << " "; - } - diagram_out << thePoint[i] << std::endl; // last point + Carriage Return - } - } else { - std::cerr << "Error: " << argv[3] << " cannot be opened" << std::endl; - usage(argv[0]); - } - - return 0; -} - diff --git a/src/common/utilities/off_file_from_shape_generator.cpp b/src/common/utilities/off_file_from_shape_generator.cpp new file mode 100644 index 00000000..0f310a13 --- /dev/null +++ b/src/common/utilities/off_file_from_shape_generator.cpp @@ -0,0 +1,189 @@ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): Vincent Rouvreau + * + * Copyright (C) 2014 INRIA Saclay (France) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include + +#include +#include +#include + +#include +#include +#include +#include // for std::ofstream +#include + +typedef CGAL::Epick_d< CGAL::Dynamic_dimension_tag > K; +typedef K::Point_d Point; + +void usage(char * const progName) { + std::cerr << "Usage: " << progName << " in|on sphere|cube off_file_name points_number[integer > 0] " << + "dimension[integer > 1] radius[double > 0.0 | default = 1.0]" << std::endl; + exit(-1); +} + +int main(int argc, char **argv) { + // program args management + if ((argc != 6) && (argc != 7)) { + std::cerr << "Error: Number of arguments (" << argc << ") is not correct" << std::endl; + usage(argv[0]); + } + + int points_number = atoi(argv[4]); + if (points_number <= 0) { + std::cerr << "Error: " << argv[4] << " is not correct" << std::endl; + usage(argv[0]); + } + + int dimension = atoi(argv[5]); + if (dimension <= 0) { + std::cerr << "Error: " << argv[5] << " is not correct" << std::endl; + usage(argv[0]); + } + + double radius = 1.0; + if (argc == 7) { + radius = atof(argv[6]); + if (radius <= 0.0) { + std::cerr << "Error: " << argv[6] << " is not correct" << std::endl; + usage(argv[0]); + } + } + + bool in = false; + if (strcmp(argv[1], "in") == 0) { + in = true; + } else if (strcmp(argv[1], "on") != 0) { + std::cerr << "Error: " << argv[1] << " is not correct" << std::endl; + usage(argv[0]); + } + + enum class Data_shape { sphere, cube, curve, torus, klein, undefined } ; + + Data_shape shape = Data_shape::undefined; + if (memcmp(argv[2], "sphere", sizeof("sphere")) == 0) { + shape = Data_shape::sphere; + } else if (memcmp(argv[2], "cube", sizeof("cube")) == 0) { + shape = Data_shape::cube; + } else if (memcmp(argv[2], "curve", sizeof("curve")) == 0) { + shape = Data_shape::curve; + } else if (memcmp(argv[2], "torus", sizeof("torus")) == 0) { + shape = Data_shape::torus; + } else if (memcmp(argv[2], "klein", sizeof("klein")) == 0) { + shape = Data_shape::klein; + } else { + std::cerr << "Error: " << argv[2] << " is not correct" << std::endl; + usage(argv[0]); + } + + std::ofstream diagram_out(argv[3]); + if (dimension == 3) { + diagram_out << "OFF" << std::endl; + diagram_out << points_number << " 0 0" << std::endl; + } else { + diagram_out << "nOFF" << std::endl; + diagram_out << dimension << " " << points_number << " 0 0" << std::endl; + } + + if (diagram_out.is_open()) { + // Generate "points_number" random points in a vector + std::vector points; + if (in) { + switch (shape) { + case Data_shape::sphere: + points = Gudhi::generate_points_in_ball_d(points_number, dimension, radius); + break; + case Data_shape::cube: + points = Gudhi::generate_points_in_ball_d(points_number, dimension, radius); + break; + case Data_shape::curve: + std::cerr << "Sorry: in curve is not available" << std::endl; + usage(argv[0]); + break; + case Data_shape::torus: + std::cerr << "Sorry: in torus is not available" << std::endl; + usage(argv[0]); + break; + case Data_shape::klein: + std::cerr << "Sorry: in klein is not available" << std::endl; + usage(argv[0]); + break; + default: + usage(argv[0]); + break; + } + } else { // means "on" + switch (shape) { + case Data_shape::sphere: + points = Gudhi::generate_points_on_sphere_d(points_number, dimension, radius); + break; + case Data_shape::cube: + std::cerr << "Sorry: on cube is not available" << std::endl; + usage(argv[0]); + break; + case Data_shape::curve: + points = Gudhi::generate_points_on_moment_curve(points_number, dimension, -radius/2., radius/2.); + break; + case Data_shape::torus: + if (dimension == 3) + points = Gudhi::generate_points_on_torus_3D(points_number, dimension, radius, radius/2.); + else + points = Gudhi::generate_points_on_torus_d(points_number, dimension, true); + break; + case Data_shape::klein: + switch (dimension) { + case 3: + points = Gudhi::generate_points_on_klein_bottle_3D(points_number, radius, radius/2., true); + break; + case 4: + points = Gudhi::generate_points_on_klein_bottle_4D(points_number, radius, radius/2., 0., true); + break; + case 5: + points = Gudhi::generate_points_on_klein_bottle_variant_5D(points_number, radius, radius/2., true); + break; + default: + std::cerr << "Sorry: on klein is only available for dimension 3, 4 and 5" << std::endl; + usage(argv[0]); + break; + } + break; + default: + usage(argv[0]); + break; + } + } + + for (auto thePoint : points) { + int i = 0; + for (; i < dimension - 1; i++) { + diagram_out << thePoint[i] << " "; + } + diagram_out << thePoint[i] << std::endl; // last point + Carriage Return + } + } else { + std::cerr << "Error: " << argv[3] << " cannot be opened" << std::endl; + usage(argv[0]); + } + + return 0; +} + diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index 96c2acb3..62f8d368 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -168,17 +168,23 @@ if(CYTHON_FOUND) configure_file(gudhi.pyx.in "${CMAKE_CURRENT_BINARY_DIR}/gudhi.pyx" @ONLY) add_custom_command( - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/gudhi.so" + OUTPUT gudhi.so WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/cythonize_gudhi.py" "build_ext" "--inplace") - add_custom_target(cython ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/gudhi.so" + add_custom_target(cython ALL DEPENDS gudhi.so COMMENT "Do not forget to add ${CMAKE_CURRENT_BINARY_DIR}/ to your PYTHONPATH before using examples or tests") if(UNIX) set( ENV{PYTHONPATH} $ENV{PYTHONPATH}:${CMAKE_CURRENT_BINARY_DIR}/ ) endif(UNIX) + # For installation purpose + install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" DESTINATION "${PYTHON_SITE_PACKAGES}/" FILES_MATCHING + PATTERN "*.so" + PATTERN "*.dylib" + PATTERN "*.pyd") + # Test examples add_test(NAME alpha_complex_from_points_example_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} -- cgit v1.2.3 From 269fa842c2eaeb7ddf8040abfd6c18d23ac767e9 Mon Sep 17 00:00:00 2001 From: cjamin Date: Tue, 23 May 2017 09:10:41 +0000 Subject: read_persistence_diagram_from_file now uses an output iterator git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/read_persistence_from_file@2455 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 3969666dcde3581a75789c5a4b62817dea553f9f --- .../example/bottleneck_read_file_example.cpp | 15 +++++++++++++-- src/common/include/gudhi/reader_utils.h | 17 ++++++++--------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp b/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp index 67bd27db..74c8d1ab 100644 --- a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp +++ b/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp @@ -31,14 +31,25 @@ #include #include +struct Persistence_interval + : std::pair +{ + Persistence_interval(std::tuple data) + : std::pair(std::make_pair(std::get<1>(data), std::get<2>(data))) + {} +}; + int main(int argc, char** argv) { if (argc < 3) { std::cout << "To run this program please provide as an input two files with persistence diagrams. Each file " << "should contain a birth-death pair per line. Third, optional parameter is an error bound on a bottleneck" << " distance (set by default to zero). The program will now terminate \n"; } - std::vector< std::pair< double, double > > diag1 = read_persistence_diagram_from_file(argv[1]); - std::vector< std::pair< double, double > > diag2 = read_persistence_diagram_from_file(argv[2]); + std::vector diag1; + std::vector diag2; + read_persistence_diagram_from_file(argv[1], std::back_inserter(diag1)); + read_persistence_diagram_from_file(argv[2], std::back_inserter(diag2)); + double tolerance = 0.; if (argc == 4) { tolerance = atof(argv[3]); diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index ceee8daf..019a3db2 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -298,11 +298,11 @@ std::vector< std::vector< Filtration_value > > read_lower_triangular_matrix_from /** Reads a file containing persistance intervals. Each line might contain 2, 3 or 4 values: [field] [dimension] birth death +The output iterator `out` is used this way: `*out++ = std::make_tuple(dim, birth, death);` +where `dim` is an `int`, `birth` a `double`, and `death` a `double`. **/ - -std::vector< std::pair > read_persistence_diagram_from_file(std::string const& filename) { - - std::vector< std::pair > result; +template +void read_persistence_diagram_from_file(std::string const& filename, OutputIterator out) { std::ifstream in; in.open(filename); @@ -310,7 +310,6 @@ std::vector< std::pair > read_persistence_diagram_from_file(std: #ifdef DEBUG_TRACES std::cerr << "File \"" << filename << "\" does not exist.\n"; #endif // DEBUG_TRACES - return result; } std::string line; @@ -319,7 +318,9 @@ std::vector< std::pair > read_persistence_diagram_from_file(std: if (line.length() != 0 && line[0] != '#') { double numbers[4]; int n = sscanf(line.c_str(), "%lf %lf %lf %lf", &numbers[0], &numbers[1], &numbers[2], &numbers[3]); - result.push_back(std::make_pair(numbers[n - 2], numbers[n - 1])); + //int field = (n == 4 ? static_cast(numbers[0]) : -1); + int dim = (n >= 3 ? static_cast(numbers[n - 3]) : -1); + *out++ = std::make_tuple(dim, numbers[n - 2], numbers[n - 1]); #ifdef DEBUG_TRACES std::cerr << numbers[n - 2] << " - " << numbers[n - 1] << "\n"; #endif // DEBUG_TRACES @@ -327,8 +328,6 @@ std::vector< std::pair > read_persistence_diagram_from_file(std: } in.close(); - return result; -} // read_diagram_from_file - +} // read_persistence_diagram_from_file #endif // READER_UTILS_H_ -- cgit v1.2.3 From 71527e6ff81a7ac657f8a797a050bbcf7a131cb9 Mon Sep 17 00:00:00 2001 From: cjamin Date: Mon, 29 May 2017 16:22:49 +0000 Subject: Add 2 new variants of read_persistence_diagram_from_file git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/read_persistence_from_file@2463 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: bd0dd2c981856c8e1a51b2b97ac10d9edd59f694 --- .../example/bottleneck_read_file_example.cpp | 6 +- src/common/include/gudhi/reader_utils.h | 85 ++++++++++++++++++++-- 2 files changed, 82 insertions(+), 9 deletions(-) diff --git a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp b/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp index 74c8d1ab..e26edd26 100644 --- a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp +++ b/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp @@ -45,10 +45,8 @@ int main(int argc, char** argv) { "should contain a birth-death pair per line. Third, optional parameter is an error bound on a bottleneck" << " distance (set by default to zero). The program will now terminate \n"; } - std::vector diag1; - std::vector diag2; - read_persistence_diagram_from_file(argv[1], std::back_inserter(diag1)); - read_persistence_diagram_from_file(argv[2], std::back_inserter(diag2)); + std::vector> diag1 = read_persistence_diagram_from_file(argv[1], -1); + std::vector> diag2 = read_persistence_diagram_from_file(argv[2], -1); double tolerance = 0.; if (argc == 4) { diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index 019a3db2..7b371afc 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -310,24 +310,99 @@ void read_persistence_diagram_from_file(std::string const& filename, OutputItera #ifdef DEBUG_TRACES std::cerr << "File \"" << filename << "\" does not exist.\n"; #endif // DEBUG_TRACES + return; } - std::string line; while (!in.eof()) { + std::string line; getline(in, line); if (line.length() != 0 && line[0] != '#') { double numbers[4]; int n = sscanf(line.c_str(), "%lf %lf %lf %lf", &numbers[0], &numbers[1], &numbers[2], &numbers[3]); - //int field = (n == 4 ? static_cast(numbers[0]) : -1); - int dim = (n >= 3 ? static_cast(numbers[n - 3]) : -1); - *out++ = std::make_tuple(dim, numbers[n - 2], numbers[n - 1]); + if (n >= 2) { + //int field = (n == 4 ? static_cast(numbers[0]) : -1); + int dim = (n >= 3 ? static_cast(numbers[n - 3]) : -1); + *out++ = std::make_tuple(dim, numbers[n - 2], numbers[n - 1]); + } + } + } + + in.close(); +} // read_persistence_diagram_from_file + +/** +Reads a file containing persistance intervals. +Each line might contain 2, 3 or 4 values: [field] [dimension] birth death +The return value is an `std::map[dim, std::vector[std::pair[birth, death]]]` +where `dim` is an `int`, `birth` a `double`, and `death` a `double`. +**/ +std::map>> read_persistence_diagram_from_file(std::string const& filename) { + + std::map>> ret; + + std::ifstream in; + in.open(filename); + if (!in.is_open()) { #ifdef DEBUG_TRACES - std::cerr << numbers[n - 2] << " - " << numbers[n - 1] << "\n"; + std::cerr << "File \"" << filename << "\" does not exist.\n"; #endif // DEBUG_TRACES + return ret; + } + + while (!in.eof()) { + std::string line; + getline(in, line); + if (line.length() != 0 && line[0] != '#') { + double numbers[4]; + int n = sscanf(line.c_str(), "%lf %lf %lf %lf", &numbers[0], &numbers[1], &numbers[2], &numbers[3]); + if (n >= 2) { + int dim = (n >= 3 ? static_cast(numbers[n - 3]) : -1); + ret[dim].push_back(std::make_pair(numbers[n - 2], numbers[n - 1])); + } + } + } + + in.close(); + return ret; +} // read_persistence_diagram_from_file + + +/** +Reads a file containing persistance intervals. +Each line might contain 2, 3 or 4 values: [field] [dimension] birth death +If `only_this_dim` = -1, dimension is ignored and all lines are returned. +If `only_this_dim` is >= 0, only the lines where dimension = `only_this_dim` +(or where dimension is not specified) are returned. +The return value is an `std::vector[std::pair[birth, death]]` +where `dim` is an `int`, `birth` a `double`, and `death` a `double`. +**/ +std::vector> read_persistence_diagram_from_file(std::string const& filename, int only_this_dim) { + + std::vector> ret; + + std::ifstream in; + in.open(filename); + if (!in.is_open()) { +#ifdef DEBUG_TRACES + std::cerr << "File \"" << filename << "\" does not exist.\n"; +#endif // DEBUG_TRACES + return ret; + } + + while (!in.eof()) { + std::string line; + getline(in, line); + if (line.length() != 0 && line[0] != '#') { + double numbers[4]; + int n = sscanf(line.c_str(), "%lf %lf %lf %lf", &numbers[0], &numbers[1], &numbers[2], &numbers[3]); + int dim = (n >= 3 ? static_cast(numbers[n - 3]) : -1); + if (n >= 2 && (only_this_dim == -1 || dim == only_this_dim)) + ret.push_back(std::make_pair(numbers[n - 2], numbers[n - 1])); } } in.close(); + return ret; } // read_persistence_diagram_from_file #endif // READER_UTILS_H_ -- cgit v1.2.3 From bb5e82c41e9d3a79f8e1dc53cd1dd2c117e06111 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 30 May 2017 07:36:17 +0000 Subject: Add a warning git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cmake_modules_for_gudhi@2465 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: a873c9c6fff031968747c3dec197aec06738c32a --- src/cython/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index 62f8d368..d9f356f9 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -180,6 +180,7 @@ if(CYTHON_FOUND) endif(UNIX) # For installation purpose + # TODO(VR) : files matching pattern mechanism is copying all cython directory install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" DESTINATION "${PYTHON_SITE_PACKAGES}/" FILES_MATCHING PATTERN "*.so" PATTERN "*.dylib" -- cgit v1.2.3 From 5ca4efc2986846d5442a8f18941430cddadc1e80 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 30 May 2017 08:49:50 +0000 Subject: Make install examples mechanism git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cmake_modules_for_gudhi@2467 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 018b6e55c392b37d02503e7822e0a586061c987d --- src/Alpha_complex/example/CMakeLists.txt | 4 ++++ src/Bitmap_cubical_complex/example/CMakeLists.txt | 4 ++++ src/Bottleneck_distance/example/CMakeLists.txt | 4 ++++ src/Contraction/example/CMakeLists.txt | 3 +++ src/Persistent_cohomology/example/CMakeLists.txt | 24 ++++++++++++++++++++--- src/Rips_complex/example/CMakeLists.txt | 5 +++++ src/Simplex_tree/example/CMakeLists.txt | 6 ++++++ src/Skeleton_blocker/example/CMakeLists.txt | 4 ++++ src/Spatial_searching/example/CMakeLists.txt | 1 + src/Subsampling/example/CMakeLists.txt | 6 ++++++ src/Tangential_complex/example/CMakeLists.txt | 3 +++ src/Witness_complex/example/CMakeLists.txt | 9 +++++++++ src/common/example/CMakeLists.txt | 5 +++++ 13 files changed, 75 insertions(+), 3 deletions(-) diff --git a/src/Alpha_complex/example/CMakeLists.txt b/src/Alpha_complex/example/CMakeLists.txt index a4853d78..4badcb91 100644 --- a/src/Alpha_complex/example/CMakeLists.txt +++ b/src/Alpha_complex/example/CMakeLists.txt @@ -29,4 +29,8 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0) add_test(Alpha_complex_example_from_off_32_diff_files ${DIFF_PATH} ${CMAKE_CURRENT_BINARY_DIR}/alphaoffreader_result_32.txt ${CMAKE_CURRENT_BINARY_DIR}/alphaoffreader_for_doc_32.txt) endif() + + install(TARGETS Alpha_complex_example_from_points DESTINATION bin) + install(TARGETS Alpha_complex_example_from_off DESTINATION bin) + endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0) diff --git a/src/Bitmap_cubical_complex/example/CMakeLists.txt b/src/Bitmap_cubical_complex/example/CMakeLists.txt index 241a11e5..47f5e0c6 100644 --- a/src/Bitmap_cubical_complex/example/CMakeLists.txt +++ b/src/Bitmap_cubical_complex/example/CMakeLists.txt @@ -34,3 +34,7 @@ add_test(NAME Bitmap_cubical_complex_example_periodic_boundary_conditions_2d_tor add_test(NAME Bitmap_cubical_complex_example_periodic_boundary_conditions_3d_torus COMMAND $ "${CMAKE_SOURCE_DIR}/data/bitmap/3d_torus.txt") + +install(TARGETS Bitmap_cubical_complex DESTINATION bin) +install(TARGETS Random_bitmap_cubical_complex DESTINATION bin) +install(TARGETS Bitmap_cubical_complex_periodic_boundary_conditions DESTINATION bin) diff --git a/src/Bottleneck_distance/example/CMakeLists.txt b/src/Bottleneck_distance/example/CMakeLists.txt index 0d0bff45..0534a2c4 100644 --- a/src/Bottleneck_distance/example/CMakeLists.txt +++ b/src/Bottleneck_distance/example/CMakeLists.txt @@ -19,4 +19,8 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) COMMAND $ "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "-r" "0.15" "-m" "0.12" "-d" "3" "-p" "3") + install(TARGETS bottleneck_read_file_example DESTINATION bin) + install(TARGETS bottleneck_basic_example DESTINATION bin) + install(TARGETS alpha_rips_persistence_bottleneck_distance DESTINATION bin) + endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) diff --git a/src/Contraction/example/CMakeLists.txt b/src/Contraction/example/CMakeLists.txt index 51a6832d..b2b38dea 100644 --- a/src/Contraction/example/CMakeLists.txt +++ b/src/Contraction/example/CMakeLists.txt @@ -16,3 +16,6 @@ add_test(NAME Contraction_example_tore3D_0.2 COMMAND $ # "${CMAKE_SOURCE_DIR}/data/points/SO3_10000.off" "0.3") + +install(TARGETS RipsContraction DESTINATION bin) +install(TARGETS GarlandHeckbert DESTINATION bin) diff --git a/src/Persistent_cohomology/example/CMakeLists.txt b/src/Persistent_cohomology/example/CMakeLists.txt index 3c45e79b..a9884c49 100644 --- a/src/Persistent_cohomology/example/CMakeLists.txt +++ b/src/Persistent_cohomology/example/CMakeLists.txt @@ -47,7 +47,15 @@ add_test(NAME Persistent_cohomology_example_from_file_3_2_0 COMMAND $ "${CMAKE_SOURCE_DIR}/data/filtered_simplicial_complex/bunny_5000_complex.fsc" "-p" "3" "-m" "100") - + +install(TARGETS plain_homology DESTINATION bin) +install(TARGETS persistence_from_simple_simplex_tree DESTINATION bin) +install(TARGETS rips_distance_matrix_persistence DESTINATION bin) +install(TARGETS rips_persistence DESTINATION bin) +install(TARGETS rips_persistence_step_by_step DESTINATION bin) +install(TARGETS rips_persistence_via_boundary_matrix DESTINATION bin) +install(TARGETS persistence_from_file DESTINATION bin) + if(GMP_FOUND) if(GMPXX_FOUND) add_executable(rips_multifield_persistence rips_multifield_persistence.cpp ) @@ -56,8 +64,9 @@ if(GMP_FOUND) if (TBB_FOUND) target_link_libraries(rips_multifield_persistence ${TBB_LIBRARIES}) endif(TBB_FOUND) - add_test(NAME Persistent_cohomology_example_multifield_2_71 COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "-r" "0.25" "-m" "0.5" "-d" "3" "-p" "2" "-q" "71") + add_test(NAME Persistent_cohomology_example_multifield_2_71 COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "-r" "0.25" "-m" "0.5" "-d" "3" "-p" "2" "-q" "71") + install(TARGETS rips_multifield_persistence DESTINATION bin) endif(GMPXX_FOUND) endif(GMP_FOUND) @@ -81,6 +90,10 @@ if(CGAL_FOUND) add_test(NAME Persistent_cohomology_example_weighted_alpha_complex_3d COMMAND $ "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.weights" "2" "0.45") + install(TARGETS alpha_complex_3d_persistence DESTINATION bin) + install(TARGETS exact_alpha_complex_3d_persistence DESTINATION bin) + install(TARGETS weighted_alpha_complex_3d_persistence DESTINATION bin) + if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0) add_executable (alpha_complex_persistence alpha_complex_persistence.cpp) target_link_libraries(alpha_complex_persistence @@ -102,5 +115,10 @@ if(CGAL_FOUND) add_test(NAME Persistent_cohomology_example_periodic_alpha_complex_3d COMMAND $ "${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.off" "${CMAKE_SOURCE_DIR}/data/points/iso_cuboid_3_in_0_1.txt" "2" "0") add_test(NAME Persistent_cohomology_example_custom_persistence_sort COMMAND $) + + install(TARGETS alpha_complex_persistence DESTINATION bin) + install(TARGETS periodic_alpha_complex_3d_persistence DESTINATION bin) + install(TARGETS custom_persistence_sort DESTINATION bin) + endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0) endif(CGAL_FOUND) diff --git a/src/Rips_complex/example/CMakeLists.txt b/src/Rips_complex/example/CMakeLists.txt index 8aee79e2..712db16e 100644 --- a/src/Rips_complex/example/CMakeLists.txt +++ b/src/Rips_complex/example/CMakeLists.txt @@ -56,3 +56,8 @@ if (DIFF_PATH) ${CMAKE_CURRENT_BINARY_DIR}/ripscsvreader_result_12_3.txt ${CMAKE_CURRENT_BINARY_DIR}/full_skeleton_rips_for_doc.txt) endif() + +install(TARGETS Rips_complex_example_from_off DESTINATION bin) +install(TARGETS Rips_complex_example_one_skeleton_from_points DESTINATION bin) +install(TARGETS Rips_complex_example_one_skeleton_from_distance_matrix DESTINATION bin) +install(TARGETS Rips_complex_example_from_csv_distance_matrix DESTINATION bin) diff --git a/src/Simplex_tree/example/CMakeLists.txt b/src/Simplex_tree/example/CMakeLists.txt index b1ea98d4..d05bb187 100644 --- a/src/Simplex_tree/example/CMakeLists.txt +++ b/src/Simplex_tree/example/CMakeLists.txt @@ -19,6 +19,9 @@ add_test(NAME Simplex_tree_example_simple_simplex_tree COMMAND $) +install(TARGETS Simplex_tree_example_from_cliques_of_graph DESTINATION bin) +install(TARGETS Simplex_tree_example_simple_simplex_tree DESTINATION bin) +install(TARGETS Simplex_tree_example_mini_simplex_tree DESTINATION bin) # An example with Simplex-tree using CGAL alpha_shapes_3 if(GMP_FOUND AND CGAL_FOUND) @@ -29,4 +32,7 @@ if(GMP_FOUND AND CGAL_FOUND) endif() add_test(NAME Simplex_tree_example_alpha_shapes_3_from_off COMMAND $ "${CMAKE_SOURCE_DIR}/data/points/bunny_5000.off") + + install(TARGETS Simplex_tree_example_alpha_shapes_3_from_off DESTINATION bin) + endif() diff --git a/src/Skeleton_blocker/example/CMakeLists.txt b/src/Skeleton_blocker/example/CMakeLists.txt index c887e408..ce51ac39 100644 --- a/src/Skeleton_blocker/example/CMakeLists.txt +++ b/src/Skeleton_blocker/example/CMakeLists.txt @@ -10,3 +10,7 @@ target_link_libraries(Skeleton_blocker_example_iteration ${Boost_TIMER_LIBRARY} add_test(NAME Skeleton_blocker_example_from_simplices COMMAND $) add_test(NAME Skeleton_blocker_example_iteration COMMAND $) add_test(NAME Skeleton_blocker_example_link COMMAND $) + +install(TARGETS Skeleton_blocker_example_from_simplices DESTINATION bin) +install(TARGETS Skeleton_blocker_example_iteration DESTINATION bin) +install(TARGETS Skeleton_blocker_example_link DESTINATION bin) diff --git a/src/Spatial_searching/example/CMakeLists.txt b/src/Spatial_searching/example/CMakeLists.txt index f4b9f3cb..4cf3d863 100644 --- a/src/Spatial_searching/example/CMakeLists.txt +++ b/src/Spatial_searching/example/CMakeLists.txt @@ -6,4 +6,5 @@ if(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) target_link_libraries(Spatial_searching_example_spatial_searching ${CGAL_LIBRARY}) add_test(NAME Spatial_searching_example_spatial_searching COMMAND $) + install(TARGETS Spatial_searching_example_spatial_searching DESTINATION bin) endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) diff --git a/src/Subsampling/example/CMakeLists.txt b/src/Subsampling/example/CMakeLists.txt index 71b8d2e8..34400b1e 100644 --- a/src/Subsampling/example/CMakeLists.txt +++ b/src/Subsampling/example/CMakeLists.txt @@ -14,4 +14,10 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) COMMAND $) add_test(NAME Subsampling_example_sparsify_point_set COMMAND $) + + install(TARGETS Subsampling_example_pick_n_random_points DESTINATION bin) + install(TARGETS Subsampling_example_choose_n_farthest_points DESTINATION bin) + install(TARGETS Subsampling_example_custom_kernel DESTINATION bin) + install(TARGETS Subsampling_example_sparsify_point_set DESTINATION bin) + endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) diff --git a/src/Tangential_complex/example/CMakeLists.txt b/src/Tangential_complex/example/CMakeLists.txt index 339d0581..45c7642b 100644 --- a/src/Tangential_complex/example/CMakeLists.txt +++ b/src/Tangential_complex/example/CMakeLists.txt @@ -15,4 +15,7 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) COMMAND $) add_test(NAME Tangential_complex_example_with_perturb COMMAND $) + + install(TARGETS Tangential_complex_example_basic DESTINATION bin) + install(TARGETS Tangential_complex_example_with_perturb DESTINATION bin) endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) diff --git a/src/Witness_complex/example/CMakeLists.txt b/src/Witness_complex/example/CMakeLists.txt index 670651ce..1e18d024 100644 --- a/src/Witness_complex/example/CMakeLists.txt +++ b/src/Witness_complex/example/CMakeLists.txt @@ -9,6 +9,8 @@ endif() add_test(NAME Witness_complex_example_nearest_landmark_table COMMAND $) +install(TARGETS Witness_complex_example_nearest_landmark_table DESTINATION bin) + # CGAL and Eigen3 are required for Euclidean version of Witness if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.6.0) add_executable( Witness_complex_example_off example_witness_complex_off.cpp ) @@ -43,4 +45,11 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.6.0) add_test(NAME Witness_complex_example_strong_test_torus_persistence COMMAND $ "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "-l" "20" "-a" "0.5") + + install(TARGETS Witness_complex_example_off DESTINATION bin) + install(TARGETS Witness_complex_example_strong_off DESTINATION bin) + install(TARGETS Witness_complex_example_sphere DESTINATION bin) + install(TARGETS Witness_complex_example_witness_persistence DESTINATION bin) + install(TARGETS Witness_complex_example_strong_witness_persistence DESTINATION bin) + endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.6.0) diff --git a/src/common/example/CMakeLists.txt b/src/common/example/CMakeLists.txt index d5311b18..af3c2c9d 100644 --- a/src/common/example/CMakeLists.txt +++ b/src/common/example/CMakeLists.txt @@ -6,6 +6,8 @@ target_link_libraries(vector_double_off_reader ${Boost_SYSTEM_LIBRARY} ${CGAL_L add_test(NAME Common_example_vector_double_off_reader COMMAND $ "${CMAKE_SOURCE_DIR}/data/points/SO3_10000.off") +install(TARGETS vector_double_off_reader DESTINATION bin) + if(CGAL_FOUND) add_executable ( cgal_3D_off_reader example_CGAL_3D_points_off_reader.cpp ) target_link_libraries(cgal_3D_off_reader ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY}) @@ -19,4 +21,7 @@ if(CGAL_FOUND) add_test(NAME Common_example_vector_cgal_off_reader COMMAND $ "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off") endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0) + + install(TARGETS cgal_3D_off_reader DESTINATION bin) + install(TARGETS cgal_off_reader DESTINATION bin) endif() -- cgit v1.2.3 -- cgit v1.2.3 From 006516d2df5eaa6e38765158f72fa29fea8fb610 Mon Sep 17 00:00:00 2001 From: cjamin Date: Tue, 30 May 2017 12:50:12 +0000 Subject: Remove debug code git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/read_persistence_from_file@2473 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 458dcfcf18b36f8dd0023dfe5af0d6083d1c7684 --- src/Bottleneck_distance/example/bottleneck_read_file_example.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp b/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp index e26edd26..f6fd6501 100644 --- a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp +++ b/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp @@ -20,8 +20,6 @@ * along with this program. If not, see . */ -#define CGAL_HAS_THREADS - #include #include #include -- cgit v1.2.3 From 6d4b5ec65b863abb5b183635a0e64341c19e7b4b Mon Sep 17 00:00:00 2001 From: cjamin Date: Tue, 30 May 2017 13:00:15 +0000 Subject: Clean-up git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/read_persistence_from_file@2474 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 9586b4987dad745fa60bca1a433349a2f78fa9bd --- src/Bottleneck_distance/example/bottleneck_read_file_example.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp b/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp index f6fd6501..de8c7f9d 100644 --- a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp +++ b/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp @@ -29,14 +29,6 @@ #include #include -struct Persistence_interval - : std::pair -{ - Persistence_interval(std::tuple data) - : std::pair(std::make_pair(std::get<1>(data), std::get<2>(data))) - {} -}; - int main(int argc, char** argv) { if (argc < 3) { std::cout << "To run this program please provide as an input two files with persistence diagrams. Each file " << -- cgit v1.2.3 -- cgit v1.2.3 From 53abf1ac75eefcecc1391d140183a49588f0d2d2 Mon Sep 17 00:00:00 2001 From: cjamin Date: Wed, 31 May 2017 11:30:58 +0000 Subject: Fix doc and shorten code git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/read_persistence_from_file@2485 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 97dcd51c0dc9cef00a655e5e0ad078de752eabe8 --- src/common/include/gudhi/reader_utils.h | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index 7b371afc..df10d5a5 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -297,15 +297,14 @@ std::vector< std::vector< Filtration_value > > read_lower_triangular_matrix_from /** Reads a file containing persistance intervals. -Each line might contain 2, 3 or 4 values: [field] [dimension] birth death +Each line might contain 2, 3 or 4 values: [[field] dimension] birth death The output iterator `out` is used this way: `*out++ = std::make_tuple(dim, birth, death);` where `dim` is an `int`, `birth` a `double`, and `death` a `double`. **/ template void read_persistence_diagram_from_file(std::string const& filename, OutputIterator out) { - std::ifstream in; - in.open(filename); + std::ifstream in(filename); if (!in.is_open()) { #ifdef DEBUG_TRACES std::cerr << "File \"" << filename << "\" does not exist.\n"; @@ -326,13 +325,11 @@ void read_persistence_diagram_from_file(std::string const& filename, OutputItera } } } - - in.close(); } // read_persistence_diagram_from_file /** Reads a file containing persistance intervals. -Each line might contain 2, 3 or 4 values: [field] [dimension] birth death +Each line might contain 2, 3 or 4 values: [[field] dimension] birth death The return value is an `std::map[dim, std::vector[std::pair[birth, death]]]` where `dim` is an `int`, `birth` a `double`, and `death` a `double`. **/ @@ -340,8 +337,7 @@ std::map>> read_persistence_diagram_f std::map>> ret; - std::ifstream in; - in.open(filename); + std::ifstream in(filename); if (!in.is_open()) { #ifdef DEBUG_TRACES std::cerr << "File \"" << filename << "\" does not exist.\n"; @@ -362,14 +358,13 @@ std::map>> read_persistence_diagram_f } } - in.close(); return ret; } // read_persistence_diagram_from_file /** Reads a file containing persistance intervals. -Each line might contain 2, 3 or 4 values: [field] [dimension] birth death +Each line might contain 2, 3 or 4 values: [[field] dimension] birth death If `only_this_dim` = -1, dimension is ignored and all lines are returned. If `only_this_dim` is >= 0, only the lines where dimension = `only_this_dim` (or where dimension is not specified) are returned. @@ -380,8 +375,7 @@ std::vector> read_persistence_diagram_from_file(std::s std::vector> ret; - std::ifstream in; - in.open(filename); + std::ifstream in(filename); if (!in.is_open()) { #ifdef DEBUG_TRACES std::cerr << "File \"" << filename << "\" does not exist.\n"; @@ -401,7 +395,6 @@ std::vector> read_persistence_diagram_from_file(std::s } } - in.close(); return ret; } // read_persistence_diagram_from_file -- cgit v1.2.3 From 8457da40a4af813d6368cd85d1f60d2b2de52191 Mon Sep 17 00:00:00 2001 From: cjamin Date: Wed, 31 May 2017 11:36:20 +0000 Subject: Typo git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/read_persistence_from_file@2486 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: dcc6134d95dea816a3c54a2a796535f384ccfc54 --- src/common/include/gudhi/reader_utils.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index df10d5a5..55a1e875 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -296,7 +296,7 @@ std::vector< std::vector< Filtration_value > > read_lower_triangular_matrix_from } // read_lower_triangular_matrix_from_csv_file /** -Reads a file containing persistance intervals. +Reads a file containing persistence intervals. Each line might contain 2, 3 or 4 values: [[field] dimension] birth death The output iterator `out` is used this way: `*out++ = std::make_tuple(dim, birth, death);` where `dim` is an `int`, `birth` a `double`, and `death` a `double`. @@ -328,7 +328,7 @@ void read_persistence_diagram_from_file(std::string const& filename, OutputItera } // read_persistence_diagram_from_file /** -Reads a file containing persistance intervals. +Reads a file containing persistence intervals. Each line might contain 2, 3 or 4 values: [[field] dimension] birth death The return value is an `std::map[dim, std::vector[std::pair[birth, death]]]` where `dim` is an `int`, `birth` a `double`, and `death` a `double`. @@ -363,7 +363,7 @@ std::map>> read_persistence_diagram_f /** -Reads a file containing persistance intervals. +Reads a file containing persistence intervals. Each line might contain 2, 3 or 4 values: [[field] dimension] birth death If `only_this_dim` = -1, dimension is ignored and all lines are returned. If `only_this_dim` is >= 0, only the lines where dimension = `only_this_dim` -- cgit v1.2.3 From cbcf098dbc2af8f385216d74d6ffbbe08deaff66 Mon Sep 17 00:00:00 2001 From: cjamin Date: Wed, 31 May 2017 11:44:16 +0000 Subject: Fix doc git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/read_persistence_from_file@2487 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 7be9a5da2a64835ff7558373e7a754647bc5b663 --- src/common/include/gudhi/reader_utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index 55a1e875..bb744b1c 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -330,7 +330,7 @@ void read_persistence_diagram_from_file(std::string const& filename, OutputItera /** Reads a file containing persistence intervals. Each line might contain 2, 3 or 4 values: [[field] dimension] birth death -The return value is an `std::map[dim, std::vector[std::pair[birth, death]]]` +The return value is an `std::map>>` where `dim` is an `int`, `birth` a `double`, and `death` a `double`. **/ std::map>> read_persistence_diagram_from_file(std::string const& filename) { @@ -368,7 +368,7 @@ Each line might contain 2, 3 or 4 values: [[field] dimension] birth death If `only_this_dim` = -1, dimension is ignored and all lines are returned. If `only_this_dim` is >= 0, only the lines where dimension = `only_this_dim` (or where dimension is not specified) are returned. -The return value is an `std::vector[std::pair[birth, death]]` +The return value is an `std::vector>` where `dim` is an `int`, `birth` a `double`, and `death` a `double`. **/ std::vector> read_persistence_diagram_from_file(std::string const& filename, int only_this_dim) { -- cgit v1.2.3 From 66873d7ee6dd369dd3d8c1909d6376ed2bce4cc7 Mon Sep 17 00:00:00 2001 From: cjamin Date: Wed, 31 May 2017 11:54:55 +0000 Subject: Check if birth <= death git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/read_persistence_from_file@2488 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: fc7aeca7ca7cd1ec2e9a9263849ec34d4dfa8414 --- src/common/include/gudhi/reader_utils.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index bb744b1c..6a89ce90 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -24,6 +24,7 @@ #define READER_UTILS_H_ #include +#include #include @@ -321,6 +322,7 @@ void read_persistence_diagram_from_file(std::string const& filename, OutputItera if (n >= 2) { //int field = (n == 4 ? static_cast(numbers[0]) : -1); int dim = (n >= 3 ? static_cast(numbers[n - 3]) : -1); + GUDHI_CHECK(numbers[n - 2] <= numbers[n - 1], "Error: birth > death."); *out++ = std::make_tuple(dim, numbers[n - 2], numbers[n - 1]); } } @@ -353,6 +355,7 @@ std::map>> read_persistence_diagram_f int n = sscanf(line.c_str(), "%lf %lf %lf %lf", &numbers[0], &numbers[1], &numbers[2], &numbers[3]); if (n >= 2) { int dim = (n >= 3 ? static_cast(numbers[n - 3]) : -1); + GUDHI_CHECK(numbers[n - 2] <= numbers[n - 1], "Error: birth > death."); ret[dim].push_back(std::make_pair(numbers[n - 2], numbers[n - 1])); } } @@ -391,7 +394,10 @@ std::vector> read_persistence_diagram_from_file(std::s int n = sscanf(line.c_str(), "%lf %lf %lf %lf", &numbers[0], &numbers[1], &numbers[2], &numbers[3]); int dim = (n >= 3 ? static_cast(numbers[n - 3]) : -1); if (n >= 2 && (only_this_dim == -1 || dim == only_this_dim)) + { + GUDHI_CHECK(numbers[n - 2] <= numbers[n - 1], "Error: birth > death."); ret.push_back(std::make_pair(numbers[n - 2], numbers[n - 1])); + } } } -- cgit v1.2.3 From df15aa4e16c00a7dc3bca01e01db8608b50dd4b9 Mon Sep 17 00:00:00 2001 From: cjamin Date: Wed, 31 May 2017 11:58:05 +0000 Subject: Add persistence diagram samples git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/read_persistence_from_file@2489 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: bcad955589cbfccdb5f887e409df17a07288c9e4 --- data/persistence_diagram/first.pers | 5 +++++ data/persistence_diagram/second.pers | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 data/persistence_diagram/first.pers create mode 100644 data/persistence_diagram/second.pers diff --git a/data/persistence_diagram/first.pers b/data/persistence_diagram/first.pers new file mode 100644 index 00000000..193c60ba --- /dev/null +++ b/data/persistence_diagram/first.pers @@ -0,0 +1,5 @@ +# Simple persistence diagram +2.7 3.7 +9.6 14. +34.2 34.974 +3. inf \ No newline at end of file diff --git a/data/persistence_diagram/second.pers b/data/persistence_diagram/second.pers new file mode 100644 index 00000000..6292fde6 --- /dev/null +++ b/data/persistence_diagram/second.pers @@ -0,0 +1,3 @@ +2.8 4.45 +9.5 14.1 +3.2 inf \ No newline at end of file -- cgit v1.2.3 From 267f55ba68cd3c7beee9cd8c7bd9e13d90217848 Mon Sep 17 00:00:00 2001 From: cjamin Date: Wed, 31 May 2017 12:03:13 +0000 Subject: Test bottleneck_read_file_example git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/read_persistence_from_file@2490 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: dbbce2ac4862dfdd3c01a619bf68120112ab44d5 --- src/Bottleneck_distance/example/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Bottleneck_distance/example/CMakeLists.txt b/src/Bottleneck_distance/example/CMakeLists.txt index 0534a2c4..508e57bf 100644 --- a/src/Bottleneck_distance/example/CMakeLists.txt +++ b/src/Bottleneck_distance/example/CMakeLists.txt @@ -19,6 +19,10 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) COMMAND $ "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "-r" "0.15" "-m" "0.12" "-d" "3" "-p" "3") + add_test(NAME Bottleneck_read_file_example + COMMAND $ + "${CMAKE_SOURCE_DIR}/data/persistence_diagram/first.pers" "${CMAKE_SOURCE_DIR}/data/persistence_diagram/second.pers") + install(TARGETS bottleneck_read_file_example DESTINATION bin) install(TARGETS bottleneck_basic_example DESTINATION bin) install(TARGETS alpha_rips_persistence_bottleneck_distance DESTINATION bin) -- cgit v1.2.3 From 8493f7a38001930329ec6204e6b3e8dff1c67df1 Mon Sep 17 00:00:00 2001 From: cjamin Date: Thu, 1 Jun 2017 10:26:05 +0000 Subject: Use make_function_output_iterator to avoid code duplication git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/read_persistence_from_file@2498 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 7d9a9d3f72ef4af17f4a9b8263526df69498090c --- src/common/include/gudhi/reader_utils.h | 54 +++++---------------------------- 1 file changed, 7 insertions(+), 47 deletions(-) diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index 6a89ce90..f0903acc 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -25,6 +25,7 @@ #include #include +#include #include @@ -338,29 +339,9 @@ where `dim` is an `int`, `birth` a `double`, and `death` a `double`. std::map>> read_persistence_diagram_from_file(std::string const& filename) { std::map>> ret; - - std::ifstream in(filename); - if (!in.is_open()) { -#ifdef DEBUG_TRACES - std::cerr << "File \"" << filename << "\" does not exist.\n"; -#endif // DEBUG_TRACES - return ret; - } - - while (!in.eof()) { - std::string line; - getline(in, line); - if (line.length() != 0 && line[0] != '#') { - double numbers[4]; - int n = sscanf(line.c_str(), "%lf %lf %lf %lf", &numbers[0], &numbers[1], &numbers[2], &numbers[3]); - if (n >= 2) { - int dim = (n >= 3 ? static_cast(numbers[n - 3]) : -1); - GUDHI_CHECK(numbers[n - 2] <= numbers[n - 1], "Error: birth > death."); - ret[dim].push_back(std::make_pair(numbers[n - 2], numbers[n - 1])); - } - } - } - + read_persistence_diagram_from_file( + filename, + boost::make_function_output_iterator([&ret](auto t) { ret[get<0>(t)].push_back(std::make_pair(get<1>(t), get<2>(t))); })); return ret; } // read_persistence_diagram_from_file @@ -377,30 +358,9 @@ where `dim` is an `int`, `birth` a `double`, and `death` a `double`. std::vector> read_persistence_diagram_from_file(std::string const& filename, int only_this_dim) { std::vector> ret; - - std::ifstream in(filename); - if (!in.is_open()) { -#ifdef DEBUG_TRACES - std::cerr << "File \"" << filename << "\" does not exist.\n"; -#endif // DEBUG_TRACES - return ret; - } - - while (!in.eof()) { - std::string line; - getline(in, line); - if (line.length() != 0 && line[0] != '#') { - double numbers[4]; - int n = sscanf(line.c_str(), "%lf %lf %lf %lf", &numbers[0], &numbers[1], &numbers[2], &numbers[3]); - int dim = (n >= 3 ? static_cast(numbers[n - 3]) : -1); - if (n >= 2 && (only_this_dim == -1 || dim == only_this_dim)) - { - GUDHI_CHECK(numbers[n - 2] <= numbers[n - 1], "Error: birth > death."); - ret.push_back(std::make_pair(numbers[n - 2], numbers[n - 1])); - } - } - } - + read_persistence_diagram_from_file( + filename, + boost::make_function_output_iterator([&ret](auto t) { ret.emplace_back(get<1>(t), get<2>(t)); })); return ret; } // read_persistence_diagram_from_file -- cgit v1.2.3 From 03f7d661f8b5d34320a075a826c0bfeafa16633f Mon Sep 17 00:00:00 2001 From: cjamin Date: Thu, 1 Jun 2017 14:55:10 +0000 Subject: Doc for "pers" file format git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/read_persistence_from_file@2500 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 2da948fefffcb1961961e3111c89f400f23b65d3 --- src/common/doc/main_page.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/common/doc/main_page.h b/src/common/doc/main_page.h index bd4615f5..fba0a858 100644 --- a/src/common/doc/main_page.h +++ b/src/common/doc/main_page.h @@ -152,6 +152,27 @@ \section Toolbox Toolbox + \subsection FileFormats File Formats + \subsubsection FileFormatsPers Persistence Diagram + + Such a file, whose extension is usually `.pers`, contains a list of persistence intervals.
+ Lines starting with `#` are ignored (comments).
+ Other lines might contain 2, 3 or 4 values (the number of values on each line must be the same for all lines): + \code{.unparsed} + [[field] dimension] birth death + \endcode + + Here is a simple sample file: + \code{.unparsed} + # Beautiful persistence diagram + 2 2.7 3.7 + 2 9.6 14. + 3 34.2 34.974 + 4 3. inf + \endcode + + Other sample files can be found in the `data/persistence_diagram`. + \subsection BottleneckDistanceToolbox Bottleneck distance \image html "perturb_pd.png" "Bottleneck distance is the length of the longest edge" -- cgit v1.2.3 From c09268a046c43b4311f0f29ac4bfb14dcb2da30d Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 2 Jun 2017 14:10:20 +0000 Subject: Try to remove boost system git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/boost_system_no_deprecated_test@2504 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: fd12c45af5ebeb72c4b49142abab91b46ce1a9da --- src/Alpha_complex/example/CMakeLists.txt | 4 ++-- src/Rips_complex/example/CMakeLists.txt | 8 ++++---- src/cmake/modules/GUDHI_third_party_libraries.cmake | 2 ++ src/cython/CMakeLists.txt | 10 +--------- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/Alpha_complex/example/CMakeLists.txt b/src/Alpha_complex/example/CMakeLists.txt index 4badcb91..5bf553e9 100644 --- a/src/Alpha_complex/example/CMakeLists.txt +++ b/src/Alpha_complex/example/CMakeLists.txt @@ -5,9 +5,9 @@ project(Alpha_complex_examples) # cmake -DCGAL_DIR=~/workspace/CGAL-4.7 .. if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0) add_executable ( Alpha_complex_example_from_points Alpha_complex_from_points.cpp ) - target_link_libraries(Alpha_complex_example_from_points ${Boost_SYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY} ${CGAL_LIBRARY}) + target_link_libraries(Alpha_complex_example_from_points ${CGAL_LIBRARY}) add_executable ( Alpha_complex_example_from_off Alpha_complex_from_off.cpp ) - target_link_libraries(Alpha_complex_example_from_off ${Boost_SYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY} ${CGAL_LIBRARY}) + target_link_libraries(Alpha_complex_example_from_off ${CGAL_LIBRARY}) if (TBB_FOUND) target_link_libraries(Alpha_complex_example_from_points ${TBB_LIBRARIES}) target_link_libraries(Alpha_complex_example_from_off ${TBB_LIBRARIES}) diff --git a/src/Rips_complex/example/CMakeLists.txt b/src/Rips_complex/example/CMakeLists.txt index 712db16e..d2d3e052 100644 --- a/src/Rips_complex/example/CMakeLists.txt +++ b/src/Rips_complex/example/CMakeLists.txt @@ -3,17 +3,17 @@ project(Rips_complex_examples) # Point cloud add_executable ( Rips_complex_example_from_off example_rips_complex_from_off_file.cpp ) -target_link_libraries(Rips_complex_example_from_off ${Boost_SYSTEM_LIBRARY}) +#target_link_libraries(Rips_complex_example_from_off ${Boost_SYSTEM_LIBRARY}) add_executable ( Rips_complex_example_one_skeleton_from_points example_one_skeleton_rips_from_points.cpp ) -target_link_libraries(Rips_complex_example_one_skeleton_from_points ${Boost_SYSTEM_LIBRARY}) +#target_link_libraries(Rips_complex_example_one_skeleton_from_points ${Boost_SYSTEM_LIBRARY}) # Distance matrix add_executable ( Rips_complex_example_one_skeleton_from_distance_matrix example_one_skeleton_rips_from_distance_matrix.cpp ) -target_link_libraries(Rips_complex_example_one_skeleton_from_distance_matrix ${Boost_SYSTEM_LIBRARY}) +#target_link_libraries(Rips_complex_example_one_skeleton_from_distance_matrix ${Boost_SYSTEM_LIBRARY}) add_executable ( Rips_complex_example_from_csv_distance_matrix example_rips_complex_from_csv_distance_matrix_file.cpp ) -target_link_libraries(Rips_complex_example_from_csv_distance_matrix ${Boost_SYSTEM_LIBRARY}) +#target_link_libraries(Rips_complex_example_from_csv_distance_matrix ${Boost_SYSTEM_LIBRARY}) if (TBB_FOUND) target_link_libraries(Rips_complex_example_from_off ${TBB_LIBRARIES}) diff --git a/src/cmake/modules/GUDHI_third_party_libraries.cmake b/src/cmake/modules/GUDHI_third_party_libraries.cmake index 8cb01d3c..7b0cda3b 100644 --- a/src/cmake/modules/GUDHI_third_party_libraries.cmake +++ b/src/cmake/modules/GUDHI_third_party_libraries.cmake @@ -99,6 +99,8 @@ add_definitions(-DBOOST_RESULT_OF_USE_DECLTYPE) add_definitions(-DBOOST_ALL_NO_LIB) # problem with Visual Studio link on Boost program_options add_definitions( -DBOOST_ALL_DYN_LINK ) +# problem on Mac with boost_system and boost_thread +#add_definitions( -DBOOST_SYSTEM_NO_DEPRECATED ) INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) LINK_DIRECTORIES(${Boost_LIBRARY_DIRS}) diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index d9f356f9..4b56122d 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -6,15 +6,7 @@ if(CYTHON_FOUND) 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', ") - set(GUDHI_CYTHON_LIBRARY_DIRS "${GUDHI_CYTHON_LIBRARY_DIRS}'${Boost_LIBRARY_DIRS}', ") - if(WIN32) - set( returnValue "" ) - find_the_lib (${returnValue} ${Boost_SYSTEM_LIBRARY}) - set(BOOST_SYSTEM_LIB_NAME ${returnValue}) - else() - set(BOOST_SYSTEM_LIB_NAME "boost_system") - endif() - set(GUDHI_CYTHON_LIBRARIES "${GUDHI_CYTHON_LIBRARIES}'${BOOST_SYSTEM_LIB_NAME}', ") + set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DBOOST_SYSTEM_NO_DEPRECATED', ") # Gudhi and CGAL compilation option if(MSVC) -- cgit v1.2.3 From 7cd2fc5259aaa1b362652a026de1c2006ab3a78c Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 2 Jun 2017 16:55:18 +0000 Subject: Get rid of Boost_system library link git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/boost_system_no_deprecated_test@2509 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 52deba0f2212767b99b801810d356e55417225db --- src/Alpha_complex/test/CMakeLists.txt | 2 +- src/Bitmap_cubical_complex/example/CMakeLists.txt | 3 --- src/Bitmap_cubical_complex/test/CMakeLists.txt | 2 +- src/Bottleneck_distance/example/CMakeLists.txt | 2 +- src/Bottleneck_distance/test/CMakeLists.txt | 2 +- src/Contraction/example/CMakeLists.txt | 4 ++-- src/Persistent_cohomology/benchmark/CMakeLists.txt | 2 +- src/Persistent_cohomology/example/CMakeLists.txt | 26 ++++++++++------------ src/Persistent_cohomology/test/CMakeLists.txt | 7 +++--- src/Rips_complex/example/CMakeLists.txt | 4 ---- src/Rips_complex/test/CMakeLists.txt | 2 +- src/Simplex_tree/example/CMakeLists.txt | 2 +- src/Simplex_tree/test/CMakeLists.txt | 2 +- src/Skeleton_blocker/example/CMakeLists.txt | 2 +- src/Skeleton_blocker/test/CMakeLists.txt | 6 ++--- src/Spatial_searching/test/CMakeLists.txt | 2 +- src/Tangential_complex/benchmark/CMakeLists.txt | 2 +- src/Tangential_complex/test/CMakeLists.txt | 2 +- src/Witness_complex/example/CMakeLists.txt | 8 ++----- src/Witness_complex/test/CMakeLists.txt | 4 ++-- src/common/example/CMakeLists.txt | 6 ++--- src/common/test/CMakeLists.txt | 4 ++-- src/common/utilities/CMakeLists.txt | 1 - 23 files changed, 42 insertions(+), 55 deletions(-) diff --git a/src/Alpha_complex/test/CMakeLists.txt b/src/Alpha_complex/test/CMakeLists.txt index d7f49b53..9e0b3b3c 100644 --- a/src/Alpha_complex/test/CMakeLists.txt +++ b/src/Alpha_complex/test/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0) include(GUDHI_test_coverage) add_executable ( Alpha_complex_test_unit Alpha_complex_unit_test.cpp ) - target_link_libraries(Alpha_complex_test_unit ${Boost_SYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY} ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + target_link_libraries(Alpha_complex_test_unit ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Alpha_complex_test_unit ${TBB_LIBRARIES}) endif() diff --git a/src/Bitmap_cubical_complex/example/CMakeLists.txt b/src/Bitmap_cubical_complex/example/CMakeLists.txt index 47f5e0c6..a0401619 100644 --- a/src/Bitmap_cubical_complex/example/CMakeLists.txt +++ b/src/Bitmap_cubical_complex/example/CMakeLists.txt @@ -2,7 +2,6 @@ cmake_minimum_required(VERSION 2.6) project(Bitmap_cubical_complex_examples) add_executable ( Bitmap_cubical_complex Bitmap_cubical_complex.cpp ) -target_link_libraries(Bitmap_cubical_complex ${Boost_SYSTEM_LIBRARY}) if (TBB_FOUND) target_link_libraries(Bitmap_cubical_complex ${TBB_LIBRARIES}) endif() @@ -14,7 +13,6 @@ add_test(NAME Bitmap_cubical_complex_example_persistence_two_sphere COMMAND $ diff --git a/src/Persistent_cohomology/benchmark/CMakeLists.txt b/src/Persistent_cohomology/benchmark/CMakeLists.txt index ea792c89..8b135ba1 100644 --- a/src/Persistent_cohomology/benchmark/CMakeLists.txt +++ b/src/Persistent_cohomology/benchmark/CMakeLists.txt @@ -5,7 +5,7 @@ project(Persistent_cohomology_benchmark) if(GMP_FOUND) if(GMPXX_FOUND) add_executable ( performance_rips_persistence EXCLUDE_FROM_ALL performance_rips_persistence.cpp ) - target_link_libraries(performance_rips_persistence ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${GMPXX_LIBRARIES} ${GMP_LIBRARIES}) + target_link_libraries(performance_rips_persistence ${Boost_PROGRAM_OPTIONS_LIBRARY} ${GMPXX_LIBRARIES} ${GMP_LIBRARIES}) if (TBB_FOUND) target_link_libraries(performance_rips_persistence ${TBB_LIBRARIES}) endif(TBB_FOUND) diff --git a/src/Persistent_cohomology/example/CMakeLists.txt b/src/Persistent_cohomology/example/CMakeLists.txt index a9884c49..f47de4c3 100644 --- a/src/Persistent_cohomology/example/CMakeLists.txt +++ b/src/Persistent_cohomology/example/CMakeLists.txt @@ -2,25 +2,23 @@ cmake_minimum_required(VERSION 2.6) project(Persistent_cohomology_examples) add_executable(plain_homology plain_homology.cpp) -target_link_libraries(plain_homology ${Boost_SYSTEM_LIBRARY}) add_executable(persistence_from_simple_simplex_tree persistence_from_simple_simplex_tree.cpp) -target_link_libraries(persistence_from_simple_simplex_tree ${Boost_SYSTEM_LIBRARY}) add_executable(rips_distance_matrix_persistence rips_distance_matrix_persistence.cpp) -target_link_libraries(rips_distance_matrix_persistence ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) +target_link_libraries(rips_distance_matrix_persistence ${Boost_PROGRAM_OPTIONS_LIBRARY}) add_executable(rips_persistence rips_persistence.cpp) -target_link_libraries(rips_persistence ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) +target_link_libraries(rips_persistence ${Boost_PROGRAM_OPTIONS_LIBRARY}) add_executable(rips_persistence_step_by_step rips_persistence_step_by_step.cpp) -target_link_libraries(rips_persistence_step_by_step ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) +target_link_libraries(rips_persistence_step_by_step ${Boost_PROGRAM_OPTIONS_LIBRARY}) add_executable(rips_persistence_via_boundary_matrix rips_persistence_via_boundary_matrix.cpp) -target_link_libraries(rips_persistence_via_boundary_matrix ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) +target_link_libraries(rips_persistence_via_boundary_matrix ${Boost_PROGRAM_OPTIONS_LIBRARY}) add_executable(persistence_from_file persistence_from_file.cpp) -target_link_libraries(persistence_from_file ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) +target_link_libraries(persistence_from_file ${Boost_PROGRAM_OPTIONS_LIBRARY}) if (TBB_FOUND) target_link_libraries(plain_homology ${TBB_LIBRARIES}) @@ -60,7 +58,7 @@ if(GMP_FOUND) if(GMPXX_FOUND) add_executable(rips_multifield_persistence rips_multifield_persistence.cpp ) target_link_libraries(rips_multifield_persistence - ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${GMPXX_LIBRARIES} ${GMP_LIBRARIES}) + ${Boost_PROGRAM_OPTIONS_LIBRARY} ${GMPXX_LIBRARIES} ${GMP_LIBRARIES}) if (TBB_FOUND) target_link_libraries(rips_multifield_persistence ${TBB_LIBRARIES}) endif(TBB_FOUND) @@ -72,11 +70,11 @@ endif(GMP_FOUND) if(CGAL_FOUND) add_executable(alpha_complex_3d_persistence alpha_complex_3d_persistence.cpp) - target_link_libraries(alpha_complex_3d_persistence ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY}) + target_link_libraries(alpha_complex_3d_persistence ${CGAL_LIBRARY}) add_executable(exact_alpha_complex_3d_persistence exact_alpha_complex_3d_persistence.cpp) - target_link_libraries(exact_alpha_complex_3d_persistence ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY}) + target_link_libraries(exact_alpha_complex_3d_persistence ${CGAL_LIBRARY}) add_executable(weighted_alpha_complex_3d_persistence weighted_alpha_complex_3d_persistence.cpp) - target_link_libraries(weighted_alpha_complex_3d_persistence ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY}) + target_link_libraries(weighted_alpha_complex_3d_persistence ${CGAL_LIBRARY}) if (TBB_FOUND) target_link_libraries(alpha_complex_3d_persistence ${TBB_LIBRARIES}) @@ -97,13 +95,13 @@ if(CGAL_FOUND) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0) add_executable (alpha_complex_persistence alpha_complex_persistence.cpp) target_link_libraries(alpha_complex_persistence - ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) + ${CGAL_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) add_executable(periodic_alpha_complex_3d_persistence periodic_alpha_complex_3d_persistence.cpp) - target_link_libraries(periodic_alpha_complex_3d_persistence ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY}) + target_link_libraries(periodic_alpha_complex_3d_persistence ${CGAL_LIBRARY}) add_executable(custom_persistence_sort custom_persistence_sort.cpp) - target_link_libraries(custom_persistence_sort ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY}) + target_link_libraries(custom_persistence_sort ${CGAL_LIBRARY}) if (TBB_FOUND) target_link_libraries(alpha_complex_persistence ${TBB_LIBRARIES}) diff --git a/src/Persistent_cohomology/test/CMakeLists.txt b/src/Persistent_cohomology/test/CMakeLists.txt index 11e9a951..45f53eb9 100644 --- a/src/Persistent_cohomology/test/CMakeLists.txt +++ b/src/Persistent_cohomology/test/CMakeLists.txt @@ -4,9 +4,9 @@ project(Persistent_cohomology_tests) include(GUDHI_test_coverage) add_executable ( Persistent_cohomology_test_unit persistent_cohomology_unit_test.cpp ) -target_link_libraries(Persistent_cohomology_test_unit ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +target_link_libraries(Persistent_cohomology_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) add_executable ( Persistent_cohomology_test_betti_numbers betti_numbers_unit_test.cpp ) -target_link_libraries(Persistent_cohomology_test_betti_numbers ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +target_link_libraries(Persistent_cohomology_test_betti_numbers ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Persistent_cohomology_test_unit ${TBB_LIBRARIES}) target_link_libraries(Persistent_cohomology_test_betti_numbers ${TBB_LIBRARIES}) @@ -22,7 +22,8 @@ gudhi_add_coverage_test(Persistent_cohomology_test_betti_numbers) if(GMPXX_FOUND AND GMP_FOUND) add_executable ( Persistent_cohomology_test_unit_multi_field persistent_cohomology_unit_test_multi_field.cpp ) - target_link_libraries(Persistent_cohomology_test_unit_multi_field ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${GMPXX_LIBRARIES} ${GMP_LIBRARIES}) + target_link_libraries(Persistent_cohomology_test_unit_multi_field + ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${GMPXX_LIBRARIES} ${GMP_LIBRARIES}) if (TBB_FOUND) target_link_libraries(Persistent_cohomology_test_unit_multi_field ${TBB_LIBRARIES}) endif(TBB_FOUND) diff --git a/src/Rips_complex/example/CMakeLists.txt b/src/Rips_complex/example/CMakeLists.txt index d2d3e052..2940f164 100644 --- a/src/Rips_complex/example/CMakeLists.txt +++ b/src/Rips_complex/example/CMakeLists.txt @@ -3,17 +3,13 @@ project(Rips_complex_examples) # Point cloud add_executable ( Rips_complex_example_from_off example_rips_complex_from_off_file.cpp ) -#target_link_libraries(Rips_complex_example_from_off ${Boost_SYSTEM_LIBRARY}) add_executable ( Rips_complex_example_one_skeleton_from_points example_one_skeleton_rips_from_points.cpp ) -#target_link_libraries(Rips_complex_example_one_skeleton_from_points ${Boost_SYSTEM_LIBRARY}) # Distance matrix add_executable ( Rips_complex_example_one_skeleton_from_distance_matrix example_one_skeleton_rips_from_distance_matrix.cpp ) -#target_link_libraries(Rips_complex_example_one_skeleton_from_distance_matrix ${Boost_SYSTEM_LIBRARY}) add_executable ( Rips_complex_example_from_csv_distance_matrix example_rips_complex_from_csv_distance_matrix_file.cpp ) -#target_link_libraries(Rips_complex_example_from_csv_distance_matrix ${Boost_SYSTEM_LIBRARY}) if (TBB_FOUND) target_link_libraries(Rips_complex_example_from_off ${TBB_LIBRARIES}) diff --git a/src/Rips_complex/test/CMakeLists.txt b/src/Rips_complex/test/CMakeLists.txt index 57f780f1..3da9c90d 100644 --- a/src/Rips_complex/test/CMakeLists.txt +++ b/src/Rips_complex/test/CMakeLists.txt @@ -4,7 +4,7 @@ project(Rips_complex_tests) include(GUDHI_test_coverage) add_executable ( Rips_complex_test_unit test_rips_complex.cpp ) -target_link_libraries(Rips_complex_test_unit ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +target_link_libraries(Rips_complex_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Rips_complex_test_unit ${TBB_LIBRARIES}) endif() diff --git a/src/Simplex_tree/example/CMakeLists.txt b/src/Simplex_tree/example/CMakeLists.txt index d05bb187..e22cc92c 100644 --- a/src/Simplex_tree/example/CMakeLists.txt +++ b/src/Simplex_tree/example/CMakeLists.txt @@ -26,7 +26,7 @@ install(TARGETS Simplex_tree_example_mini_simplex_tree DESTINATION bin) # An example with Simplex-tree using CGAL alpha_shapes_3 if(GMP_FOUND AND CGAL_FOUND) add_executable ( Simplex_tree_example_alpha_shapes_3_from_off example_alpha_shapes_3_simplex_tree_from_off_file.cpp ) - target_link_libraries(Simplex_tree_example_alpha_shapes_3_from_off ${GMP_LIBRARIES} ${CGAL_LIBRARY} ${Boost_SYSTEM_LIBRARY}) + target_link_libraries(Simplex_tree_example_alpha_shapes_3_from_off ${GMP_LIBRARIES} ${CGAL_LIBRARY}) if (TBB_FOUND) target_link_libraries(Simplex_tree_example_alpha_shapes_3_from_off ${TBB_LIBRARIES}) endif() diff --git a/src/Simplex_tree/test/CMakeLists.txt b/src/Simplex_tree/test/CMakeLists.txt index 17b0f2c2..81999de6 100644 --- a/src/Simplex_tree/test/CMakeLists.txt +++ b/src/Simplex_tree/test/CMakeLists.txt @@ -4,7 +4,7 @@ project(Simplex_tree_tests) include(GUDHI_test_coverage) add_executable ( Simplex_tree_test_unit simplex_tree_unit_test.cpp ) -target_link_libraries(Simplex_tree_test_unit ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +target_link_libraries(Simplex_tree_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Simplex_tree_test_unit ${TBB_LIBRARIES}) endif() diff --git a/src/Skeleton_blocker/example/CMakeLists.txt b/src/Skeleton_blocker/example/CMakeLists.txt index ce51ac39..6d685717 100644 --- a/src/Skeleton_blocker/example/CMakeLists.txt +++ b/src/Skeleton_blocker/example/CMakeLists.txt @@ -5,7 +5,7 @@ add_executable(Skeleton_blocker_example_from_simplices Skeleton_blocker_from_sim add_executable(Skeleton_blocker_example_iteration Skeleton_blocker_iteration.cpp) add_executable(Skeleton_blocker_example_link Skeleton_blocker_link.cpp) -target_link_libraries(Skeleton_blocker_example_iteration ${Boost_TIMER_LIBRARY} ${Boost_SYSTEM_LIBRARY}) +target_link_libraries(Skeleton_blocker_example_iteration ${Boost_TIMER_LIBRARY}) add_test(NAME Skeleton_blocker_example_from_simplices COMMAND $) add_test(NAME Skeleton_blocker_example_iteration COMMAND $) diff --git a/src/Skeleton_blocker/test/CMakeLists.txt b/src/Skeleton_blocker/test/CMakeLists.txt index 0887fcff..4a363294 100644 --- a/src/Skeleton_blocker/test/CMakeLists.txt +++ b/src/Skeleton_blocker/test/CMakeLists.txt @@ -4,11 +4,11 @@ project(Skeleton_blocker_tests) include(GUDHI_test_coverage) add_executable ( Skeleton_blocker_test_unit test_skeleton_blocker_complex.cpp ) -target_link_libraries(Skeleton_blocker_test_unit ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +target_link_libraries(Skeleton_blocker_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) add_executable ( Skeleton_blocker_test_geometric_complex test_skeleton_blocker_geometric_complex.cpp ) -target_link_libraries(Skeleton_blocker_test_geometric_complex ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +target_link_libraries(Skeleton_blocker_test_geometric_complex ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) add_executable ( Skeleton_blocker_test_simplifiable test_skeleton_blocker_simplifiable.cpp ) -target_link_libraries(Skeleton_blocker_test_simplifiable ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +target_link_libraries(Skeleton_blocker_test_simplifiable ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) # Do not forget to copy test files in current binary dir file(COPY "test2.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) diff --git a/src/Spatial_searching/test/CMakeLists.txt b/src/Spatial_searching/test/CMakeLists.txt index 2502ea5e..b9da7b4e 100644 --- a/src/Spatial_searching/test/CMakeLists.txt +++ b/src/Spatial_searching/test/CMakeLists.txt @@ -6,7 +6,7 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) add_executable( Spatial_searching_test_Kd_tree_search test_Kd_tree_search.cpp ) target_link_libraries(Spatial_searching_test_Kd_tree_search - ${CGAL_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) gudhi_add_coverage_test(Spatial_searching_test_Kd_tree_search) endif () diff --git a/src/Tangential_complex/benchmark/CMakeLists.txt b/src/Tangential_complex/benchmark/CMakeLists.txt index ef772be8..8cb16e8c 100644 --- a/src/Tangential_complex/benchmark/CMakeLists.txt +++ b/src/Tangential_complex/benchmark/CMakeLists.txt @@ -4,7 +4,7 @@ project(Tangential_complex_benchmark) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) add_executable(Tangential_complex_benchmark benchmark_tc.cpp) target_link_libraries(Tangential_complex_benchmark - ${Boost_DATE_TIME_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY}) + ${Boost_DATE_TIME_LIBRARY} ${CGAL_LIBRARY}) if (TBB_FOUND) target_link_libraries(Tangential_complex_benchmark ${TBB_LIBRARIES}) endif(TBB_FOUND) diff --git a/src/Tangential_complex/test/CMakeLists.txt b/src/Tangential_complex/test/CMakeLists.txt index fc710676..1948c8f6 100644 --- a/src/Tangential_complex/test/CMakeLists.txt +++ b/src/Tangential_complex/test/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) include(GUDHI_test_coverage) add_executable( Tangential_complex_test_TC test_tangential_complex.cpp ) - target_link_libraries(Tangential_complex_test_TC ${CGAL_LIBRARY} ${Boost_DATE_TIME_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + target_link_libraries(Tangential_complex_test_TC ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Tangential_complex_test_TC ${TBB_LIBRARIES}) endif() diff --git a/src/Witness_complex/example/CMakeLists.txt b/src/Witness_complex/example/CMakeLists.txt index 1e18d024..cbc53902 100644 --- a/src/Witness_complex/example/CMakeLists.txt +++ b/src/Witness_complex/example/CMakeLists.txt @@ -2,7 +2,6 @@ cmake_minimum_required(VERSION 2.6) project(Witness_complex_examples) add_executable ( Witness_complex_example_nearest_landmark_table example_nearest_landmark_table.cpp ) -target_link_libraries(Witness_complex_example_nearest_landmark_table ${Boost_SYSTEM_LIBRARY}) if (TBB_FOUND) target_link_libraries(Witness_complex_example_nearest_landmark_table ${TBB_LIBRARIES}) endif() @@ -14,17 +13,14 @@ install(TARGETS Witness_complex_example_nearest_landmark_table DESTINATION bin) # CGAL and Eigen3 are required for Euclidean version of Witness if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.6.0) add_executable( Witness_complex_example_off example_witness_complex_off.cpp ) - target_link_libraries(Witness_complex_example_off ${Boost_SYSTEM_LIBRARY}) add_executable( Witness_complex_example_strong_off example_strong_witness_complex_off.cpp ) - target_link_libraries(Witness_complex_example_strong_off ${Boost_SYSTEM_LIBRARY}) add_executable ( Witness_complex_example_sphere example_witness_complex_sphere.cpp ) - target_link_libraries(Witness_complex_example_sphere ${Boost_SYSTEM_LIBRARY}) add_executable ( Witness_complex_example_witness_persistence example_witness_complex_persistence.cpp ) - target_link_libraries(Witness_complex_example_witness_persistence ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) + target_link_libraries(Witness_complex_example_witness_persistence ${Boost_PROGRAM_OPTIONS_LIBRARY}) add_executable ( Witness_complex_example_strong_witness_persistence example_strong_witness_persistence.cpp ) - target_link_libraries(Witness_complex_example_strong_witness_persistence ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) + target_link_libraries(Witness_complex_example_strong_witness_persistence ${Boost_PROGRAM_OPTIONS_LIBRARY}) if (TBB_FOUND) target_link_libraries(Witness_complex_example_witness_persistence ${TBB_LIBRARIES}) diff --git a/src/Witness_complex/test/CMakeLists.txt b/src/Witness_complex/test/CMakeLists.txt index 152e2f2c..0b523eaf 100644 --- a/src/Witness_complex/test/CMakeLists.txt +++ b/src/Witness_complex/test/CMakeLists.txt @@ -4,7 +4,7 @@ project(Witness_complex_tests) include(GUDHI_test_coverage) add_executable ( Witness_complex_test_simple_witness_complex test_simple_witness_complex.cpp ) -target_link_libraries(Witness_complex_test_simple_witness_complex ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +target_link_libraries(Witness_complex_test_simple_witness_complex ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Witness_complex_test_simple_witness_complex ${TBB_LIBRARIES}) endif(TBB_FOUND) @@ -14,7 +14,7 @@ gudhi_add_coverage_test(Witness_complex_test_simple_witness_complex) # CGAL and Eigen3 are required for Euclidean version of Witness if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.6.0) add_executable ( Witness_complex_test_euclidean_simple_witness_complex test_euclidean_simple_witness_complex.cpp ) - target_link_libraries(Witness_complex_test_euclidean_simple_witness_complex ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + target_link_libraries(Witness_complex_test_euclidean_simple_witness_complex ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Witness_complex_test_euclidean_simple_witness_complex ${TBB_LIBRARIES}) endif(TBB_FOUND) diff --git a/src/common/example/CMakeLists.txt b/src/common/example/CMakeLists.txt index af3c2c9d..d0a3aa80 100644 --- a/src/common/example/CMakeLists.txt +++ b/src/common/example/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.6) project(Common_examples) add_executable ( vector_double_off_reader example_vector_double_points_off_reader.cpp ) -target_link_libraries(vector_double_off_reader ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY}) +target_link_libraries(vector_double_off_reader ${CGAL_LIBRARY}) add_test(NAME Common_example_vector_double_off_reader COMMAND $ "${CMAKE_SOURCE_DIR}/data/points/SO3_10000.off") @@ -10,14 +10,14 @@ install(TARGETS vector_double_off_reader DESTINATION bin) if(CGAL_FOUND) add_executable ( cgal_3D_off_reader example_CGAL_3D_points_off_reader.cpp ) - target_link_libraries(cgal_3D_off_reader ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY}) + target_link_libraries(cgal_3D_off_reader ${CGAL_LIBRARY}) add_test(NAME Common_example_vector_cgal_3D_off_reader COMMAND $ "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off") # need CGAL 4.7and Eigen3 if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0) add_executable ( cgal_off_reader example_CGAL_points_off_reader.cpp ) - target_link_libraries(cgal_off_reader ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY}) + target_link_libraries(cgal_off_reader ${CGAL_LIBRARY}) add_test(NAME Common_example_vector_cgal_off_reader COMMAND $ "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off") endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0) diff --git a/src/common/test/CMakeLists.txt b/src/common/test/CMakeLists.txt index c695fbf4..5aa426d7 100644 --- a/src/common/test/CMakeLists.txt +++ b/src/common/test/CMakeLists.txt @@ -4,10 +4,10 @@ project(Common_tests) include(GUDHI_test_coverage) add_executable ( Common_test_points_off_reader test_points_off_reader.cpp ) -target_link_libraries(Common_test_points_off_reader ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +target_link_libraries(Common_test_points_off_reader ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) add_executable ( Common_test_distance_matrix_reader test_distance_matrix_reader.cpp ) -target_link_libraries(Common_test_distance_matrix_reader ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +target_link_libraries(Common_test_distance_matrix_reader ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) # Do not forget to copy test files in current binary dir file(COPY "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) diff --git a/src/common/utilities/CMakeLists.txt b/src/common/utilities/CMakeLists.txt index c2e07e7e..b3e4b436 100644 --- a/src/common/utilities/CMakeLists.txt +++ b/src/common/utilities/CMakeLists.txt @@ -3,7 +3,6 @@ project(off_file_from_shape_generator) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.6.0) add_executable ( off_file_from_shape_generator off_file_from_shape_generator.cpp ) - target_link_libraries(off_file_from_shape_generator ${Boost_SYSTEM_LIBRARY}) add_test(NAME off_file_from_shape_generator_on_sphere_1000_3_15.2 COMMAND $ "on" "sphere" "onSphere.off" "1000" "3" "15.2") add_test(NAME off_file_from_shape_generator_in_sphere_100_2 COMMAND $ -- cgit v1.2.3 From 65bd15c84df2bf660918fcbf35a87b22510640cb Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 2 Jun 2017 16:59:15 +0000 Subject: Fix install issue git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/boost_system_no_deprecated_test@2510 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: c081183c9876761dace595a09ec04fe220846ed6 --- src/common/example/CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/common/example/CMakeLists.txt b/src/common/example/CMakeLists.txt index d0a3aa80..afe865d4 100644 --- a/src/common/example/CMakeLists.txt +++ b/src/common/example/CMakeLists.txt @@ -14,14 +14,15 @@ if(CGAL_FOUND) add_test(NAME Common_example_vector_cgal_3D_off_reader COMMAND $ "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off") - # need CGAL 4.7and Eigen3 + install(TARGETS cgal_3D_off_reader DESTINATION bin) + + # need CGAL 4.7 and Eigen3 if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0) add_executable ( cgal_off_reader example_CGAL_points_off_reader.cpp ) target_link_libraries(cgal_off_reader ${CGAL_LIBRARY}) add_test(NAME Common_example_vector_cgal_off_reader COMMAND $ "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off") + install(TARGETS cgal_off_reader DESTINATION bin) endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0) - install(TARGETS cgal_3D_off_reader DESTINATION bin) - install(TARGETS cgal_off_reader DESTINATION bin) endif() -- cgit v1.2.3 From f5d28342ee398c739c7345d8db4fbd653e9a0413 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 8 Jun 2017 07:17:36 +0000 Subject: Add modules as CMake options in order to be able to activate/desactivate compilation git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cmake_modules_for_gudhi@2515 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 53d5e669ad310c9d8d17c7f95f1e07c3bf658d77 --- CMakeLists.txt | 18 ++++-------------- src/CMakeLists.txt | 8 ++++---- src/cmake/modules/GUDHI_modules.cmake | 23 +++++++++++++++++++---- src/cmake/modules/GUDHI_user_version_target.cmake | 4 ++-- 4 files changed, 29 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c9ceb92b..fbb359e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,10 +3,7 @@ project(GUDHIdev) include(CMakeGUDHIVersion.txt) -set(CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/src/cmake/modules/") -set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/src/cmake/modules/") -message("CMAKE_PREFIX_PATH = ${CMAKE_PREFIX_PATH}") -message("CMAKE_MODULE_PATH = ${CMAKE_MODULE_PATH}") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/src/cmake/modules/") enable_testing() @@ -34,10 +31,8 @@ if (DEBUG_TRACES) add_definitions(-DDEBUG_TRACES) endif() -# Modules list can be found in CMAKE_MODULE_PATH/GUDHI_modules.cmake -include(GUDHI_modules) - # Add your new module in the list, order is not important +include(GUDHI_modules) add_gudhi_module(common) add_gudhi_module(Alpha_complex) @@ -54,12 +49,7 @@ add_gudhi_module(Subsampling) add_gudhi_module(Tangential_complex) add_gudhi_module(Witness_complex) -# Include module headers -foreach(GUDHI_MODULE ${GUDHI_MODULES}) - if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/src/${GUDHI_MODULE}/include/) - include_directories(src/${GUDHI_MODULE}/include/) - endif() -endforeach() +message("++ GUDHI_MODULES list is:\"${GUDHI_MODULES}\"") # Include module CMake subdirectories # GUDHI_SUB_DIRECTORIES is managed in CMAKE_MODULE_PATH/GUDHI_modules.cmake @@ -73,7 +63,7 @@ endforeach() add_subdirectory(src/GudhUI) -if (NOT WITHOUT_GUDHI_PYTHON) +if (WITH_GUDHI_PYTHON) # specific for cython module add_subdirectory(${GUDHI_CYTHON_PATH}) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8abfcf44..795005b1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,10 +7,8 @@ enable_testing() list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/") -# To be done first - Modules list can be found in CMAKE_MODULE_PATH/GUDHI_modules.cmake -include(GUDHI_modules) - # Add your new module in the list, order is not important +include(GUDHI_modules) add_gudhi_module(common) add_gudhi_module(Alpha_complex) @@ -27,6 +25,8 @@ add_gudhi_module(Subsampling) add_gudhi_module(Tangential_complex) add_gudhi_module(Witness_complex) +message("++ GUDHI_MODULES list is:\"${GUDHI_MODULES}\"") + # For "make doxygen" - Requires GUDHI_USER_VERSION_DIR to be set set(GUDHI_USER_VERSION_DIR ${CMAKE_SOURCE_DIR}) include(GUDHI_doxygen_target) @@ -71,7 +71,7 @@ endforeach() add_subdirectory(GudhUI) -if (NOT WITHOUT_GUDHI_PYTHON) +if (WITH_GUDHI_PYTHON) # specific for cython module add_subdirectory(${GUDHI_CYTHON_PATH}) endif() diff --git a/src/cmake/modules/GUDHI_modules.cmake b/src/cmake/modules/GUDHI_modules.cmake index 20fc8d17..f95d0c34 100644 --- a/src/cmake/modules/GUDHI_modules.cmake +++ b/src/cmake/modules/GUDHI_modules.cmake @@ -1,11 +1,26 @@ # A function to add a new module in GUDHI set(GUDHI_MODULES "") +set(GUDHI_MODULES_FULL_LIST "") function(add_gudhi_module file_path) + option("WITH_MODULE_GUDHI_${file_path}" "Activate/desactivate ${file_path} compilation and installation" ON) + if (WITH_MODULE_GUDHI_${file_path}) set(GUDHI_MODULES ${GUDHI_MODULES} ${file_path} PARENT_SCOPE) + endif() + # Required by user_version + set(GUDHI_MODULES_FULL_LIST ${GUDHI_MODULES_FULL_LIST} ${file_path} PARENT_SCOPE) + # Include module headers is independant - You may ask for no Alpha complex module but Python interface i.e. + if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/src/${file_path}/include/) + include_directories(src/${file_path}/include/) + endif() + endfunction(add_gudhi_module) -# message("++ GUDHI_MODULES list is:\"${GUDHI_MODULES}\"") +option(WITH_GUDHI_BENCHMARK "Activate/desactivate benchmark compilation" OFF) +option(WITH_GUDHI_EXAMPLE "Activate/desactivate examples compilation and installation" OFF) +option(WITH_GUDHI_PYTHON "Activate/desactivate python module compilation and installation" ON) +option(WITH_GUDHI_TEST "Activate/desactivate examples compilation and installation" ON) +option(WITH_GUDHI_UTILITIES "Activate/desactivate utilities compilation and installation" ON) if (WITH_GUDHI_BENCHMARK) set(GUDHI_SUB_DIRECTORIES "${GUDHI_SUB_DIRECTORIES};benchmark") @@ -13,10 +28,10 @@ endif() if (WITH_GUDHI_EXAMPLE) set(GUDHI_SUB_DIRECTORIES "${GUDHI_SUB_DIRECTORIES};example") endif() -if (NOT WITHOUT_GUDHI_TEST) - set(GUDHI_SUB_DIRECTORIES "${GUDHI_SUB_DIRECTORIES};test") +if (WITH_GUDHI_TEST) + set(GUDHI_SUB_DIRECTORIES "${GUDHI_SUB_DIRECTORIES};test") endif() -if (NOT WITHOUT_GUDHI_UTILITIES) +if (WITH_GUDHI_UTILITIES) set(GUDHI_SUB_DIRECTORIES "${GUDHI_SUB_DIRECTORIES};utilities") endif() diff --git a/src/cmake/modules/GUDHI_user_version_target.cmake b/src/cmake/modules/GUDHI_user_version_target.cmake index 8642d3bf..cff64ad2 100644 --- a/src/cmake/modules/GUDHI_user_version_target.cmake +++ b/src/cmake/modules/GUDHI_user_version_target.cmake @@ -50,7 +50,7 @@ if (NOT CMAKE_VERSION VERSION_LESS 2.8.11) set(GUDHI_DIRECTORIES "doc;example;concept;utilities") set(GUDHI_INCLUDE_DIRECTORIES "include/gudhi;include/gudhi_patches") - foreach(GUDHI_MODULE ${GUDHI_MODULES}) + foreach(GUDHI_MODULE ${GUDHI_MODULES_FULL_LIST}) foreach(GUDHI_DIRECTORY ${GUDHI_DIRECTORIES}) # Find files file(GLOB GUDHI_FILES ${CMAKE_SOURCE_DIR}/src/${GUDHI_MODULE}/${GUDHI_DIRECTORY}/*) @@ -85,6 +85,6 @@ if (NOT CMAKE_VERSION VERSION_LESS 2.8.11) endforeach() endforeach(GUDHI_INCLUDE_DIRECTORY ${GUDHI_INCLUDE_DIRECTORIES}) - endforeach(GUDHI_MODULE ${GUDHI_MODULES}) + endforeach(GUDHI_MODULE ${GUDHI_MODULES_FULL_LIST}) endif() -- cgit v1.2.3 From 41991433af57269f1328c7c67e26eb111b060fa2 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 9 Jun 2017 06:19:25 +0000 Subject: Add BOOST_SYSTEM_NO_DEPRECATED definition git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/boost_system_no_deprecated_test@2524 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 4718264666a9289a46f282cfcf3200481966c0db --- src/cmake/modules/GUDHI_third_party_libraries.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmake/modules/GUDHI_third_party_libraries.cmake b/src/cmake/modules/GUDHI_third_party_libraries.cmake index 7b0cda3b..5bee774a 100644 --- a/src/cmake/modules/GUDHI_third_party_libraries.cmake +++ b/src/cmake/modules/GUDHI_third_party_libraries.cmake @@ -100,7 +100,7 @@ add_definitions(-DBOOST_ALL_NO_LIB) # problem with Visual Studio link on Boost program_options add_definitions( -DBOOST_ALL_DYN_LINK ) # problem on Mac with boost_system and boost_thread -#add_definitions( -DBOOST_SYSTEM_NO_DEPRECATED ) +add_definitions( -DBOOST_SYSTEM_NO_DEPRECATED ) INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) LINK_DIRECTORIES(${Boost_LIBRARY_DIRS}) -- cgit v1.2.3 From 25b640d65879b719094e8d0e923812c2658c85c3 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 9 Jun 2017 07:01:18 +0000 Subject: Tangential complex test must link with boost date time library git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/boost_system_no_deprecated_test@2525 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 2f62d58f2915eead697ba5fbb02e69719f6e471a --- src/Tangential_complex/test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tangential_complex/test/CMakeLists.txt b/src/Tangential_complex/test/CMakeLists.txt index 1948c8f6..63e51c3e 100644 --- a/src/Tangential_complex/test/CMakeLists.txt +++ b/src/Tangential_complex/test/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) include(GUDHI_test_coverage) add_executable( Tangential_complex_test_TC test_tangential_complex.cpp ) - target_link_libraries(Tangential_complex_test_TC ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + target_link_libraries(Tangential_complex_test_TC ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${Boost_DATE_TIME_LIBRARY}) if (TBB_FOUND) target_link_libraries(Tangential_complex_test_TC ${TBB_LIBRARIES}) endif() -- cgit v1.2.3 From 4adbd857ff2ac187b5dfcfa25c37f32b887ae69b Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 9 Jun 2017 07:48:54 +0000 Subject: No more need of find_the_lib cmake macro to find Windows boost lib name Fix cmake warning on if with quotes git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/boost_system_no_deprecated_test@2527 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: a352820ab0a596961b9851d4a30c40196a70ff98 --- src/cmake/modules/GUDHI_third_party_libraries.cmake | 13 ------------- src/cython/CMakeLists.txt | 4 ++-- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/src/cmake/modules/GUDHI_third_party_libraries.cmake b/src/cmake/modules/GUDHI_third_party_libraries.cmake index 5bee774a..b4f3eb52 100644 --- a/src/cmake/modules/GUDHI_third_party_libraries.cmake +++ b/src/cmake/modules/GUDHI_third_party_libraries.cmake @@ -108,19 +108,6 @@ LINK_DIRECTORIES(${Boost_LIBRARY_DIRS}) message(STATUS "boost include dirs:" ${Boost_INCLUDE_DIRS}) message(STATUS "boost library dirs:" ${Boost_LIBRARY_DIRS}) -macro( find_the_lib placeholder THE_LIBS ) - set (THE_LIB_WE_FOUND "NO") - foreach(THE_LIB ${THE_LIBS}) - if(EXISTS ${THE_LIB}) - get_filename_component(THE_LIB_WE ${THE_LIB} NAME_WE) - if (NOT THE_LIB_WE_FOUND) - set (THE_LIB_WE_FOUND "YES") - set(returnValue "${THE_LIB_WE}") - endif(NOT THE_LIB_WE_FOUND) - endif(EXISTS ${THE_LIB}) - endforeach(THE_LIB ${THE_LIBS}) -endmacro( find_the_lib ) - # Find the correct Python interpreter. # Can be set with -DPYTHON_EXECUTABLE=/usr/bin/python3 or -DPython_ADDITIONAL_VERSIONS=3 for instance. find_package(Cython) diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index 4b56122d..adcc64e4 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -17,9 +17,9 @@ if(CYTHON_FOUND) if(CMAKE_COMPILER_IS_GNUCXX) set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-frounding-math', ") endif(CMAKE_COMPILER_IS_GNUCXX) - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") + if (CMAKE_CXX_COMPILER_ID MATCHES Intel) set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-fp-model strict', ") - endif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") + endif(CMAKE_CXX_COMPILER_ID MATCHES Intel) if (DEBUG_TRACES) # For programs to be more verbose set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DDEBUG_TRACES', ") -- cgit v1.2.3 From 26ccabbd6892ddc5313a7f75c98a92c268f15747 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 9 Jun 2017 08:39:16 +0000 Subject: Remove boost timer and chrono dependencies git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/boost_system_no_deprecated_test@2528 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 5bfb8bd5a6e49dbea9fbfbdc1d748423fc930913 --- src/Contraction/example/CMakeLists.txt | 4 ---- src/Contraction/example/Garland_heckbert.cpp | 3 --- src/Contraction/example/Rips_contraction.cpp | 6 ------ src/Skeleton_blocker/example/CMakeLists.txt | 2 -- src/Skeleton_blocker/example/Skeleton_blocker_iteration.cpp | 4 ---- src/cmake/modules/GUDHI_third_party_libraries.cmake | 2 +- 6 files changed, 1 insertion(+), 20 deletions(-) diff --git a/src/Contraction/example/CMakeLists.txt b/src/Contraction/example/CMakeLists.txt index 6443323d..83594c0e 100644 --- a/src/Contraction/example/CMakeLists.txt +++ b/src/Contraction/example/CMakeLists.txt @@ -5,10 +5,6 @@ project(Contraction_examples) add_executable(RipsContraction Rips_contraction.cpp) add_executable(GarlandHeckbert Garland_heckbert.cpp) -target_link_libraries(RipsContraction ${Boost_TIMER_LIBRARY}) -target_link_libraries(GarlandHeckbert ${Boost_TIMER_LIBRARY}) - - add_test(NAME Contraction_example_tore3D_0.2 COMMAND $ "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "0.2") # TODO(DS) : These tests are too long under Windows diff --git a/src/Contraction/example/Garland_heckbert.cpp b/src/Contraction/example/Garland_heckbert.cpp index 8b5a6a6c..2b0dc973 100644 --- a/src/Contraction/example/Garland_heckbert.cpp +++ b/src/Contraction/example/Garland_heckbert.cpp @@ -30,7 +30,6 @@ #include #include -#include #include #include "Garland_heckbert/Error_quadric.h" @@ -165,8 +164,6 @@ int main(int argc, char *argv[]) { int num_contractions = atoi(argv[3]); - boost::timer::auto_cpu_timer t; - // constructs the contractor object with Garland Heckbert policies. Complex_contractor contractor(complex, new GH_cost(complex), diff --git a/src/Contraction/example/Rips_contraction.cpp b/src/Contraction/example/Rips_contraction.cpp index 8289b1d3..1b97f877 100644 --- a/src/Contraction/example/Rips_contraction.cpp +++ b/src/Contraction/example/Rips_contraction.cpp @@ -24,7 +24,6 @@ #include #include -#include #include struct Geometry_trait { @@ -68,8 +67,6 @@ int main(int argc, char *argv[]) { build_rips(complex, atof(argv[2])); - boost::timer::auto_cpu_timer t; - std::cout << "Initial complex has " << complex.num_vertices() << " vertices and " << complex.num_edges() << " edges" << std::endl; @@ -90,9 +87,6 @@ int main(int argc, char *argv[]) { complex.num_blockers() << " blockers and " << num_simplices << " simplices" << std::endl; - - std::cout << "Time to simplify and enumerate simplices:\n"; - return EXIT_SUCCESS; } diff --git a/src/Skeleton_blocker/example/CMakeLists.txt b/src/Skeleton_blocker/example/CMakeLists.txt index 6d685717..de70f089 100644 --- a/src/Skeleton_blocker/example/CMakeLists.txt +++ b/src/Skeleton_blocker/example/CMakeLists.txt @@ -5,8 +5,6 @@ add_executable(Skeleton_blocker_example_from_simplices Skeleton_blocker_from_sim add_executable(Skeleton_blocker_example_iteration Skeleton_blocker_iteration.cpp) add_executable(Skeleton_blocker_example_link Skeleton_blocker_link.cpp) -target_link_libraries(Skeleton_blocker_example_iteration ${Boost_TIMER_LIBRARY}) - add_test(NAME Skeleton_blocker_example_from_simplices COMMAND $) add_test(NAME Skeleton_blocker_example_iteration COMMAND $) add_test(NAME Skeleton_blocker_example_link COMMAND $) diff --git a/src/Skeleton_blocker/example/Skeleton_blocker_iteration.cpp b/src/Skeleton_blocker/example/Skeleton_blocker_iteration.cpp index 6a1bc480..4a0044e1 100644 --- a/src/Skeleton_blocker/example/Skeleton_blocker_iteration.cpp +++ b/src/Skeleton_blocker/example/Skeleton_blocker_iteration.cpp @@ -22,8 +22,6 @@ #include -#include - #include #include #include @@ -47,8 +45,6 @@ Complex build_complete_complex(int n) { } int main(int argc, char *argv[]) { - boost::timer::auto_cpu_timer t; - const int n = 15; // build a full complex with n vertices and 2^n-1 simplices diff --git a/src/cmake/modules/GUDHI_third_party_libraries.cmake b/src/cmake/modules/GUDHI_third_party_libraries.cmake index b4f3eb52..2be79ee4 100644 --- a/src/cmake/modules/GUDHI_third_party_libraries.cmake +++ b/src/cmake/modules/GUDHI_third_party_libraries.cmake @@ -1,6 +1,6 @@ # This files manage third party libraries required by GUDHI -find_package(Boost REQUIRED COMPONENTS system filesystem unit_test_framework chrono timer date_time program_options thread) +find_package(Boost REQUIRED COMPONENTS system filesystem unit_test_framework date_time program_options thread) if(NOT Boost_FOUND) message(FATAL_ERROR "NOTICE: This program requires Boost and will not be compiled.") -- cgit v1.2.3 From 05de4e9f4ed8f74e53a11455bc50470beba908eb Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 9 Jun 2017 09:40:52 +0000 Subject: Remove boost date_time dependencies git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/boost_system_no_deprecated_test@2529 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: daa13fc0046ffdd72577bb1b399fcbdc8ef5033c --- src/Tangential_complex/benchmark/CMakeLists.txt | 3 +-- src/Tangential_complex/example/CMakeLists.txt | 4 ++-- src/Tangential_complex/test/CMakeLists.txt | 2 +- src/cmake/modules/GUDHI_third_party_libraries.cmake | 2 +- src/common/include/gudhi/Clock.h | 18 +++++++++--------- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/Tangential_complex/benchmark/CMakeLists.txt b/src/Tangential_complex/benchmark/CMakeLists.txt index 8cb16e8c..8729e394 100644 --- a/src/Tangential_complex/benchmark/CMakeLists.txt +++ b/src/Tangential_complex/benchmark/CMakeLists.txt @@ -3,8 +3,7 @@ project(Tangential_complex_benchmark) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) add_executable(Tangential_complex_benchmark benchmark_tc.cpp) - target_link_libraries(Tangential_complex_benchmark - ${Boost_DATE_TIME_LIBRARY} ${CGAL_LIBRARY}) + target_link_libraries(Tangential_complex_benchmark ${CGAL_LIBRARY}) if (TBB_FOUND) target_link_libraries(Tangential_complex_benchmark ${TBB_LIBRARIES}) endif(TBB_FOUND) diff --git a/src/Tangential_complex/example/CMakeLists.txt b/src/Tangential_complex/example/CMakeLists.txt index 45c7642b..16d1339d 100644 --- a/src/Tangential_complex/example/CMakeLists.txt +++ b/src/Tangential_complex/example/CMakeLists.txt @@ -3,9 +3,9 @@ project(Tangential_complex_examples) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) add_executable( Tangential_complex_example_basic example_basic.cpp ) - target_link_libraries(Tangential_complex_example_basic ${CGAL_LIBRARY} ${Boost_DATE_TIME_LIBRARY}) + target_link_libraries(Tangential_complex_example_basic ${CGAL_LIBRARY}) add_executable( Tangential_complex_example_with_perturb example_with_perturb.cpp ) - target_link_libraries(Tangential_complex_example_with_perturb ${CGAL_LIBRARY} ${Boost_DATE_TIME_LIBRARY}) + target_link_libraries(Tangential_complex_example_with_perturb ${CGAL_LIBRARY}) if (TBB_FOUND) target_link_libraries(Tangential_complex_example_basic ${TBB_LIBRARIES}) target_link_libraries(Tangential_complex_example_with_perturb ${TBB_LIBRARIES}) diff --git a/src/Tangential_complex/test/CMakeLists.txt b/src/Tangential_complex/test/CMakeLists.txt index 63e51c3e..1948c8f6 100644 --- a/src/Tangential_complex/test/CMakeLists.txt +++ b/src/Tangential_complex/test/CMakeLists.txt @@ -5,7 +5,7 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) include(GUDHI_test_coverage) add_executable( Tangential_complex_test_TC test_tangential_complex.cpp ) - target_link_libraries(Tangential_complex_test_TC ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${Boost_DATE_TIME_LIBRARY}) + target_link_libraries(Tangential_complex_test_TC ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Tangential_complex_test_TC ${TBB_LIBRARIES}) endif() diff --git a/src/cmake/modules/GUDHI_third_party_libraries.cmake b/src/cmake/modules/GUDHI_third_party_libraries.cmake index 2be79ee4..8f486118 100644 --- a/src/cmake/modules/GUDHI_third_party_libraries.cmake +++ b/src/cmake/modules/GUDHI_third_party_libraries.cmake @@ -1,6 +1,6 @@ # This files manage third party libraries required by GUDHI -find_package(Boost REQUIRED COMPONENTS system filesystem unit_test_framework date_time program_options thread) +find_package(Boost REQUIRED COMPONENTS system filesystem unit_test_framework program_options thread) if(NOT Boost_FOUND) message(FATAL_ERROR "NOTICE: This program requires Boost and will not be compiled.") diff --git a/src/common/include/gudhi/Clock.h b/src/common/include/gudhi/Clock.h index 77f196ca..eff48e41 100644 --- a/src/common/include/gudhi/Clock.h +++ b/src/common/include/gudhi/Clock.h @@ -23,9 +23,9 @@ #ifndef CLOCK_H_ #define CLOCK_H_ -#include - +#include #include +#include namespace Gudhi { @@ -33,20 +33,20 @@ class Clock { public: // Construct and start the timer Clock(const std::string& msg_ = std::string()) - : startTime(boost::posix_time::microsec_clock::local_time()), + : startTime(std::chrono::system_clock::now()), end_called(false), msg(msg_) { } // Restart the timer void begin() const { end_called = false; - startTime = boost::posix_time::microsec_clock::local_time(); + startTime = std::chrono::system_clock::now(); } // Stop the timer void end() const { end_called = true; - endTime = boost::posix_time::microsec_clock::local_time(); + endTime = std::chrono::system_clock::now(); } std::string message() const { @@ -71,15 +71,15 @@ class Clock { // - or now otherwise. In this case, the timer is not stopped. double num_seconds() const { if (!end_called) { - auto end = boost::posix_time::microsec_clock::local_time(); - return (end - startTime).total_milliseconds() / 1000.; + auto end = std::chrono::system_clock::now(); + return std::chrono::duration_cast(end-startTime).count() / 1000.; } else { - return (endTime - startTime).total_milliseconds() / 1000.; + return std::chrono::duration_cast(endTime-startTime).count() / 1000.; } } private: - mutable boost::posix_time::ptime startTime, endTime; + mutable std::chrono::time_point startTime, endTime; mutable bool end_called; std::string msg; }; -- cgit v1.2.3 From 8a0f3bf13633cc0608e19a724873dc57e833837b Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 9 Jun 2017 09:45:41 +0000 Subject: Homogenize DEFINE profiling name for subsampling git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/boost_system_no_deprecated_test@2530 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 99176a6381a5c81298d94a781b996904ff2e1acc --- src/Subsampling/include/gudhi/pick_n_random_points.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Subsampling/include/gudhi/pick_n_random_points.h b/src/Subsampling/include/gudhi/pick_n_random_points.h index f0e3f1f1..8c90b6bf 100644 --- a/src/Subsampling/include/gudhi/pick_n_random_points.h +++ b/src/Subsampling/include/gudhi/pick_n_random_points.h @@ -52,7 +52,7 @@ typename OutputIterator> void pick_n_random_points(Point_container const &points, std::size_t final_size, OutputIterator output_it) { -#ifdef GUDHI_SUBS_PROFILING +#ifdef GUDHI_SUBSAMPLING_PROFILING Gudhi::Clock t; #endif @@ -72,7 +72,7 @@ void pick_n_random_points(Point_container const &points, for (int l : landmarks) *output_it++ = points[l]; -#ifdef GUDHI_SUBS_PROFILING +#ifdef GUDHI_SUBSAMPLING_PROFILING t.end(); std::cerr << "Random landmark choice took " << t.num_seconds() << " seconds." << std::endl; -- cgit v1.2.3 From 3a7ffc0bfec712cb586d5c7ea154a4fd20be1a39 Mon Sep 17 00:00:00 2001 From: cjamin Date: Fri, 9 Jun 2017 10:32:48 +0000 Subject: Change names and adapt example git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/read_persistence_from_file@2531 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 833a51dd03ddccca38c6011834bb58667d63ccbf --- .../example/bottleneck_read_file_example.cpp | 4 ++-- src/common/include/gudhi/reader_utils.h | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp b/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp index de8c7f9d..94d9a148 100644 --- a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp +++ b/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp @@ -35,8 +35,8 @@ int main(int argc, char** argv) { "should contain a birth-death pair per line. Third, optional parameter is an error bound on a bottleneck" << " distance (set by default to zero). The program will now terminate \n"; } - std::vector> diag1 = read_persistence_diagram_from_file(argv[1], -1); - std::vector> diag2 = read_persistence_diagram_from_file(argv[2], -1); + std::vector> diag1 = read_persistence_intervals_in_dimension(argv[1]); + std::vector> diag2 = read_persistence_intervals_in_dimension(argv[2]); double tolerance = 0.; if (argc == 4) { diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index f0903acc..62b479ac 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -304,7 +304,7 @@ The output iterator `out` is used this way: `*out++ = std::make_tuple(dim, birth where `dim` is an `int`, `birth` a `double`, and `death` a `double`. **/ template -void read_persistence_diagram_from_file(std::string const& filename, OutputIterator out) { +void read_persistence_intervals_and_dimension(std::string const& filename, OutputIterator out) { std::ifstream in(filename); if (!in.is_open()) { @@ -336,10 +336,10 @@ Each line might contain 2, 3 or 4 values: [[field] dimension] birth death The return value is an `std::map>>` where `dim` is an `int`, `birth` a `double`, and `death` a `double`. **/ -std::map>> read_persistence_diagram_from_file(std::string const& filename) { +std::map>> read_persistence_intervals_grouped_by_dimension(std::string const& filename) { std::map>> ret; - read_persistence_diagram_from_file( + read_persistence_intervals_and_dimension( filename, boost::make_function_output_iterator([&ret](auto t) { ret[get<0>(t)].push_back(std::make_pair(get<1>(t), get<2>(t))); })); return ret; @@ -355,10 +355,10 @@ If `only_this_dim` is >= 0, only the lines where dimension = `only_this_dim` The return value is an `std::vector>` where `dim` is an `int`, `birth` a `double`, and `death` a `double`. **/ -std::vector> read_persistence_diagram_from_file(std::string const& filename, int only_this_dim) { +std::vector> read_persistence_intervals_in_dimension(std::string const& filename, int only_this_dim = -1) { std::vector> ret; - read_persistence_diagram_from_file( + read_persistence_intervals_and_dimension( filename, boost::make_function_output_iterator([&ret](auto t) { ret.emplace_back(get<1>(t), get<2>(t)); })); return ret; -- cgit v1.2.3 From 2ceede5cd9f226e66bb1ecbe1798330c349c2aa0 Mon Sep 17 00:00:00 2001 From: cjamin Date: Fri, 9 Jun 2017 10:39:31 +0000 Subject: Missing "return" git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/read_persistence_from_file@2532 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 8905e0d3406cbe26615b83ab7056e7fd5bd8ed0e --- src/Bottleneck_distance/example/bottleneck_read_file_example.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp b/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp index 94d9a148..6cfbeafa 100644 --- a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp +++ b/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp @@ -34,6 +34,7 @@ int main(int argc, char** argv) { std::cout << "To run this program please provide as an input two files with persistence diagrams. Each file " << "should contain a birth-death pair per line. Third, optional parameter is an error bound on a bottleneck" << " distance (set by default to zero). The program will now terminate \n"; + //return -1; } std::vector> diag1 = read_persistence_intervals_in_dimension(argv[1]); std::vector> diag2 = read_persistence_intervals_in_dimension(argv[2]); @@ -44,4 +45,6 @@ int main(int argc, char** argv) { } double b = Gudhi::persistence_diagram::bottleneck_distance(diag1, diag2, tolerance); std::cout << "The distance between the diagrams is : " << b << ". The tolerance is : " << tolerance << std::endl; + + return 0; } -- cgit v1.2.3 From 4918b9c752a2d269678791dc4772ae9276539051 Mon Sep 17 00:00:00 2001 From: cjamin Date: Fri, 9 Jun 2017 10:42:12 +0000 Subject: Throw exceptions if file not found git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/read_persistence_from_file@2533 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: b412f432aeac6aef07ac2d9d65d50dc8f508c2e6 --- src/common/include/gudhi/reader_utils.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index 62b479ac..35af09bd 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -94,7 +94,10 @@ template< typename Graph_t, typename Filtration_value, typename Vertex_handle > Graph_t read_graph(std::string file_name) { std::ifstream in_(file_name.c_str(), std::ios::in); if (!in_.is_open()) { - std::cerr << "Unable to open file " << file_name << std::endl; + std::string error_str("read_graph - Unable to open file "); + error_str.append(file_name); + std::cerr << error_str << std::endl; + throw std::invalid_argument(error_str); } typedef std::pair< Vertex_handle, Vertex_handle > Edge_t; @@ -308,10 +311,10 @@ void read_persistence_intervals_and_dimension(std::string const& filename, Outpu std::ifstream in(filename); if (!in.is_open()) { -#ifdef DEBUG_TRACES - std::cerr << "File \"" << filename << "\" does not exist.\n"; -#endif // DEBUG_TRACES - return; + std::string error_str("read_persistence_intervals_and_dimension - Unable to open file "); + error_str.append(filename); + std::cerr << error_str << std::endl; + throw std::invalid_argument(error_str); } while (!in.eof()) { -- cgit v1.2.3 From 93c97a9a93b930a2f3c1c119d9e4d2567c54dacc Mon Sep 17 00:00:00 2001 From: cjamin Date: Fri, 9 Jun 2017 11:20:13 +0000 Subject: Create a new page for file formats git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/read_persistence_from_file@2534 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: dc0d836b9df68a3f339dcbc6b8ff51577faf3d7b --- src/common/doc/file_formats.h | 25 +++++++++++++++++++++++++ src/common/doc/main_page.h | 23 ++--------------------- 2 files changed, 27 insertions(+), 21 deletions(-) create mode 100644 src/common/doc/file_formats.h diff --git a/src/common/doc/file_formats.h b/src/common/doc/file_formats.h new file mode 100644 index 00000000..1f7ba201 --- /dev/null +++ b/src/common/doc/file_formats.h @@ -0,0 +1,25 @@ +/*! \page fileformats File formats + + \tableofcontents + + \section FileFormatsPers Persistence Diagram + + Such a file, whose extension is usually `.pers`, contains a list of persistence intervals.
+ Lines starting with `#` are ignored (comments).
+ Other lines might contain 2, 3 or 4 values (the number of values on each line must be the same for all lines): + \code{.unparsed} + [[field] dimension] birth death + \endcode + + Here is a simple sample file: + \code{.unparsed} + # Beautiful persistence diagram + 2 2.7 3.7 + 2 9.6 14. + 3 34.2 34.974 + 4 3. inf + \endcode + + Other sample files can be found in the `data/persistence_diagram` folder. + +*/ \ No newline at end of file diff --git a/src/common/doc/main_page.h b/src/common/doc/main_page.h index fba0a858..b7f93ed2 100644 --- a/src/common/doc/main_page.h +++ b/src/common/doc/main_page.h @@ -152,27 +152,7 @@
\section Toolbox Toolbox - \subsection FileFormats File Formats - \subsubsection FileFormatsPers Persistence Diagram - - Such a file, whose extension is usually `.pers`, contains a list of persistence intervals.
- Lines starting with `#` are ignored (comments).
- Other lines might contain 2, 3 or 4 values (the number of values on each line must be the same for all lines): - \code{.unparsed} - [[field] dimension] birth death - \endcode - - Here is a simple sample file: - \code{.unparsed} - # Beautiful persistence diagram - 2 2.7 3.7 - 2 9.6 14. - 3 34.2 34.974 - 4 3. inf - \endcode - - Other sample files can be found in the `data/persistence_diagram`. - + \subsection BottleneckDistanceToolbox Bottleneck distance \image html "perturb_pd.png" "Bottleneck distance is the length of the longest edge" @@ -489,3 +469,4 @@ make doxygen * @example Witness_complex/example_witness_complex_sphere.cpp */ +#include "file_formats.h" \ No newline at end of file -- cgit v1.2.3 From 7260c86a2158b0df3f33b49f314201dd51044563 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 9 Jun 2017 12:20:12 +0000 Subject: Rewrite Contraction and Skeleton blocker time display using Gudhi::Clock git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/boost_system_no_deprecated_test@2535 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: e2b5c1e152fd7bdca9d07db0390944409942ba53 --- src/Contraction/example/Garland_heckbert.cpp | 5 +++++ src/Contraction/example/Rips_contraction.cpp | 5 +++++ src/Skeleton_blocker/example/Skeleton_blocker_iteration.cpp | 3 +++ src/common/include/gudhi/Clock.h | 2 +- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Contraction/example/Garland_heckbert.cpp b/src/Contraction/example/Garland_heckbert.cpp index 2b0dc973..f0cde95e 100644 --- a/src/Contraction/example/Garland_heckbert.cpp +++ b/src/Contraction/example/Garland_heckbert.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -164,6 +165,8 @@ int main(int argc, char *argv[]) { int num_contractions = atoi(argv[3]); + Gudhi::Clock contraction_chrono("Time to simplify and enumerate simplices"); + // constructs the contractor object with Garland Heckbert policies. Complex_contractor contractor(complex, new GH_cost(complex), @@ -179,6 +182,8 @@ int main(int argc, char *argv[]) { complex.num_edges() << " edges and " << complex.num_triangles() << " triangles." << std::endl; + std::cout << contraction_chrono; + // write simplified complex Gudhi::skeleton_blocker::Skeleton_blocker_off_writer off_writer(argv[2], complex); diff --git a/src/Contraction/example/Rips_contraction.cpp b/src/Contraction/example/Rips_contraction.cpp index 1b97f877..501b0e87 100644 --- a/src/Contraction/example/Rips_contraction.cpp +++ b/src/Contraction/example/Rips_contraction.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -67,6 +68,8 @@ int main(int argc, char *argv[]) { build_rips(complex, atof(argv[2])); + Gudhi::Clock contraction_chrono("Time to simplify and enumerate simplices"); + std::cout << "Initial complex has " << complex.num_vertices() << " vertices and " << complex.num_edges() << " edges" << std::endl; @@ -87,6 +90,8 @@ int main(int argc, char *argv[]) { complex.num_blockers() << " blockers and " << num_simplices << " simplices" << std::endl; + std::cout << contraction_chrono; + return EXIT_SUCCESS; } diff --git a/src/Skeleton_blocker/example/Skeleton_blocker_iteration.cpp b/src/Skeleton_blocker/example/Skeleton_blocker_iteration.cpp index 4a0044e1..08ff0264 100644 --- a/src/Skeleton_blocker/example/Skeleton_blocker_iteration.cpp +++ b/src/Skeleton_blocker/example/Skeleton_blocker_iteration.cpp @@ -21,6 +21,7 @@ */ #include +#include #include #include @@ -45,6 +46,7 @@ Complex build_complete_complex(int n) { } int main(int argc, char *argv[]) { + Gudhi::Clock skbl_chrono("Time to build the complete complex, enumerate simplices and Euler Characteristic"); const int n = 15; // build a full complex with n vertices and 2^n-1 simplices @@ -78,5 +80,6 @@ int main(int argc, char *argv[]) { std::cout << "Saw " << num_vertices << " vertices, " << num_edges << " edges and " << num_simplices << " simplices" << std::endl; std::cout << "The Euler Characteristic is " << euler << std::endl; + std::cout << skbl_chrono; return EXIT_SUCCESS; } diff --git a/src/common/include/gudhi/Clock.h b/src/common/include/gudhi/Clock.h index eff48e41..b83de2f5 100644 --- a/src/common/include/gudhi/Clock.h +++ b/src/common/include/gudhi/Clock.h @@ -62,7 +62,7 @@ class Clock { if (!clock.msg.empty()) stream << clock.msg << ": "; - stream << clock.num_seconds() << "s"; + stream << clock.num_seconds() << "s\n"; return stream; } -- cgit v1.2.3 From 8b8689e9dc0c9970eee7c75cb8ea08433ce28196 Mon Sep 17 00:00:00 2001 From: cjamin Date: Tue, 13 Jun 2017 13:37:48 +0000 Subject: Add header and namespace + remove unnecessary include git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/read_persistence_from_file@2537 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: fc2da43c18649c606ac4760a923684f9eef0c95e --- src/common/doc/file_formats.h | 33 +++++++++++++++++++++++++++++++-- src/common/doc/main_page.h | 3 +-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/common/doc/file_formats.h b/src/common/doc/file_formats.h index 1f7ba201..c145b271 100644 --- a/src/common/doc/file_formats.h +++ b/src/common/doc/file_formats.h @@ -1,3 +1,30 @@ +/* This file is part of the Gudhi Library. The Gudhi library +* (Geometric Understanding in Higher Dimensions) is a generic C++ +* library for computational topology. +* +* Author(s): Clément Jamin +* +* Copyright (C) 2017 INRIA +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +#ifndef DOC_COMMON_FILE_FORMAT_H_ +#define DOC_COMMON_FILE_FORMAT_H_ + +namespace Gudhi { + /*! \page fileformats File formats \tableofcontents @@ -21,5 +48,7 @@ \endcode Other sample files can be found in the `data/persistence_diagram` folder. - -*/ \ No newline at end of file +*/ +} // namespace Gudhi + +#endif // DOC_COMMON_FILE_FORMAT_H_ diff --git a/src/common/doc/main_page.h b/src/common/doc/main_page.h index b7f93ed2..12012ecb 100644 --- a/src/common/doc/main_page.h +++ b/src/common/doc/main_page.h @@ -468,5 +468,4 @@ make doxygen * @example Witness_complex/example_witness_complex_persistence.cpp * @example Witness_complex/example_witness_complex_sphere.cpp */ - -#include "file_formats.h" \ No newline at end of file + \ No newline at end of file -- cgit v1.2.3 From e6b1730fd0832fad2a9103863428465155f70986 Mon Sep 17 00:00:00 2001 From: cjamin Date: Tue, 13 Jun 2017 15:29:35 +0000 Subject: This should never have been commented out git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/read_persistence_from_file@2540 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 5e5fc971986908e5b9383130704536686e1b66ea --- src/Bottleneck_distance/example/bottleneck_read_file_example.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp b/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp index 6cfbeafa..238d99ad 100644 --- a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp +++ b/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp @@ -34,7 +34,7 @@ int main(int argc, char** argv) { std::cout << "To run this program please provide as an input two files with persistence diagrams. Each file " << "should contain a birth-death pair per line. Third, optional parameter is an error bound on a bottleneck" << " distance (set by default to zero). The program will now terminate \n"; - //return -1; + return -1; } std::vector> diag1 = read_persistence_intervals_in_dimension(argv[1]); std::vector> diag2 = read_persistence_intervals_in_dimension(argv[2]); -- cgit v1.2.3 From 547a7c9cb50d1818c9412d10cca9655503db625c Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 13 Jun 2017 20:42:51 +0000 Subject: Try to fix Windows compilation for Conda git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/boost_system_no_deprecated_test@2541 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: afa1b10e300aafbc92a85b3519f4b39add2ae6e4 --- src/cmake/modules/GUDHI_third_party_libraries.cmake | 4 ++++ src/cython/CMakeLists.txt | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/cmake/modules/GUDHI_third_party_libraries.cmake b/src/cmake/modules/GUDHI_third_party_libraries.cmake index 8f486118..7cd57b25 100644 --- a/src/cmake/modules/GUDHI_third_party_libraries.cmake +++ b/src/cmake/modules/GUDHI_third_party_libraries.cmake @@ -10,6 +10,10 @@ find_package(GMP) if(GMP_FOUND) message(STATUS "GMP_LIBRARIES = ${GMP_LIBRARIES}") INCLUDE_DIRECTORIES(${GMP_INCLUDE_DIR}) + get_filename_component(lib_we ${GMP_LIBRARIES} NAME_WE) + + message("++ lib_we = ${lib_we}") + find_package(GMPXX) if(GMPXX_FOUND) message(STATUS "GMPXX_LIBRARIES = ${GMPXX_LIBRARIES}") diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index adcc64e4..2a0a3844 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -8,6 +8,9 @@ if(CYTHON_FOUND) set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DBOOST_ALL_NO_LIB', ") set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DBOOST_SYSTEM_NO_DEPRECATED', ") + if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(GUDHI_CYTHON_LIBRARIES "${GUDHI_CYTHON_LIBRARIES}'boost_thread', ") + endif() # Gudhi and CGAL compilation option if(MSVC) set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'/fp:strict', ") -- cgit v1.2.3 From f6d8aaaacf4a2802d3aaad6d326f9510fdb2ddf7 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 14 Jun 2017 05:24:01 +0000 Subject: Add traces for debug git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/boost_system_no_deprecated_test@2542 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: a9e8098443114a4fe6e9c19e6410169580c134c6 --- src/cmake/modules/GUDHI_third_party_libraries.cmake | 4 ---- src/cython/CMakeLists.txt | 10 ++++++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/cmake/modules/GUDHI_third_party_libraries.cmake b/src/cmake/modules/GUDHI_third_party_libraries.cmake index 7cd57b25..8f486118 100644 --- a/src/cmake/modules/GUDHI_third_party_libraries.cmake +++ b/src/cmake/modules/GUDHI_third_party_libraries.cmake @@ -10,10 +10,6 @@ find_package(GMP) if(GMP_FOUND) message(STATUS "GMP_LIBRARIES = ${GMP_LIBRARIES}") INCLUDE_DIRECTORIES(${GMP_INCLUDE_DIR}) - get_filename_component(lib_we ${GMP_LIBRARIES} NAME_WE) - - message("++ lib_we = ${lib_we}") - find_package(GMPXX) if(GMPXX_FOUND) message(STATUS "GMPXX_LIBRARIES = ${GMPXX_LIBRARIES}") diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index 2a0a3844..eff36f93 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -8,6 +8,7 @@ if(CYTHON_FOUND) set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DBOOST_ALL_NO_LIB', ") set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DBOOST_SYSTEM_NO_DEPRECATED', ") + message("++ Boost_THREAD_LIBRARY=${Boost_THREAD_LIBRARY} - Boost_thread_LIBRARY=${Boost_thread_LIBRARY} - ") if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(GUDHI_CYTHON_LIBRARIES "${GUDHI_CYTHON_LIBRARIES}'boost_thread', ") endif() @@ -106,6 +107,7 @@ if(CYTHON_FOUND) if(CGAL_FOUND) # Add CGAL compilation args + message("++ CGAL_LIBRARIES = ${CGAL_LIBRARIES}") if(CGAL_HEADER_ONLY) set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DCGAL_HEADER_ONLY', ") else(CGAL_HEADER_ONLY) @@ -119,10 +121,14 @@ if(CYTHON_FOUND) # GMP and GMPXX are not required, but if present, CGAL will link with them. if(GMP_FOUND) set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DCGAL_USE_GMP', ") + get_filename_component(GMP_LIBRARY_FILE_NAME ${GMP_LIBRARIES} NAME_WE) + message("++ GMP_LIBRARY_FILE_NAME = ${GMP_LIBRARY_FILE_NAME}") if(WIN32) - set(GUDHI_CYTHON_LIBRARIES "${GUDHI_CYTHON_LIBRARIES}'libgmp-10', ") + set(GUDHI_CYTHON_LIBRARIES "${GUDHI_CYTHON_LIBRARIES}'${GMP_LIBRARY_FILE_NAME}', ") else(WIN32) - set(GUDHI_CYTHON_LIBRARIES "${GUDHI_CYTHON_LIBRARIES}'gmp', ") + STRING(REGEX REPLACE "lib" "" UNIX_GMP_LIBRARY_FILE_NAME ${GMP_LIBRARY_FILE_NAME}) + message("++ UNIX_GMP_LIBRARY_FILE_NAME = ${UNIX_GMP_LIBRARY_FILE_NAME}") + set(GUDHI_CYTHON_LIBRARIES "${GUDHI_CYTHON_LIBRARIES}'${UNIX_GMP_LIBRARY_FILE_NAME}', ") endif(WIN32) set(GUDHI_CYTHON_LIBRARY_DIRS "${GUDHI_CYTHON_LIBRARY_DIRS}'${GMP_LIBRARIES_DIR}', ") if(GMPXX_FOUND) -- cgit v1.2.3 From e8c3b007c141551b68859ea178e79ddf618c6dca Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 14 Jun 2017 06:38:20 +0000 Subject: Fix try git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/boost_system_no_deprecated_test@2543 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: da6eb0ef7b79c0d21d8e98d17d78459d1768a5db --- src/cython/CMakeLists.txt | 42 +++++++++++++++++++++------------------- src/cython/cythonize_gudhi.py.in | 2 +- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index eff36f93..739e1a89 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -1,6 +1,20 @@ cmake_minimum_required(VERSION 2.8) project(Cython) +function( add_gudhi_cython_lib THE_LIB ) + if(EXISTS ${THE_LIB}) + get_filename_component(THE_LIB_FILE_NAME ${THE_LIB} NAME_WE) + if(WIN32) + message("++ ${THE_LIB} => THE_LIB_FILE_NAME = ${THE_LIB_FILE_NAME}") + set(GUDHI_CYTHON_LIBRARIES "${GUDHI_CYTHON_LIBRARIES}'${THE_LIB_FILE_NAME}', " PARENT_SCOPE) + else(WIN32) + STRING(REGEX REPLACE "lib" "" UNIX_LIB_FILE_NAME ${THE_LIB_FILE_NAME}) + message("++ ${THE_LIB} => UNIX_LIB_FILE_NAME = ${UNIX_LIB_FILE_NAME}") + set(GUDHI_CYTHON_LIBRARIES "${GUDHI_CYTHON_LIBRARIES}'${UNIX_LIB_FILE_NAME}', " PARENT_SCOPE) + endif(WIN32) + endif(EXISTS ${THE_LIB}) +endfunction( add_gudhi_cython_lib ) + if(CYTHON_FOUND) message("++ ${PYTHON_EXECUTABLE} v.${PYTHON_VERSION_STRING} - Cython is ${CYTHON_EXECUTABLE} - py.test is ${PYTEST_PATH} - Sphinx is ${SPHINX_PATH}") @@ -8,9 +22,9 @@ if(CYTHON_FOUND) set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DBOOST_ALL_NO_LIB', ") set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DBOOST_SYSTEM_NO_DEPRECATED', ") - message("++ Boost_THREAD_LIBRARY=${Boost_THREAD_LIBRARY} - Boost_thread_LIBRARY=${Boost_thread_LIBRARY} - ") if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - set(GUDHI_CYTHON_LIBRARIES "${GUDHI_CYTHON_LIBRARIES}'boost_thread', ") + add_gudhi_cython_lib(${Boost_THREAD_LIBRARY}) + set(GUDHI_CYTHON_LIBRARY_DIRS "${GUDHI_CYTHON_LIBRARY_DIRS}'${Boost_LIBRARY_DIRS}', ") endif() # Gudhi and CGAL compilation option if(MSVC) @@ -107,33 +121,20 @@ if(CYTHON_FOUND) if(CGAL_FOUND) # Add CGAL compilation args - message("++ CGAL_LIBRARIES = ${CGAL_LIBRARIES}") if(CGAL_HEADER_ONLY) set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DCGAL_HEADER_ONLY', ") else(CGAL_HEADER_ONLY) - if(WIN32) - set(GUDHI_CYTHON_LIBRARIES "${GUDHI_CYTHON_LIBRARIES}'CGAL-vc140-mt-4.7', ") - else(WIN32) - set(GUDHI_CYTHON_LIBRARIES "${GUDHI_CYTHON_LIBRARIES}'CGAL', ") - endif(WIN32) + add_gudhi_cython_lib(${CGAL_LIBRARIES}) set(GUDHI_CYTHON_LIBRARY_DIRS "${GUDHI_CYTHON_LIBRARY_DIRS}'${CGAL_LIBRARIES_DIR}', ") endif(CGAL_HEADER_ONLY) # GMP and GMPXX are not required, but if present, CGAL will link with them. if(GMP_FOUND) set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DCGAL_USE_GMP', ") - get_filename_component(GMP_LIBRARY_FILE_NAME ${GMP_LIBRARIES} NAME_WE) - message("++ GMP_LIBRARY_FILE_NAME = ${GMP_LIBRARY_FILE_NAME}") - if(WIN32) - set(GUDHI_CYTHON_LIBRARIES "${GUDHI_CYTHON_LIBRARIES}'${GMP_LIBRARY_FILE_NAME}', ") - else(WIN32) - STRING(REGEX REPLACE "lib" "" UNIX_GMP_LIBRARY_FILE_NAME ${GMP_LIBRARY_FILE_NAME}) - message("++ UNIX_GMP_LIBRARY_FILE_NAME = ${UNIX_GMP_LIBRARY_FILE_NAME}") - set(GUDHI_CYTHON_LIBRARIES "${GUDHI_CYTHON_LIBRARIES}'${UNIX_GMP_LIBRARY_FILE_NAME}', ") - endif(WIN32) - set(GUDHI_CYTHON_LIBRARY_DIRS "${GUDHI_CYTHON_LIBRARY_DIRS}'${GMP_LIBRARIES_DIR}', ") + add_gudhi_cython_lib(${GMP_LIBRARIES}) + set(GUDHI_CYTHON_LIBRARY_DIRS "${GUDHI_CYTHON_LIBRARY_DIRS}'${GMP_LIBRARIES_DIR}', ") if(GMPXX_FOUND) set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DCGAL_USE_GMPXX', ") - set(GUDHI_CYTHON_LIBRARIES "${GUDHI_CYTHON_LIBRARIES}'gmpxx', ") + add_gudhi_cython_lib(${GMPXX_LIBRARIES}) set(GUDHI_CYTHON_LIBRARY_DIRS "${GUDHI_CYTHON_LIBRARY_DIRS}'${GMPXX_LIBRARIES_DIR}', ") endif(GMPXX_FOUND) endif(GMP_FOUND) @@ -154,7 +155,8 @@ if(CYTHON_FOUND) if (TBB_FOUND) set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DGUDHI_USE_TBB', ") - set(GUDHI_CYTHON_LIBRARIES "${GUDHI_CYTHON_LIBRARIES}'tbb', 'tbbmalloc', ") + add_gudhi_cython_lib(${TBB_RELEASE_LIBRARY}) + add_gudhi_cython_lib(${TBB_MALLOC_RELEASE_LIBRARY}) set(GUDHI_CYTHON_LIBRARY_DIRS "${GUDHI_CYTHON_LIBRARY_DIRS}'${TBB_LIBRARY_DIRS}', ") set(GUDHI_CYTHON_INCLUDE_DIRS "${GUDHI_CYTHON_INCLUDE_DIRS}'${TBB_INCLUDE_DIRS}', ") endif() diff --git a/src/cython/cythonize_gudhi.py.in b/src/cython/cythonize_gudhi.py.in index 5a97e9f3..cae4641b 100644 --- a/src/cython/cythonize_gudhi.py.in +++ b/src/cython/cythonize_gudhi.py.in @@ -42,7 +42,7 @@ setup( name = 'gudhi', author='Vincent Rouvreau', author_email='gudhi-contact@lists.gforge.inria.fr', - version='0.1.0', + version='@GUDHI_VERSION@', url='http://gudhi.gforge.inria.fr/', ext_modules = cythonize(gudhi), ) -- cgit v1.2.3 From a6b6f91bfd5a86ee88297b27f18c2bc7d38f6db4 Mon Sep 17 00:00:00 2001 From: cjamin Date: Wed, 14 Jun 2017 07:45:09 +0000 Subject: Remove birth<=death check (should be done by the caller if necessary) git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/read_persistence_from_file@2544 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: ce50159f4bf779a2a42d357cf1c2aa290feaf9b9 --- src/common/include/gudhi/reader_utils.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index 35af09bd..8df20dcc 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -305,6 +305,7 @@ Reads a file containing persistence intervals. Each line might contain 2, 3 or 4 values: [[field] dimension] birth death The output iterator `out` is used this way: `*out++ = std::make_tuple(dim, birth, death);` where `dim` is an `int`, `birth` a `double`, and `death` a `double`. +Note: the function does not check that birth <= death. **/ template void read_persistence_intervals_and_dimension(std::string const& filename, OutputIterator out) { @@ -326,7 +327,6 @@ void read_persistence_intervals_and_dimension(std::string const& filename, Outpu if (n >= 2) { //int field = (n == 4 ? static_cast(numbers[0]) : -1); int dim = (n >= 3 ? static_cast(numbers[n - 3]) : -1); - GUDHI_CHECK(numbers[n - 2] <= numbers[n - 1], "Error: birth > death."); *out++ = std::make_tuple(dim, numbers[n - 2], numbers[n - 1]); } } @@ -338,6 +338,7 @@ Reads a file containing persistence intervals. Each line might contain 2, 3 or 4 values: [[field] dimension] birth death The return value is an `std::map>>` where `dim` is an `int`, `birth` a `double`, and `death` a `double`. +Note: the function does not check that birth <= death. **/ std::map>> read_persistence_intervals_grouped_by_dimension(std::string const& filename) { @@ -357,6 +358,7 @@ If `only_this_dim` is >= 0, only the lines where dimension = `only_this_dim` (or where dimension is not specified) are returned. The return value is an `std::vector>` where `dim` is an `int`, `birth` a `double`, and `death` a `double`. +Note: the function does not check that birth <= death. **/ std::vector> read_persistence_intervals_in_dimension(std::string const& filename, int only_this_dim = -1) { -- cgit v1.2.3 From 30d31a1aabc2035e23eca7bcf3867a30536f11b7 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 16 Jun 2017 07:06:49 +0000 Subject: Fix Python module version numer Fix link with external libraries git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/boost_system_no_deprecated_test@2547 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: e2f47e860ea4608a4d298fa4772d750ac540be5a --- CMakeGUDHIVersion.txt | 2 +- src/cython/cythonize_gudhi.py.in | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeGUDHIVersion.txt b/CMakeGUDHIVersion.txt index bd0c57ac..3d9add66 100644 --- a/CMakeGUDHIVersion.txt +++ b/CMakeGUDHIVersion.txt @@ -1,6 +1,6 @@ set (GUDHI_MAJOR_VERSION 2) set (GUDHI_MINOR_VERSION 0) -set (GUDHI_PATCH_VERSION 0) +set (GUDHI_PATCH_VERSION 1.beta) set(GUDHI_VERSION ${GUDHI_MAJOR_VERSION}.${GUDHI_MINOR_VERSION}.${GUDHI_PATCH_VERSION}) message(STATUS "GUDHI version : ${GUDHI_VERSION}") diff --git a/src/cython/cythonize_gudhi.py.in b/src/cython/cythonize_gudhi.py.in index cae4641b..68a95916 100644 --- a/src/cython/cythonize_gudhi.py.in +++ b/src/cython/cythonize_gudhi.py.in @@ -35,6 +35,7 @@ gudhi = Extension( extra_link_args=[@GUDHI_CYTHON_EXTRA_LINK_ARGS@], libraries=[@GUDHI_CYTHON_LIBRARIES@], library_dirs=[@GUDHI_CYTHON_LIBRARY_DIRS@], + runtime_library_dirs=[@GUDHI_CYTHON_LIBRARY_DIRS@], include_dirs = [@GUDHI_CYTHON_INCLUDE_DIRS@], ) -- cgit v1.2.3 From 30b44fa282606a6a6b585e0e83b98dae4f2e6b2e Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 16 Jun 2017 08:12:26 +0000 Subject: Add warning about boost_thread link for the Mac GUDHI python module git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/boost_system_no_deprecated_test@2548 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 4a9f6c43f4868bd4f303579c22fdc7a54728e68c --- src/cython/CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index 739e1a89..84441591 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -22,6 +22,15 @@ if(CYTHON_FOUND) set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DBOOST_ALL_NO_LIB', ") set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DBOOST_SYSTEM_NO_DEPRECATED', ") + # TODO: Something more clever could be done. + # This is because of https://github.com/CGAL/cgal/blob/master/Installation/include/CGAL/tss.h + # CGAL is using boost thread if thread_local is not ready (requires XCode 8 for Mac). + # The test in https://github.com/CGAL/cgal/blob/master/Installation/include/CGAL/config.h + # #if __has_feature(cxx_thread_local) || \ + # ( (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L ) || \ + # ( _MSC_VER >= 1900 ) + # #define CGAL_CAN_USE_CXX11_THREAD_LOCAL + # #endif if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") add_gudhi_cython_lib(${Boost_THREAD_LIBRARY}) set(GUDHI_CYTHON_LIBRARY_DIRS "${GUDHI_CYTHON_LIBRARY_DIRS}'${Boost_LIBRARY_DIRS}', ") -- cgit v1.2.3 From 06f595c9bbe1f7fbc1d4e9dae7f5a0a384fe62c2 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 16 Jun 2017 09:27:12 +0000 Subject: Fix CUSTOMBUILD : error : don't know how to set runtime library search path for MSVC git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/boost_system_no_deprecated_test@2549 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 94c7625b3bc8e943e3856e0e65dc65bb5d8cd0f7 --- src/cython/CMakeLists.txt | 8 ++++---- src/cython/cythonize_gudhi.py.in | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index 84441591..7586188c 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -170,6 +170,10 @@ if(CYTHON_FOUND) set(GUDHI_CYTHON_INCLUDE_DIRS "${GUDHI_CYTHON_INCLUDE_DIRS}'${TBB_INCLUDE_DIRS}', ") endif() + if(UNIX) + set( GUDHI_CYTHON_RUNTIME_LIBRARY_DIRS "${GUDHI_CYTHON_LIBRARY_DIRS}") + endif(UNIX) + # set sphinx-build in make files configure_file(doc/Makefile.in "${CMAKE_CURRENT_BINARY_DIR}/doc/Makefile" @ONLY) configure_file(doc/make.bat.in "${CMAKE_CURRENT_BINARY_DIR}/doc/make.bat" @ONLY) @@ -187,10 +191,6 @@ if(CYTHON_FOUND) add_custom_target(cython ALL DEPENDS gudhi.so COMMENT "Do not forget to add ${CMAKE_CURRENT_BINARY_DIR}/ to your PYTHONPATH before using examples or tests") - if(UNIX) - set( ENV{PYTHONPATH} $ENV{PYTHONPATH}:${CMAKE_CURRENT_BINARY_DIR}/ ) - endif(UNIX) - # For installation purpose # TODO(VR) : files matching pattern mechanism is copying all cython directory install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" DESTINATION "${PYTHON_SITE_PACKAGES}/" FILES_MATCHING diff --git a/src/cython/cythonize_gudhi.py.in b/src/cython/cythonize_gudhi.py.in index 68a95916..c1a1717a 100644 --- a/src/cython/cythonize_gudhi.py.in +++ b/src/cython/cythonize_gudhi.py.in @@ -35,8 +35,8 @@ gudhi = Extension( extra_link_args=[@GUDHI_CYTHON_EXTRA_LINK_ARGS@], libraries=[@GUDHI_CYTHON_LIBRARIES@], library_dirs=[@GUDHI_CYTHON_LIBRARY_DIRS@], - runtime_library_dirs=[@GUDHI_CYTHON_LIBRARY_DIRS@], include_dirs = [@GUDHI_CYTHON_INCLUDE_DIRS@], + runtime_library_dirs=[@GUDHI_CYTHON_RUNTIME_LIBRARY_DIRS@], ) setup( -- cgit v1.2.3 From cdb39c39a60fe06009168c1ecb1d4ce5de0bed8c Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 16 Jun 2017 09:31:43 +0000 Subject: Fix auto lambda (requires C++14) compilation issue git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/read_persistence_from_file@2550 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: df64cfdde77500b06f00432a1d1532518cd4dd37 --- src/common/include/gudhi/reader_utils.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index 8df20dcc..f1684d78 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -25,8 +25,8 @@ #include #include -#include +#include #include #include @@ -340,12 +340,12 @@ The return value is an `std::map>>` where `dim` is an `int`, `birth` a `double`, and `death` a `double`. Note: the function does not check that birth <= death. **/ -std::map>> read_persistence_intervals_grouped_by_dimension(std::string const& filename) { +inline std::map>> read_persistence_intervals_grouped_by_dimension(std::string const& filename) { std::map>> ret; read_persistence_intervals_and_dimension( filename, - boost::make_function_output_iterator([&ret](auto t) { ret[get<0>(t)].push_back(std::make_pair(get<1>(t), get<2>(t))); })); + boost::make_function_output_iterator([&ret](std::tuple t) { ret[get<0>(t)].push_back(std::make_pair(get<1>(t), get<2>(t))); })); return ret; } // read_persistence_diagram_from_file @@ -360,12 +360,12 @@ The return value is an `std::vector>` where `dim` is an `int`, `birth` a `double`, and `death` a `double`. Note: the function does not check that birth <= death. **/ -std::vector> read_persistence_intervals_in_dimension(std::string const& filename, int only_this_dim = -1) { +inline std::vector> read_persistence_intervals_in_dimension(std::string const& filename, int only_this_dim = -1) { std::vector> ret; read_persistence_intervals_and_dimension( filename, - boost::make_function_output_iterator([&ret](auto t) { ret.emplace_back(get<1>(t), get<2>(t)); })); + boost::make_function_output_iterator([&ret](std::tuple t) { ret.emplace_back(get<1>(t), get<2>(t)); })); return ret; } // read_persistence_diagram_from_file -- cgit v1.2.3 -- cgit v1.2.3 From 9d0b415512c166cda2985d1709fcf99fd770b799 Mon Sep 17 00:00:00 2001 From: cjamin Date: Tue, 20 Jun 2017 14:04:09 +0000 Subject: Missing typedef git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/Spatial_searching-Add_radius_search@2556 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 3354bb63d0839ae8377e9c11ef2a1168cce7dd20 --- src/Spatial_searching/include/gudhi/Kd_tree_search.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Spatial_searching/include/gudhi/Kd_tree_search.h b/src/Spatial_searching/include/gudhi/Kd_tree_search.h index c4a15876..f13a98f7 100644 --- a/src/Spatial_searching/include/gudhi/Kd_tree_search.h +++ b/src/Spatial_searching/include/gudhi/Kd_tree_search.h @@ -88,6 +88,10 @@ class Kd_tree_search { std::ptrdiff_t, Point_property_map, Traits_base> STraits; + typedef CGAL::Distance_adapter< + std::ptrdiff_t, + Point_property_map, + CGAL::Euclidean_distance > Orthogonal_distance; typedef CGAL::Orthogonal_k_neighbor_search K_neighbor_search; typedef typename K_neighbor_search::Tree Tree; -- cgit v1.2.3 From 8194773c116763e538b6a542fccbd92ec1537372 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 23 Jun 2017 15:07:18 +0000 Subject: First version of expansion with blocker oracle git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2562 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 755af58e3688d00b43edd9616fd903cce1eca704 --- src/Simplex_tree/example/CMakeLists.txt | 24 ----------- src/Simplex_tree/include/gudhi/Simplex_tree.h | 59 ++++++++++++++++++++------- 2 files changed, 44 insertions(+), 39 deletions(-) diff --git a/src/Simplex_tree/example/CMakeLists.txt b/src/Simplex_tree/example/CMakeLists.txt index cfac0da6..d05bb187 100644 --- a/src/Simplex_tree/example/CMakeLists.txt +++ b/src/Simplex_tree/example/CMakeLists.txt @@ -36,27 +36,3 @@ if(GMP_FOUND AND CGAL_FOUND) install(TARGETS Simplex_tree_example_alpha_shapes_3_from_off DESTINATION bin) endif() - - -add_executable(rips_step_by_step rips_step_by_step.cpp) -target_link_libraries(rips_step_by_step ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) -if (TBB_FOUND) - target_link_libraries(rips_step_by_step ${TBB_LIBRARIES}) -endif() - -add_executable(cgal_rips_step_by_step cgal_rips_step_by_step.cpp) -target_link_libraries(cgal_rips_step_by_step ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) -if (TBB_FOUND) - target_link_libraries(cgal_rips_step_by_step ${TBB_LIBRARIES}) -endif() - -add_executable(cgal_euclidean_distance cgal_euclidean_distance.cpp) -if (TBB_FOUND) - target_link_libraries(cgal_euclidean_distance ${TBB_LIBRARIES}) -endif() - -add_executable(subsamp_rips_step_by_step subsamp_rips_step_by_step.cpp) -target_link_libraries(subsamp_rips_step_by_step ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) -if (TBB_FOUND) - target_link_libraries(subsamp_rips_step_by_step ${TBB_LIBRARIES}) -endif() diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 317bce23..a83623a5 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1007,11 +1007,35 @@ class Simplex_tree { * The Simplex_tree must contain no simplex of dimension bigger than * 1 when calling the method. */ void expansion(int max_dim) { + expansion_with_blockers(max_dim, + [](Simplex_handle origin_sh, + Simplex_handle dict1_sh, + Simplex_handle dict2_sh) { + // Default blocker is always insert with the maximal filtration value between + // origin, dict1 and dict2 + return std::make_pair(true, (std::max)({origin_sh->second.filtration(), + dict1_sh->second.filtration(), + dict2_sh->second.filtration()})); }); + } + + /** \brief Expands the Simplex_tree containing only its one skeleton + * until dimension max_dim. + * + * The expanded simplicial complex until dimension \f$d\f$ + * attached to a graph \f$G\f$ is the maximal simplicial complex of + * dimension at most \f$d\f$ admitting the graph \f$G\f$ as \f$1\f$-skeleton. + * The filtration value assigned to a simplex is the maximal filtration + * value of one of its edges. + * + * The Simplex_tree must contain no simplex of dimension bigger than + * 1 when calling the method. */ + template< typename Blocker > + void expansion_with_blockers(int max_dim, Blocker blocker_expansion_function) { dimension_ = max_dim; for (Dictionary_it root_it = root_.members_.begin(); root_it != root_.members_.end(); ++root_it) { if (has_children(root_it)) { - siblings_expansion(root_it->second.children(), max_dim - 1); + siblings_expansion_with_blockers(root_it->second.children(), max_dim - 1, blocker_expansion_function); } } dimension_ = max_dim - dimension_; @@ -1019,8 +1043,9 @@ class Simplex_tree { private: /** \brief Recursive expansion of the simplex tree.*/ - void siblings_expansion(Siblings * siblings, // must contain elements - int k) { + template< typename Blocker > + void siblings_expansion_with_blockers(Siblings * siblings, // must contain elements + int k, Blocker blocker_expansion_function) { if (dimension_ > k) { dimension_ = k; } @@ -1034,20 +1059,21 @@ class Simplex_tree { s_h != siblings->members().end(); ++s_h, ++next) { Simplex_handle root_sh = find_vertex(s_h->first); if (has_children(root_sh)) { - intersection( - inter, // output intersection - next, // begin - siblings->members().end(), // end - root_sh->second.children()->members().begin(), - root_sh->second.children()->members().end(), - s_h->second.filtration()); + intersection_with_blockers( + inter, // output intersection + next, // begin + siblings->members().end(), // end + root_sh->second.children()->members().begin(), + root_sh->second.children()->members().end(), + s_h, blocker_expansion_function); if (inter.size() != 0) { Siblings * new_sib = new Siblings(siblings, // oncles s_h->first, // parent inter); // boost::container::ordered_unique_range_t + // As siblings_expansion_with_blockers is recusively called, inter must be cleared before inter.clear(); s_h->second.assign_children(new_sib); - siblings_expansion(new_sib, k - 1); + siblings_expansion_with_blockers(new_sib, k - 1, blocker_expansion_function); } else { // ensure the children property s_h->second.assign_children(siblings); @@ -1059,16 +1085,19 @@ class Simplex_tree { /** \brief Intersects Dictionary 1 [begin1;end1) with Dictionary 2 [begin2,end2) * and assigns the maximal possible Filtration_value to the Nodes. */ - static void intersection(std::vector >& intersection, + template< typename Blocker > + static void intersection_with_blockers(std::vector >& intersection, Dictionary_it begin1, Dictionary_it end1, Dictionary_it begin2, Dictionary_it end2, - Filtration_value filtration_) { + Dictionary_it origin_sh, + Blocker blocker_expansion_function) { if (begin1 == end1 || begin2 == end2) return; // ----->> while (true) { if (begin1->first == begin2->first) { - Filtration_value filt = (std::max)({begin1->second.filtration(), begin2->second.filtration(), filtration_}); - intersection.emplace_back(begin1->first, Node(nullptr, filt)); + std::pair blocker_result = blocker_expansion_function(origin_sh, begin1, begin2); + if (blocker_result.first) + intersection.emplace_back(begin1->first, Node(nullptr, blocker_result.second)); if (++begin1 == end1 || ++begin2 == end2) return; // ----->> } else if (begin1->first < begin2->first) { -- cgit v1.2.3 From 5c4d2b4a40ca149702253a2412cb7a63a182ff92 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 26 Jun 2017 15:17:28 +0000 Subject: A test of Cech complex with oracle blocker git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2563 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 6c4325dd1ca53a92f4f3de3ed32323c8b6505f5d --- src/Simplex_tree/example/CMakeLists.txt | 9 + .../example/cech_complex_step_by_step.cpp | 240 +++++++++++++++++++++ src/Simplex_tree/include/gudhi/Simplex_tree.h | 11 +- src/common/include/gudhi/Points_off_io.h | 2 +- 4 files changed, 257 insertions(+), 5 deletions(-) create mode 100644 src/Simplex_tree/example/cech_complex_step_by_step.cpp diff --git a/src/Simplex_tree/example/CMakeLists.txt b/src/Simplex_tree/example/CMakeLists.txt index d05bb187..5dbbfcc0 100644 --- a/src/Simplex_tree/example/CMakeLists.txt +++ b/src/Simplex_tree/example/CMakeLists.txt @@ -36,3 +36,12 @@ if(GMP_FOUND AND CGAL_FOUND) install(TARGETS Simplex_tree_example_alpha_shapes_3_from_off DESTINATION bin) endif() + +add_executable ( Simplex_tree_example_cech_complex_step_by_step cech_complex_step_by_step.cpp) +target_link_libraries(Simplex_tree_example_cech_complex_step_by_step ${Boost_PROGRAM_OPTIONS_LIBRARY}) +if (TBB_FOUND) + target_link_libraries(Simplex_tree_example_cech_complex_step_by_step ${TBB_LIBRARIES}) +endif() +add_test(NAME Simplex_tree_example_cech_complex_step_by_step COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" "-r" "12." "-d" "3") +install(TARGETS Simplex_tree_example_cech_complex_step_by_step DESTINATION bin) diff --git a/src/Simplex_tree/example/cech_complex_step_by_step.cpp b/src/Simplex_tree/example/cech_complex_step_by_step.cpp new file mode 100644 index 00000000..b5cda443 --- /dev/null +++ b/src/Simplex_tree/example/cech_complex_step_by_step.cpp @@ -0,0 +1,240 @@ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): Clément Maria + * + * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include + +// #include +// #include +// #include +#include +#include +#include + +#include + +#include +#include +#include // infinity +#include // for pair +#include + +// ---------------------------------------------------------------------------- +// rips_persistence_step_by_step is an example of each step that is required to +// build a Rips over a Simplex_tree. Please refer to rips_persistence to see +// how to do the same thing with the Rips_complex wrapper for less detailed +// steps. +// ---------------------------------------------------------------------------- + +// Types definition +using Simplex_tree = Gudhi::Simplex_tree; +using Vertex_handle = Simplex_tree::Vertex_handle; +using Simplex_handle = Simplex_tree::Simplex_handle; +using Filtration_value = Simplex_tree::Filtration_value; +using Siblings = Simplex_tree::Siblings; +using Graph_t = boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS +, boost::property < vertex_filtration_t, Filtration_value > +, boost::property < edge_filtration_t, Filtration_value > +>; +using Edge_t = std::pair< Vertex_handle, Vertex_handle >; + +// using Kernel = CGAL::Epick_d< CGAL::Dimension_tag<2> >;// CGAL::Dynamic_dimension_tag >; +typedef CGAL::Cartesian_d Kernel; +typedef CGAL::Optimisation_d_traits_d Traits; +typedef CGAL::Min_sphere_d Min_sphere; + +using Point = Kernel::Point_d; +using Points_off_reader = Gudhi::Points_off_reader; +// using Min_sphere = CGAL::Min_sphere_d; + +class Cech_blocker { + public: + std::pair operator()(Simplex_handle origin_sh, Simplex_handle dict1_sh, Simplex_handle dict2_sh, Siblings* siblings) { + //std::vector path = {dict1_sh->first, origin_sh->first}; + Siblings* sib_path = siblings; + std::vector sphere_points = {point_cloud_[dict1_sh->first], point_cloud_[origin_sh->first]}; + do { + //path.push_back(sib_path->parent()); + sphere_points.push_back(point_cloud_[sib_path->parent()]); + sib_path = sib_path->oncles(); + } while (sib_path->oncles() != nullptr); + /*std::cout << square_threshold_ << "-"; + for (auto vh : path) { + std::cout << vh << " "; + } + std::cout << std::endl;*/ + Min_sphere min_sphere(sphere_points.begin(), sphere_points.end()); + //std::cout << min_sphere.squared_radius() << std::endl; + Filtration_value squared_diameter = min_sphere.squared_radius() * 4.; + // Default blocker is always insert with the maximal filtration value between + // origin, dict1 and dict2 + return std::make_pair(squared_diameter < square_threshold_, + squared_diameter); + } + Cech_blocker(Filtration_value threshold, const std::vector& point_cloud) + : square_threshold_(threshold * threshold), + point_cloud_(point_cloud) { } + private: + Filtration_value square_threshold_; + std::vector point_cloud_; +}; + +template< typename InputPointRange> +Graph_t compute_proximity_graph(InputPointRange &points, Filtration_value threshold); + +void program_options(int argc, char * argv[] + , std::string & off_file_points + , Filtration_value & threshold + , int & dim_max); + +int main(int argc, char * argv[]) { + std::string off_file_points; + Filtration_value threshold; + int dim_max; + + program_options(argc, argv, off_file_points, threshold, dim_max); + + // Extract the points from the file filepoints + Points_off_reader off_reader(off_file_points); + + // Compute the proximity graph of the points + Graph_t prox_graph = compute_proximity_graph(off_reader.get_point_cloud(), threshold); + + //Min_sphere sph1(off_reader.get_point_cloud()[0], off_reader.get_point_cloud()[1], off_reader.get_point_cloud()[2]); + // Construct the Rips complex in a Simplex Tree + Simplex_tree st; + // insert the proximity graph in the simplex tree + st.insert_graph(prox_graph); + // expand the graph until dimension dim_max + st.expansion_with_blockers(dim_max, Cech_blocker(threshold, off_reader.get_point_cloud())); + + std::cout << "The complex contains " << st.num_simplices() << " simplices \n"; + std::cout << " and has dimension " << st.dimension() << " \n"; + + // Sort the simplices in the order of the filtration + st.initialize_filtration(); + + std::cout << "********************************************************************\n"; + // Display the Simplex_tree - Can not be done in the middle of 2 inserts + std::cout << "* The complex contains " << st.num_simplices() << " simplices\n"; + std::cout << " - dimension " << st.dimension() << " - filtration " << st.filtration() << "\n"; + std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; + for (auto f_simplex : st.filtration_simplex_range()) { + std::cout << " " << "[" << st.filtration(f_simplex) << "] "; + for (auto vertex : st.simplex_vertex_range(f_simplex)) { + std::cout << static_cast(vertex) << " "; + } + std::cout << std::endl; + } + + return 0; +} + +void program_options(int argc, char * argv[] + , std::string & off_file_points + , Filtration_value & threshold + , int & dim_max) { + namespace po = boost::program_options; + po::options_description hidden("Hidden options"); + hidden.add_options() + ("input-file", po::value(&off_file_points), + "Name of an OFF file containing a point set.\n"); + + po::options_description visible("Allowed options", 100); + visible.add_options() + ("help,h", "produce help message") + ("max-edge-length,r", + po::value(&threshold)->default_value(std::numeric_limits::infinity()), + "Maximal length of an edge for the Rips complex construction.") + ("cpx-dimension,d", po::value(&dim_max)->default_value(1), + "Maximal dimension of the Rips complex we want to compute."); + + po::positional_options_description pos; + pos.add("input-file", 1); + + po::options_description all; + all.add(visible).add(hidden); + + po::variables_map vm; + po::store(po::command_line_parser(argc, argv). + options(all).positional(pos).run(), vm); + po::notify(vm); + + if (vm.count("help") || !vm.count("input-file")) { + std::cout << std::endl; + std::cout << "Construct a Cech complex defined on a set of input points.\n \n"; + + std::cout << "Usage: " << argv[0] << " [options] input-file" << std::endl << std::endl; + std::cout << visible << std::endl; + std::abort(); + } +} + +/** Output the proximity graph of the points. + * + * If points contains n elements, the proximity graph is the graph + * with n vertices, and an edge [u,v] iff the distance function between + * points u and v is smaller than threshold. + * + * The type PointCloud furnishes .begin() and .end() methods, that return + * iterators with value_type Point. + */ +template< typename InputPointRange> +Graph_t compute_proximity_graph(InputPointRange &points, Filtration_value threshold) { + std::vector< Edge_t > edges; + std::vector< Filtration_value > edges_fil; + + Kernel k; + Filtration_value square_threshold = threshold * threshold; + + Vertex_handle idx_u, idx_v; + Filtration_value fil; + idx_u = 0; + for (auto it_u = points.begin(); it_u != points.end(); ++it_u) { + idx_v = idx_u + 1; + for (auto it_v = it_u + 1; it_v != points.end(); ++it_v, ++idx_v) { + fil = k.squared_distance_d_object()(*it_u, *it_v); + if (fil <= square_threshold) { + edges.emplace_back(idx_u, idx_v); + edges_fil.push_back(fil); + } + } + ++idx_u; + } + + Graph_t skel_graph(edges.begin() + , edges.end() + , edges_fil.begin() + , idx_u); // number of points labeled from 0 to idx_u-1 + + auto vertex_prop = boost::get(vertex_filtration_t(), skel_graph); + + boost::graph_traits::vertex_iterator vi, vi_end; + for (std::tie(vi, vi_end) = boost::vertices(skel_graph); + vi != vi_end; ++vi) { + boost::put(vertex_prop, *vi, 0.); + } + + return skel_graph; +} diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index a83623a5..dbed47b8 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1010,7 +1010,8 @@ class Simplex_tree { expansion_with_blockers(max_dim, [](Simplex_handle origin_sh, Simplex_handle dict1_sh, - Simplex_handle dict2_sh) { + Simplex_handle dict2_sh, + Siblings* siblings) { // Default blocker is always insert with the maximal filtration value between // origin, dict1 and dict2 return std::make_pair(true, (std::max)({origin_sh->second.filtration(), @@ -1044,7 +1045,7 @@ class Simplex_tree { private: /** \brief Recursive expansion of the simplex tree.*/ template< typename Blocker > - void siblings_expansion_with_blockers(Siblings * siblings, // must contain elements + void siblings_expansion_with_blockers(Siblings* siblings, // must contain elements int k, Blocker blocker_expansion_function) { if (dimension_ > k) { dimension_ = k; @@ -1065,7 +1066,8 @@ class Simplex_tree { siblings->members().end(), // end root_sh->second.children()->members().begin(), root_sh->second.children()->members().end(), - s_h, blocker_expansion_function); + s_h, siblings, + blocker_expansion_function); if (inter.size() != 0) { Siblings * new_sib = new Siblings(siblings, // oncles s_h->first, // parent @@ -1090,12 +1092,13 @@ class Simplex_tree { Dictionary_it begin1, Dictionary_it end1, Dictionary_it begin2, Dictionary_it end2, Dictionary_it origin_sh, + Siblings* siblings, Blocker blocker_expansion_function) { if (begin1 == end1 || begin2 == end2) return; // ----->> while (true) { if (begin1->first == begin2->first) { - std::pair blocker_result = blocker_expansion_function(origin_sh, begin1, begin2); + std::pair blocker_result = blocker_expansion_function(origin_sh, begin1, begin2, siblings); if (blocker_result.first) intersection.emplace_back(begin1->first, Node(nullptr, blocker_result.second)); if (++begin1 == end1 || ++begin2 == end2) diff --git a/src/common/include/gudhi/Points_off_io.h b/src/common/include/gudhi/Points_off_io.h index 29af8a8a..2104b411 100644 --- a/src/common/include/gudhi/Points_off_io.h +++ b/src/common/include/gudhi/Points_off_io.h @@ -85,7 +85,7 @@ class Points_off_visitor_reader { std::cout << std::endl; #endif // DEBUG_TRACES // Fill the point cloud - point_cloud.push_back(Point_d(point.begin(), point.end())); + point_cloud.push_back(Point_d(point.end() - point.begin(), point.begin(), point.end())); } // Off_reader visitor maximal_face implementation - Only points are read -- cgit v1.2.3 From 34487e33517c36ad65407743c46fd4c1df963628 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 28 Jun 2017 10:53:42 +0000 Subject: Add a comment git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@2566 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 64cd59ca30ff82a1c116df20c4cee38a795dc518 --- src/cython/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index 5c98b09a..d801fb0b 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -151,6 +151,7 @@ if(CYTHON_FOUND) else(CGAL_HEADER_ONLY) add_gudhi_cython_lib(${CGAL_LIBRARIES}) set(GUDHI_CYTHON_LIBRARY_DIRS "${GUDHI_CYTHON_LIBRARY_DIRS}'${CGAL_LIBRARIES_DIR}', ") + # If CGAL is not header only, CGAL library may link with boost system, add_gudhi_cython_lib(${Boost_SYSTEM_LIBRARY}) set(GUDHI_CYTHON_LIBRARY_DIRS "${GUDHI_CYTHON_LIBRARY_DIRS}'${Boost_LIBRARY_DIRS}', ") endif(CGAL_HEADER_ONLY) -- cgit v1.2.3 From 0423b7024dee787659b76fff4b4f659546a40aea Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 29 Jun 2017 15:57:04 +0000 Subject: First working version of expansion insertion (different from rips expansion). git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2570 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 6a6bb4052c3111e783e9e138619f1e945c856708 --- src/Simplex_tree/example/CMakeLists.txt | 17 +++ src/Simplex_tree/example/block.cpp | 82 +++++++++++ src/Simplex_tree/example/simple_simplex_tree.cpp | 35 ++++- src/Simplex_tree/include/gudhi/Simplex_tree.h | 167 ++++++++++++++++------- 4 files changed, 251 insertions(+), 50 deletions(-) create mode 100644 src/Simplex_tree/example/block.cpp diff --git a/src/Simplex_tree/example/CMakeLists.txt b/src/Simplex_tree/example/CMakeLists.txt index 5dbbfcc0..d5f512b3 100644 --- a/src/Simplex_tree/example/CMakeLists.txt +++ b/src/Simplex_tree/example/CMakeLists.txt @@ -45,3 +45,20 @@ endif() add_test(NAME Simplex_tree_example_cech_complex_step_by_step COMMAND $ "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" "-r" "12." "-d" "3") install(TARGETS Simplex_tree_example_cech_complex_step_by_step DESTINATION bin) + + +# +# TO BE REMOVED !! +# + +#add_executable ( rips_step_by_step rips_step_by_step.cpp) +#target_link_libraries(rips_step_by_step ${Boost_PROGRAM_OPTIONS_LIBRARY}) +#if (TBB_FOUND) +# target_link_libraries(rips_step_by_step ${TBB_LIBRARIES}) +#endif() + + +add_executable ( block block.cpp ) +if (TBB_FOUND) + target_link_libraries(block ${TBB_LIBRARIES}) +endif() diff --git a/src/Simplex_tree/example/block.cpp b/src/Simplex_tree/example/block.cpp new file mode 100644 index 00000000..07ec3921 --- /dev/null +++ b/src/Simplex_tree/example/block.cpp @@ -0,0 +1,82 @@ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): Vincent Rouvreau + * + * Copyright (C) 2014 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include + +#include +#include // for pair +#include + +using Simplex_tree = Gudhi::Simplex_tree<>; +using Vertex_handle = Simplex_tree::Vertex_handle; +using Filtration_value = Simplex_tree::Filtration_value; +using typeVectorVertex = std::vector< Vertex_handle >; +using typePairSimplexBool = std::pair< Simplex_tree::Simplex_handle, bool >; + +int main(int argc, char * const argv[]) { + + // Construct the Simplex Tree + Simplex_tree simplexTree; + + simplexTree.insert_simplex({0, 1}); + simplexTree.insert_simplex({0, 2}); + simplexTree.insert_simplex({0, 3}); + simplexTree.insert_simplex({1, 2}); + simplexTree.insert_simplex({1, 3}); + simplexTree.insert_simplex({2, 3}); + simplexTree.insert_simplex({2, 4}); + simplexTree.insert_simplex({3, 6}); + simplexTree.insert_simplex({4, 5}); + simplexTree.insert_simplex({4, 6}); + simplexTree.insert_simplex({5, 6}); + simplexTree.insert_simplex({6}); + + std::cout << "********************************************************************\n"; + // Display the Simplex_tree - Can not be done in the middle of 2 inserts + std::cout << "* The complex contains " << simplexTree.num_simplices() << " simplices\n"; + std::cout << " - dimension " << simplexTree.dimension() << " - filtration " << simplexTree.filtration() << "\n"; + std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; + for (auto f_simplex : simplexTree.filtration_simplex_range()) { + std::cout << " " << "[" << simplexTree.filtration(f_simplex) << "] "; + for (auto vertex : simplexTree.simplex_vertex_range(f_simplex)) + std::cout << "(" << vertex << ")"; + std::cout << std::endl; + } + + simplexTree.expansion_with_blockers(3, [](){return true;}); + + simplexTree.initialize_filtration(); + std::cout << "********************************************************************\n"; + // Display the Simplex_tree - Can not be done in the middle of 2 inserts + std::cout << "* The complex contains " << simplexTree.num_simplices() << " simplices\n"; + std::cout << " - dimension " << simplexTree.dimension() << " - filtration " << simplexTree.filtration() << "\n"; + std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; + for (auto f_simplex : simplexTree.filtration_simplex_range()) { + std::cout << " " << "[" << simplexTree.filtration(f_simplex) << "] "; + for (auto vertex : simplexTree.simplex_vertex_range(f_simplex)) + std::cout << "(" << vertex << ")"; + std::cout << std::endl; + } + + return 0; +} diff --git a/src/Simplex_tree/example/simple_simplex_tree.cpp b/src/Simplex_tree/example/simple_simplex_tree.cpp index 60f9a35e..f27d7ab8 100644 --- a/src/Simplex_tree/example/simple_simplex_tree.cpp +++ b/src/Simplex_tree/example/simple_simplex_tree.cpp @@ -195,9 +195,8 @@ int main(int argc, char * const argv[]) { std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; for (auto f_simplex : simplexTree.filtration_simplex_range()) { std::cout << " " << "[" << simplexTree.filtration(f_simplex) << "] "; - for (auto vertex : simplexTree.simplex_vertex_range(f_simplex)) { - std::cout << static_cast(vertex) << " "; - } + for (auto vertex : simplexTree.simplex_vertex_range(f_simplex)) + std::cout << "(" << vertex << ")"; std::cout << std::endl; } // [0.1] 0 @@ -250,5 +249,35 @@ int main(int argc, char * const argv[]) { std::cout << "***+ YES IT IS!\n"; else std::cout << "***- NO IT ISN'T\n"; + + invSimplexVector = { 0, 1 }; + simplexFound = simplexTree.find({ 0, 1 }); + std::cout << "**************IS THE SIMPLEX {0,1} IN THE SIMPLEX TREE ?\n"; + if (simplexFound != simplexTree.null_simplex()) + std::cout << "***+ YES IT IS!\n"; + else + std::cout << "***- NO IT ISN'T\n"; + + std::cout << "**************COFACES OF {0,1} IN CODIMENSION 1 ARE\n"; + for (auto& simplex : simplexTree.cofaces_simplex_range(simplexTree.find({0,1}), 1)) { + for (auto vertex : simplexTree.simplex_vertex_range(simplex)) + std::cout << "(" << vertex << ")"; + std::cout << std::endl; + } + + std::cout << "**************STARS OF {0,1} ARE\n"; + for (auto& simplex : simplexTree.star_simplex_range(simplexTree.find({0,1}))) { + for (auto vertex : simplexTree.simplex_vertex_range(simplex)) + std::cout << "(" << vertex << ")"; + std::cout << std::endl; + } + + std::cout << "**************BOUNDARIES OF {0,1,2} ARE\n"; + for (auto& simplex : simplexTree.boundary_simplex_range(simplexTree.find({0,1,2}))) { + for (auto vertex : simplexTree.simplex_vertex_range(simplex)) + std::cout << "(" << vertex << ")"; + std::cout << std::endl; + } + return 0; } diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index dbed47b8..ff31fd89 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1007,36 +1007,11 @@ class Simplex_tree { * The Simplex_tree must contain no simplex of dimension bigger than * 1 when calling the method. */ void expansion(int max_dim) { - expansion_with_blockers(max_dim, - [](Simplex_handle origin_sh, - Simplex_handle dict1_sh, - Simplex_handle dict2_sh, - Siblings* siblings) { - // Default blocker is always insert with the maximal filtration value between - // origin, dict1 and dict2 - return std::make_pair(true, (std::max)({origin_sh->second.filtration(), - dict1_sh->second.filtration(), - dict2_sh->second.filtration()})); }); - } - - /** \brief Expands the Simplex_tree containing only its one skeleton - * until dimension max_dim. - * - * The expanded simplicial complex until dimension \f$d\f$ - * attached to a graph \f$G\f$ is the maximal simplicial complex of - * dimension at most \f$d\f$ admitting the graph \f$G\f$ as \f$1\f$-skeleton. - * The filtration value assigned to a simplex is the maximal filtration - * value of one of its edges. - * - * The Simplex_tree must contain no simplex of dimension bigger than - * 1 when calling the method. */ - template< typename Blocker > - void expansion_with_blockers(int max_dim, Blocker blocker_expansion_function) { dimension_ = max_dim; for (Dictionary_it root_it = root_.members_.begin(); root_it != root_.members_.end(); ++root_it) { if (has_children(root_it)) { - siblings_expansion_with_blockers(root_it->second.children(), max_dim - 1, blocker_expansion_function); + siblings_expansion(root_it->second.children(), max_dim - 1); } } dimension_ = max_dim - dimension_; @@ -1044,9 +1019,8 @@ class Simplex_tree { private: /** \brief Recursive expansion of the simplex tree.*/ - template< typename Blocker > - void siblings_expansion_with_blockers(Siblings* siblings, // must contain elements - int k, Blocker blocker_expansion_function) { + void siblings_expansion(Siblings * siblings, // must contain elements + int k) { if (dimension_ > k) { dimension_ = k; } @@ -1060,22 +1034,20 @@ class Simplex_tree { s_h != siblings->members().end(); ++s_h, ++next) { Simplex_handle root_sh = find_vertex(s_h->first); if (has_children(root_sh)) { - intersection_with_blockers( - inter, // output intersection - next, // begin - siblings->members().end(), // end - root_sh->second.children()->members().begin(), - root_sh->second.children()->members().end(), - s_h, siblings, - blocker_expansion_function); + intersection( + inter, // output intersection + next, // begin + siblings->members().end(), // end + root_sh->second.children()->members().begin(), + root_sh->second.children()->members().end(), + s_h->second.filtration()); if (inter.size() != 0) { Siblings * new_sib = new Siblings(siblings, // oncles s_h->first, // parent inter); // boost::container::ordered_unique_range_t - // As siblings_expansion_with_blockers is recusively called, inter must be cleared before inter.clear(); s_h->second.assign_children(new_sib); - siblings_expansion_with_blockers(new_sib, k - 1, blocker_expansion_function); + siblings_expansion(new_sib, k - 1); } else { // ensure the children property s_h->second.assign_children(siblings); @@ -1087,20 +1059,16 @@ class Simplex_tree { /** \brief Intersects Dictionary 1 [begin1;end1) with Dictionary 2 [begin2,end2) * and assigns the maximal possible Filtration_value to the Nodes. */ - template< typename Blocker > - static void intersection_with_blockers(std::vector >& intersection, + static void intersection(std::vector >& intersection, Dictionary_it begin1, Dictionary_it end1, Dictionary_it begin2, Dictionary_it end2, - Dictionary_it origin_sh, - Siblings* siblings, - Blocker blocker_expansion_function) { + Filtration_value filtration_) { if (begin1 == end1 || begin2 == end2) return; // ----->> while (true) { if (begin1->first == begin2->first) { - std::pair blocker_result = blocker_expansion_function(origin_sh, begin1, begin2, siblings); - if (blocker_result.first) - intersection.emplace_back(begin1->first, Node(nullptr, blocker_result.second)); + Filtration_value filt = (std::max)({begin1->second.filtration(), begin2->second.filtration(), filtration_}); + intersection.emplace_back(begin1->first, Node(nullptr, filt)); if (++begin1 == end1 || ++begin2 == end2) return; // ----->> } else if (begin1->first < begin2->first) { @@ -1113,6 +1081,111 @@ class Simplex_tree { } } + + + /*-------------------------------------------------------------------------------------------------------------------------*/ + /*-------------------------------------------------------------------------------------------------------------------------*/ + /*-------------------------------------------------------------------------------------------------------------------------*/ + + public: + /** \brief Expands the Simplex_tree containing only its one skeleton + * until dimension max_dim. + * + * The expanded simplicial complex until dimension \f$d\f$ + * attached to a graph \f$G\f$ is the maximal simplicial complex of + * dimension at most \f$d\f$ admitting the graph \f$G\f$ as \f$1\f$-skeleton. + * The filtration value assigned to a simplex is the maximal filtration + * value of one of its edges. + * + * The Simplex_tree must contain no simplex of dimension bigger than + * 1 when calling the method. */ + template< typename Blocker > + void expansion_with_blockers(int max_dim, Blocker blocker_expansion_function) { + dimension_ = max_dim; + // Loop must be from the end to the beginning, as higher dimension simplex are always on the left part of the tree + for (auto& simplex : boost::adaptors::reverse(root_.members())) { + if (has_children(&simplex)) { + std::cout << " *** root on " << static_cast(simplex.first) << std::endl; + siblings_expansion_with_blockers(simplex.second.children(), max_dim - 1, blocker_expansion_function); + } + } + dimension_ = max_dim - dimension_; + } + + private: + /** \brief Recursive expansion of the simplex tree.*/ + template< typename Blocker > + void siblings_expansion_with_blockers(Siblings* siblings, // must contain elements + int k, Blocker blocker_expansion_function) { + if (dimension_ > k) { + dimension_ = k; + } + if (k == 0) + return; + // No need to go deeper + if (siblings->members().size() < 2) + return; + // Reverse loop starting before the last one for 'next' to be the last one + for (auto simplex = siblings->members().rbegin() + 1; simplex != siblings->members().rend(); simplex++) { + auto next = siblings->members().rbegin(); + std::vector > intersection; + while(next != simplex) { + bool to_be_inserted = true; + std::cout << "to_be_inserted = " << to_be_inserted << " dim = " << k << " simplex = " << simplex->first << " - next = " << next->first << std::endl; + + for (auto& border : boundary_simplex_range(simplex)) { + to_be_inserted = to_be_inserted && find_child(border, next->first); + + for (auto vertex : simplex_vertex_range(border)) { + std::cout << "(" << vertex << ")"; + } + std::cout << " | "; + } + std::cout << std::endl; + if (to_be_inserted) { + std::cout << next->first << " to be inserted." << std::endl; + intersection.emplace_back(next->first, Node(nullptr, 0.0)); + } + + // loop until simplex is reached + next++; + } + if (intersection.size() != 0) { + // Reverse the order to insert + std::reverse(std::begin(intersection), std::end(intersection)); + Siblings * new_sib = new Siblings(siblings, // oncles + simplex->first, // parent + intersection); // boost::container::ordered_unique_range_t + // intersection must be cleared before the function to be called recursively + intersection.clear(); + simplex->second.assign_children(new_sib); + siblings_expansion_with_blockers(new_sib, k - 1, blocker_expansion_function); + } else { + // ensure the children property + simplex->second.assign_children(siblings); + intersection.clear(); + } + + } + + } + + /** \private Returns true if vh is a member of sh*/ + bool find_child(Simplex_handle sh, Vertex_handle vh) { + std::vector child = {vh}; + std::cout << "+" << vh; + for (auto vertex : simplex_vertex_range(sh)) { + std::cout << "+" << vertex; + child.push_back(vertex); + } + std::cout << " => " << (find(child) != null_simplex()) << "___ "; + return find(child) != null_simplex(); + } + + /*-------------------------------------------------------------------------------------------------------------------------*/ + /*-------------------------------------------------------------------------------------------------------------------------*/ + /*-------------------------------------------------------------------------------------------------------------------------*/ + public: /** \brief Write the hasse diagram of the simplicial complex in os. * -- cgit v1.2.3 From 7c205b2cb36b9d8b04556cc81afb4940f27743fc Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Sat, 1 Jul 2017 21:57:42 +0000 Subject: Example of blocker and Cech Complex implementation git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2573 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 88a98ef49630989833a09b59d9b1e4713b409c0b --- src/Simplex_tree/example/CMakeLists.txt | 32 +++++------ src/Simplex_tree/example/block.cpp | 42 ++++++++------- .../example/cech_complex_step_by_step.cpp | 62 +++++++++------------- 3 files changed, 63 insertions(+), 73 deletions(-) diff --git a/src/Simplex_tree/example/CMakeLists.txt b/src/Simplex_tree/example/CMakeLists.txt index d5f512b3..7a30979f 100644 --- a/src/Simplex_tree/example/CMakeLists.txt +++ b/src/Simplex_tree/example/CMakeLists.txt @@ -35,30 +35,26 @@ if(GMP_FOUND AND CGAL_FOUND) install(TARGETS Simplex_tree_example_alpha_shapes_3_from_off DESTINATION bin) -endif() + # + # TO BE REMOVED !! + # -add_executable ( Simplex_tree_example_cech_complex_step_by_step cech_complex_step_by_step.cpp) -target_link_libraries(Simplex_tree_example_cech_complex_step_by_step ${Boost_PROGRAM_OPTIONS_LIBRARY}) -if (TBB_FOUND) - target_link_libraries(Simplex_tree_example_cech_complex_step_by_step ${TBB_LIBRARIES}) -endif() -add_test(NAME Simplex_tree_example_cech_complex_step_by_step COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" "-r" "12." "-d" "3") -install(TARGETS Simplex_tree_example_cech_complex_step_by_step DESTINATION bin) + add_executable ( Simplex_tree_example_cech_complex_step_by_step cech_complex_step_by_step.cpp ) + target_link_libraries(Simplex_tree_example_cech_complex_step_by_step ${GMP_LIBRARIES} ${CGAL_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) + if (TBB_FOUND) + target_link_libraries(Simplex_tree_example_cech_complex_step_by_step ${TBB_LIBRARIES}) + endif() + add_test(NAME Simplex_tree_example_cech_complex_step_by_step COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" "-d" "3" "-r" "6.0") +endif() # # TO BE REMOVED !! # -#add_executable ( rips_step_by_step rips_step_by_step.cpp) -#target_link_libraries(rips_step_by_step ${Boost_PROGRAM_OPTIONS_LIBRARY}) -#if (TBB_FOUND) -# target_link_libraries(rips_step_by_step ${TBB_LIBRARIES}) -#endif() - - -add_executable ( block block.cpp ) +add_executable ( Simplex_tree_example_block block.cpp ) if (TBB_FOUND) - target_link_libraries(block ${TBB_LIBRARIES}) + target_link_libraries(Simplex_tree_example_block ${TBB_LIBRARIES}) endif() +add_test(NAME Simplex_tree_example_block COMMAND $) diff --git a/src/Simplex_tree/example/block.cpp b/src/Simplex_tree/example/block.cpp index 07ec3921..75b8d1ea 100644 --- a/src/Simplex_tree/example/block.cpp +++ b/src/Simplex_tree/example/block.cpp @@ -28,31 +28,27 @@ #include using Simplex_tree = Gudhi::Simplex_tree<>; -using Vertex_handle = Simplex_tree::Vertex_handle; -using Filtration_value = Simplex_tree::Filtration_value; -using typeVectorVertex = std::vector< Vertex_handle >; -using typePairSimplexBool = std::pair< Simplex_tree::Simplex_handle, bool >; +using Simplex_handle = Simplex_tree::Simplex_handle; int main(int argc, char * const argv[]) { // Construct the Simplex Tree Simplex_tree simplexTree; - simplexTree.insert_simplex({0, 1}); - simplexTree.insert_simplex({0, 2}); - simplexTree.insert_simplex({0, 3}); - simplexTree.insert_simplex({1, 2}); - simplexTree.insert_simplex({1, 3}); - simplexTree.insert_simplex({2, 3}); - simplexTree.insert_simplex({2, 4}); - simplexTree.insert_simplex({3, 6}); - simplexTree.insert_simplex({4, 5}); - simplexTree.insert_simplex({4, 6}); - simplexTree.insert_simplex({5, 6}); - simplexTree.insert_simplex({6}); + simplexTree.insert_simplex({0, 1}, 0.); + simplexTree.insert_simplex({0, 2}, 1.); + simplexTree.insert_simplex({0, 3}, 2.); + simplexTree.insert_simplex({1, 2}, 3.); + simplexTree.insert_simplex({1, 3}, 4.); + simplexTree.insert_simplex({2, 3}, 5.); + simplexTree.insert_simplex({2, 4}, 6.); + simplexTree.insert_simplex({3, 6}, 7.); + simplexTree.insert_simplex({4, 5}, 8.); + simplexTree.insert_simplex({4, 6}, 9.); + simplexTree.insert_simplex({5, 6}, 10.); + simplexTree.insert_simplex({6}, 11.); std::cout << "********************************************************************\n"; - // Display the Simplex_tree - Can not be done in the middle of 2 inserts std::cout << "* The complex contains " << simplexTree.num_simplices() << " simplices\n"; std::cout << " - dimension " << simplexTree.dimension() << " - filtration " << simplexTree.filtration() << "\n"; std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; @@ -63,11 +59,19 @@ int main(int argc, char * const argv[]) { std::cout << std::endl; } - simplexTree.expansion_with_blockers(3, [](){return true;}); + simplexTree.expansion_with_blockers(3, [&](Simplex_handle sh){ + bool result = false; + for (auto vertex : simplexTree.simplex_vertex_range(sh)) { + if (vertex == 6) + result = true; + std::cout << "#(" << vertex << ")#"; + } + std::cout << std::endl; + return result; + }); simplexTree.initialize_filtration(); std::cout << "********************************************************************\n"; - // Display the Simplex_tree - Can not be done in the middle of 2 inserts std::cout << "* The complex contains " << simplexTree.num_simplices() << " simplices\n"; std::cout << " - dimension " << simplexTree.dimension() << " - filtration " << simplexTree.filtration() << "\n"; std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; diff --git a/src/Simplex_tree/example/cech_complex_step_by_step.cpp b/src/Simplex_tree/example/cech_complex_step_by_step.cpp index b5cda443..1805c792 100644 --- a/src/Simplex_tree/example/cech_complex_step_by_step.cpp +++ b/src/Simplex_tree/example/cech_complex_step_by_step.cpp @@ -28,9 +28,9 @@ // #include // #include // #include -#include -#include -#include +#include +#include +#include #include @@ -59,44 +59,34 @@ using Graph_t = boost::adjacency_list < boost::vecS, boost::vecS, boost::undirec >; using Edge_t = std::pair< Vertex_handle, Vertex_handle >; -// using Kernel = CGAL::Epick_d< CGAL::Dimension_tag<2> >;// CGAL::Dynamic_dimension_tag >; -typedef CGAL::Cartesian_d Kernel; -typedef CGAL::Optimisation_d_traits_d Traits; -typedef CGAL::Min_sphere_d Min_sphere; - +using Kernel = CGAL::Epick_d< CGAL::Dimension_tag<2> >;// CGAL::Dynamic_dimension_tag >; using Point = Kernel::Point_d; +using Traits = CGAL::Min_sphere_of_points_d_traits_d; +using Min_sphere = CGAL::Min_sphere_of_spheres_d; + using Points_off_reader = Gudhi::Points_off_reader; -// using Min_sphere = CGAL::Min_sphere_d; class Cech_blocker { public: - std::pair operator()(Simplex_handle origin_sh, Simplex_handle dict1_sh, Simplex_handle dict2_sh, Siblings* siblings) { - //std::vector path = {dict1_sh->first, origin_sh->first}; - Siblings* sib_path = siblings; - std::vector sphere_points = {point_cloud_[dict1_sh->first], point_cloud_[origin_sh->first]}; - do { - //path.push_back(sib_path->parent()); - sphere_points.push_back(point_cloud_[sib_path->parent()]); - sib_path = sib_path->oncles(); - } while (sib_path->oncles() != nullptr); - /*std::cout << square_threshold_ << "-"; - for (auto vh : path) { - std::cout << vh << " "; + bool operator()(Simplex_handle sh) { + std::vector points; + for (auto vertex : simplex_tree_.simplex_vertex_range(sh)) { + points.push_back(point_cloud_[vertex]); + std::cout << "#(" << vertex << ")#"; } - std::cout << std::endl;*/ - Min_sphere min_sphere(sphere_points.begin(), sphere_points.end()); - //std::cout << min_sphere.squared_radius() << std::endl; - Filtration_value squared_diameter = min_sphere.squared_radius() * 4.; - // Default blocker is always insert with the maximal filtration value between - // origin, dict1 and dict2 - return std::make_pair(squared_diameter < square_threshold_, - squared_diameter); + Min_sphere ms(points.begin(),points.end()); + Filtration_value radius = ms.radius(); + std::cout << "radius = " << radius << " - " << (radius > threshold_) << std::endl; + simplex_tree_.assign_filtration(sh, radius); + return (radius > threshold_); } - Cech_blocker(Filtration_value threshold, const std::vector& point_cloud) - : square_threshold_(threshold * threshold), + Cech_blocker(Simplex_tree& simplex_tree, Filtration_value threshold, const std::vector& point_cloud) + : simplex_tree_(simplex_tree), + threshold_(threshold), point_cloud_(point_cloud) { } private: - Filtration_value square_threshold_; + Simplex_tree simplex_tree_; + Filtration_value threshold_; std::vector point_cloud_; }; @@ -127,7 +117,7 @@ int main(int argc, char * argv[]) { // insert the proximity graph in the simplex tree st.insert_graph(prox_graph); // expand the graph until dimension dim_max - st.expansion_with_blockers(dim_max, Cech_blocker(threshold, off_reader.get_point_cloud())); + st.expansion_with_blockers(dim_max, Cech_blocker(st, threshold, off_reader.get_point_cloud())); std::cout << "The complex contains " << st.num_simplices() << " simplices \n"; std::cout << " and has dimension " << st.dimension() << " \n"; @@ -206,8 +196,6 @@ Graph_t compute_proximity_graph(InputPointRange &points, Filtration_value thresh std::vector< Filtration_value > edges_fil; Kernel k; - Filtration_value square_threshold = threshold * threshold; - Vertex_handle idx_u, idx_v; Filtration_value fil; idx_u = 0; @@ -215,7 +203,9 @@ Graph_t compute_proximity_graph(InputPointRange &points, Filtration_value thresh idx_v = idx_u + 1; for (auto it_v = it_u + 1; it_v != points.end(); ++it_v, ++idx_v) { fil = k.squared_distance_d_object()(*it_u, *it_v); - if (fil <= square_threshold) { + // For Cech Complex, threshold is a radius (distance /2) + fil = std::sqrt(fil) / 2.; + if (fil <= threshold) { edges.emplace_back(idx_u, idx_v); edges_fil.push_back(fil); } -- cgit v1.2.3 From 2e7447cf1deb3a1ac08f2fe90cd780901da65016 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 3 Jul 2017 13:16:54 +0000 Subject: Rename cythonize_gudhi.py in setup.py to be conform with Python convention (for easy_install and pip) git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@2578 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: c514a7c5096293380254339e7e60782194040823 --- src/cython/CMakeLists.txt | 6 ++--- src/cython/cythonize_gudhi.py.in | 49 ---------------------------------------- src/cython/setup.py.in | 49 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 52 deletions(-) delete mode 100644 src/cython/cythonize_gudhi.py.in create mode 100644 src/cython/setup.py.in diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index d801fb0b..99badffb 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -197,15 +197,15 @@ if(CYTHON_FOUND) configure_file(doc/Makefile.in "${CMAKE_CURRENT_BINARY_DIR}/doc/Makefile" @ONLY) configure_file(doc/make.bat.in "${CMAKE_CURRENT_BINARY_DIR}/doc/make.bat" @ONLY) - # Generate cythonize_gudhi.py file to cythonize Gudhi - configure_file(cythonize_gudhi.py.in "${CMAKE_CURRENT_BINARY_DIR}/cythonize_gudhi.py" @ONLY) + # 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) add_custom_command( OUTPUT gudhi.so WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/cythonize_gudhi.py" "build_ext" "--inplace") + COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/setup.py" "build_ext" "--inplace") add_custom_target(cython ALL DEPENDS gudhi.so COMMENT "Do not forget to add ${CMAKE_CURRENT_BINARY_DIR}/ to your PYTHONPATH before using examples or tests") diff --git a/src/cython/cythonize_gudhi.py.in b/src/cython/cythonize_gudhi.py.in deleted file mode 100644 index c1a1717a..00000000 --- a/src/cython/cythonize_gudhi.py.in +++ /dev/null @@ -1,49 +0,0 @@ -from distutils.core import setup, Extension -from Cython.Build import cythonize - -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. - - Author(s): Vincent Rouvreau - - Copyright (C) 2016 INRIA - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -""" - -__author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA" -__license__ = "GPL v3" - -gudhi = Extension( - "gudhi", - sources = ['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 = [@GUDHI_CYTHON_INCLUDE_DIRS@], - runtime_library_dirs=[@GUDHI_CYTHON_RUNTIME_LIBRARY_DIRS@], -) - -setup( - name = 'gudhi', - author='Vincent Rouvreau', - author_email='gudhi-contact@lists.gforge.inria.fr', - version='@GUDHI_VERSION@', - url='http://gudhi.gforge.inria.fr/', - ext_modules = cythonize(gudhi), -) diff --git a/src/cython/setup.py.in b/src/cython/setup.py.in new file mode 100644 index 00000000..c1a1717a --- /dev/null +++ b/src/cython/setup.py.in @@ -0,0 +1,49 @@ +from distutils.core import setup, Extension +from Cython.Build import cythonize + +"""This file is part of the Gudhi Library. The Gudhi library + (Geometric Understanding in Higher Dimensions) is a generic C++ + library for computational topology. + + Author(s): Vincent Rouvreau + + Copyright (C) 2016 INRIA + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +""" + +__author__ = "Vincent Rouvreau" +__copyright__ = "Copyright (C) 2016 INRIA" +__license__ = "GPL v3" + +gudhi = Extension( + "gudhi", + sources = ['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 = [@GUDHI_CYTHON_INCLUDE_DIRS@], + runtime_library_dirs=[@GUDHI_CYTHON_RUNTIME_LIBRARY_DIRS@], +) + +setup( + name = 'gudhi', + author='Vincent Rouvreau', + author_email='gudhi-contact@lists.gforge.inria.fr', + version='@GUDHI_VERSION@', + url='http://gudhi.gforge.inria.fr/', + ext_modules = cythonize(gudhi), +) -- cgit v1.2.3 -- cgit v1.2.3 From a4b7d528893f992115711225c7d4396de55c6c58 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 4 Jul 2017 13:37:29 +0000 Subject: Add Gudhi namespace for reader_utils Add confidence band in persistence_graphical_tools.py Persistence_diagram returns a plot that is no more showed. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/persistence_diagram_improvement@2582 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 4125f4f525057e89c8b0d5d164ea0b9d1df1bd72 --- .../example/bottleneck_read_file_example.cpp | 4 ++-- .../example/rips_distance_matrix_persistence.cpp | 2 +- ..._rips_complex_from_csv_distance_matrix_file.cpp | 2 +- src/Rips_complex/test/test_rips_complex.cpp | 2 +- src/common/include/gudhi/reader_utils.h | 10 +++++++--- src/common/test/test_distance_matrix_reader.cpp | 4 ++-- src/cython/cython/persistence_graphical_tools.py | 23 +++++++++++++++------- .../doc/persistence_graphical_tools_user.rst | 10 ++++++---- ...ex_diagram_persistence_from_off_file_example.py | 4 +++- 9 files changed, 39 insertions(+), 22 deletions(-) diff --git a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp b/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp index 238d99ad..1408681a 100644 --- a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp +++ b/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp @@ -36,8 +36,8 @@ int main(int argc, char** argv) { " distance (set by default to zero). The program will now terminate \n"; return -1; } - std::vector> diag1 = read_persistence_intervals_in_dimension(argv[1]); - std::vector> diag2 = read_persistence_intervals_in_dimension(argv[2]); + std::vector> diag1 = Gudhi::read_persistence_intervals_in_dimension(argv[1]); + std::vector> diag2 = Gudhi::read_persistence_intervals_in_dimension(argv[2]); double tolerance = 0.; if (argc == 4) { diff --git a/src/Persistent_cohomology/example/rips_distance_matrix_persistence.cpp b/src/Persistent_cohomology/example/rips_distance_matrix_persistence.cpp index 8517e7f6..d38808c7 100644 --- a/src/Persistent_cohomology/example/rips_distance_matrix_persistence.cpp +++ b/src/Persistent_cohomology/example/rips_distance_matrix_persistence.cpp @@ -57,7 +57,7 @@ int main(int argc, char * argv[]) { program_options(argc, argv, csv_matrix_file, filediag, threshold, dim_max, p, min_persistence); - Distance_matrix distances = read_lower_triangular_matrix_from_csv_file(csv_matrix_file); + Distance_matrix distances = Gudhi::read_lower_triangular_matrix_from_csv_file(csv_matrix_file); Rips_complex rips_complex_from_file(distances, threshold); // Construct the Rips complex in a Simplex Tree diff --git a/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp b/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp index 7ae8126f..9e182f1e 100644 --- a/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp +++ b/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp @@ -32,7 +32,7 @@ int main(int argc, char **argv) { // Init of a Rips complex from a distance matrix in a csv file // Default separator is ';' // ---------------------------------------------------------------------------- - Distance_matrix distances = read_lower_triangular_matrix_from_csv_file(csv_file_name); + Distance_matrix distances = Gudhi::read_lower_triangular_matrix_from_csv_file(csv_file_name); Rips_complex rips_complex_from_file(distances, threshold); std::streambuf* streambufffer; diff --git a/src/Rips_complex/test/test_rips_complex.cpp b/src/Rips_complex/test/test_rips_complex.cpp index fc2179f2..fc83f5f7 100644 --- a/src/Rips_complex/test/test_rips_complex.cpp +++ b/src/Rips_complex/test/test_rips_complex.cpp @@ -244,7 +244,7 @@ BOOST_AUTO_TEST_CASE(Rips_doc_csv_file) { std::cout << "========== CSV FILE NAME = " << csv_file_name << " - Rips threshold=" << rips_threshold << "==========" << std::endl; - Distance_matrix distances = read_lower_triangular_matrix_from_csv_file(csv_file_name); + Distance_matrix distances = Gudhi::read_lower_triangular_matrix_from_csv_file(csv_file_name); Rips_complex rips_complex_from_file(distances, rips_threshold); const int DIMENSION_1 = 1; diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index f1684d78..8e99acfc 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -37,6 +37,8 @@ #include #include // for pair +namespace Gudhi { + // Keep this file tag for Doxygen to parse the code, otherwise, functions are not documented. // It is required for global functions and variables. @@ -331,7 +333,7 @@ void read_persistence_intervals_and_dimension(std::string const& filename, Outpu } } } -} // read_persistence_diagram_from_file +} // read_persistence_diagram_from_file /** Reads a file containing persistence intervals. @@ -347,7 +349,7 @@ inline std::map>> read_persistence_in filename, boost::make_function_output_iterator([&ret](std::tuple t) { ret[get<0>(t)].push_back(std::make_pair(get<1>(t), get<2>(t))); })); return ret; -} // read_persistence_diagram_from_file +} // read_persistence_diagram_from_file /** @@ -367,6 +369,8 @@ inline std::vector> read_persistence_intervals_in_dime filename, boost::make_function_output_iterator([&ret](std::tuple t) { ret.emplace_back(get<1>(t), get<2>(t)); })); return ret; -} // read_persistence_diagram_from_file +} // read_persistence_diagram_from_file + +} // namespace Gudhi #endif // READER_UTILS_H_ diff --git a/src/common/test/test_distance_matrix_reader.cpp b/src/common/test/test_distance_matrix_reader.cpp index 95a73bd9..656e6f2e 100644 --- a/src/common/test/test_distance_matrix_reader.cpp +++ b/src/common/test/test_distance_matrix_reader.cpp @@ -36,7 +36,7 @@ BOOST_AUTO_TEST_CASE( lower_triangular_distance_matrix ) { Distance_matrix from_lower_triangular; // Read lower_triangular_distance_matrix.csv file where the separator is a ',' - from_lower_triangular = read_lower_triangular_matrix_from_csv_file("lower_triangular_distance_matrix.csv", + from_lower_triangular = Gudhi::read_lower_triangular_matrix_from_csv_file("lower_triangular_distance_matrix.csv", ','); for (auto& i : from_lower_triangular) { for (auto j : i) { @@ -69,7 +69,7 @@ BOOST_AUTO_TEST_CASE( full_square_distance_matrix ) { Distance_matrix from_full_square; // Read full_square_distance_matrix.csv file where the separator is the default one ';' - from_full_square = read_lower_triangular_matrix_from_csv_file("full_square_distance_matrix.csv"); + from_full_square = Gudhi::read_lower_triangular_matrix_from_csv_file("full_square_distance_matrix.csv"); for (auto& i : from_full_square) { for (auto j : i) { std::cout << j << " "; diff --git a/src/cython/cython/persistence_graphical_tools.py b/src/cython/cython/persistence_graphical_tools.py index a984633e..70ff6001 100755 --- a/src/cython/cython/persistence_graphical_tools.py +++ b/src/cython/cython/persistence_graphical_tools.py @@ -5,7 +5,7 @@ import numpy as np (Geometric Understanding in Higher Dimensions) is a generic C++ library for computational topology. - Author(s): Vincent Rouvreau + Author(s): Vincent Rouvreau, Bertrand Michel Copyright (C) 2016 INRIA @@ -27,11 +27,13 @@ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 INRIA" __license__ = "GPL v3" -def __min_birth_max_death(persistence): +def __min_birth_max_death(persistence, band_boot=0.): """This function returns (min_birth, max_death) from the persistence. :param persistence: The persistence to plot. :type persistence: list of tuples(dimension, tuple(birth, death)). + :param band_boot: bootstrap band + :type band_boot: float. :returns: (float, float) -- (min_birth, max_death). """ # Look for minimum birth date and maximum death date for plot optimisation @@ -45,6 +47,8 @@ def __min_birth_max_death(persistence): max_death = float(interval[1][0]) if float(interval[1][0]) < min_birth: min_birth = float(interval[1][0]) + if band_boot > 0.: + max_death += band_boot return (min_birth, max_death) """ @@ -108,16 +112,18 @@ def plot_persistence_barcode(persistence, alpha=0.6): plt.axis([axis_start, infinity, 0, ind]) plt.show() -def plot_persistence_diagram(persistence, alpha=0.6): - """This function plots the persistence diagram. +def plot_persistence_diagram(persistence, alpha=0.6, band_boot=0.): + """This function plots the persistence diagram with confidence band. :param persistence: The persistence to plot. :type persistence: list of tuples(dimension, tuple(birth, death)). :param alpha: alpha value in [0.0, 1.0] for points and horizontal infinity line (default is 0.6). :type alpha: float. - :returns: plot -- An diagram plot of persistence. + :param band_boot: bootstrap band + :type band_boot: float. + :returns: plot -- A diagram plot of persistence. """ - (min_birth, max_death) = __min_birth_max_death(persistence) + (min_birth, max_death) = __min_birth_max_death(persistence, band_boot) ind = 0 delta = ((max_death - min_birth) / 10.0) # Replace infinity values with max_death + delta for diagram to be more @@ -131,6 +137,9 @@ def plot_persistence_diagram(persistence, alpha=0.6): plt.plot(x, x, color='k', linewidth=1.0) plt.plot(x, [infinity] * len(x), linewidth=1.0, color='k', alpha=alpha) plt.text(axis_start, infinity, r'$\infty$', color='k', alpha=alpha) + # bootstrap band + if band_boot > 0.: + plt.fill_between(x, x, x+band_boot, alpha=alpha, facecolor='red') # Draw points in loop for interval in reversed(persistence): @@ -149,4 +158,4 @@ def plot_persistence_diagram(persistence, alpha=0.6): plt.ylabel('Death') # Ends plot on infinity value and starts a little bit before min_birth plt.axis([axis_start, infinity, axis_start, infinity + delta]) - plt.show() + return plt diff --git a/src/cython/doc/persistence_graphical_tools_user.rst b/src/cython/doc/persistence_graphical_tools_user.rst index cae18323..bc731f12 100644 --- a/src/cython/doc/persistence_graphical_tools_user.rst +++ b/src/cython/doc/persistence_graphical_tools_user.rst @@ -51,16 +51,18 @@ This function can display the persistence result as a diagram: import gudhi - rips_complex = gudhi.RipsComplex(off_file='tore3D_300.off', max_edge_length=2.0) + rips_complex = gudhi.RipsComplex(off_file='tore3D_1307.off', max_edge_length=0.2) simplex_tree = rips_complex.create_simplex_tree(max_dimension=3) diag = simplex_tree.persistence() - gudhi.plot_persistence_diagram(diag) + pplot = gudhi.plot_persistence_diagram(diag, band_boot=0.13) + pplot.show() .. plot:: import gudhi - rips_complex = gudhi.RipsComplex(off_file='tore3D_300.off', max_edge_length=2.0) + rips_complex = gudhi.RipsComplex(off_file='tore3D_1307.off', max_edge_length=0.2) simplex_tree = rips_complex.create_simplex_tree(max_dimension=3) diag = simplex_tree.persistence() - gudhi.plot_persistence_diagram(diag) + pplot = gudhi.plot_persistence_diagram(diag, band_boot=0.13) + pplot.show() diff --git a/src/cython/example/rips_complex_diagram_persistence_from_off_file_example.py b/src/cython/example/rips_complex_diagram_persistence_from_off_file_example.py index 4c21b98e..5951eedf 100755 --- a/src/cython/example/rips_complex_diagram_persistence_from_off_file_example.py +++ b/src/cython/example/rips_complex_diagram_persistence_from_off_file_example.py @@ -39,6 +39,7 @@ parser = argparse.ArgumentParser(description='RipsComplex creation from ' parser.add_argument("-f", "--file", type=str, required=True) parser.add_argument("-e", "--max_edge_length", type=float, default=0.5) parser.add_argument("-d", "--max_dimension", type=int, default=1) +parser.add_argument("-b", "--band_boot", type=float, default=0.) parser.add_argument('--no-diagram', default=False, action='store_true' , help='Flag for not to display the diagrams') args = parser.parse_args() @@ -64,7 +65,8 @@ with open(args.file, 'r') as f: print(simplex_tree.betti_numbers()) if args.no_diagram == False: - gudhi.plot_persistence_diagram(diag) + pplot = gudhi.plot_persistence_diagram(diag, band_boot=args.band_boot) + pplot.show() else: print(args.file, "is not a valid OFF file") -- cgit v1.2.3 From 093866604f986dded2db6a96d7dbc4b6d1f7194a Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 5 Jul 2017 15:03:57 +0000 Subject: Fix default filtration value given by the graph_expansion method with blocker git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2585 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 38586e3c9a622c74c6b6658bdc0a6776c5ea5d5a --- src/Simplex_tree/example/CMakeLists.txt | 17 -- src/Simplex_tree/example/block.cpp | 30 ++- .../example/cech_complex_step_by_step.cpp | 230 --------------------- src/Simplex_tree/include/gudhi/Simplex_tree.h | 93 +++++---- 4 files changed, 61 insertions(+), 309 deletions(-) delete mode 100644 src/Simplex_tree/example/cech_complex_step_by_step.cpp diff --git a/src/Simplex_tree/example/CMakeLists.txt b/src/Simplex_tree/example/CMakeLists.txt index 7a30979f..4557deb3 100644 --- a/src/Simplex_tree/example/CMakeLists.txt +++ b/src/Simplex_tree/example/CMakeLists.txt @@ -34,25 +34,8 @@ if(GMP_FOUND AND CGAL_FOUND) "${CMAKE_SOURCE_DIR}/data/points/bunny_5000.off") install(TARGETS Simplex_tree_example_alpha_shapes_3_from_off DESTINATION bin) - - # - # TO BE REMOVED !! - # - - add_executable ( Simplex_tree_example_cech_complex_step_by_step cech_complex_step_by_step.cpp ) - target_link_libraries(Simplex_tree_example_cech_complex_step_by_step ${GMP_LIBRARIES} ${CGAL_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) - if (TBB_FOUND) - target_link_libraries(Simplex_tree_example_cech_complex_step_by_step ${TBB_LIBRARIES}) - endif() - add_test(NAME Simplex_tree_example_cech_complex_step_by_step COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" "-d" "3" "-r" "6.0") - endif() -# -# TO BE REMOVED !! -# - add_executable ( Simplex_tree_example_block block.cpp ) if (TBB_FOUND) target_link_libraries(Simplex_tree_example_block ${TBB_LIBRARIES}) diff --git a/src/Simplex_tree/example/block.cpp b/src/Simplex_tree/example/block.cpp index 75b8d1ea..67697b89 100644 --- a/src/Simplex_tree/example/block.cpp +++ b/src/Simplex_tree/example/block.cpp @@ -24,15 +24,13 @@ #include #include -#include // for pair -#include using Simplex_tree = Gudhi::Simplex_tree<>; using Simplex_handle = Simplex_tree::Simplex_handle; int main(int argc, char * const argv[]) { - // Construct the Simplex Tree + // Construct the Simplex Tree with a 1-skeleton graph example Simplex_tree simplexTree; simplexTree.insert_simplex({0, 1}, 0.); @@ -46,31 +44,27 @@ int main(int argc, char * const argv[]) { simplexTree.insert_simplex({4, 5}, 8.); simplexTree.insert_simplex({4, 6}, 9.); simplexTree.insert_simplex({5, 6}, 10.); - simplexTree.insert_simplex({6}, 11.); - - std::cout << "********************************************************************\n"; - std::cout << "* The complex contains " << simplexTree.num_simplices() << " simplices\n"; - std::cout << " - dimension " << simplexTree.dimension() << " - filtration " << simplexTree.filtration() << "\n"; - std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; - for (auto f_simplex : simplexTree.filtration_simplex_range()) { - std::cout << " " << "[" << simplexTree.filtration(f_simplex) << "] "; - for (auto vertex : simplexTree.simplex_vertex_range(f_simplex)) - std::cout << "(" << vertex << ")"; - std::cout << std::endl; - } + simplexTree.insert_simplex({6}, 10.); simplexTree.expansion_with_blockers(3, [&](Simplex_handle sh){ bool result = false; + std::cout << "Blocker on ["; + // User can loop on the vertices from the given simplex_handle i.e. for (auto vertex : simplexTree.simplex_vertex_range(sh)) { + // We block the expansion, if the vertex '6' is in the given list of vertices if (vertex == 6) result = true; - std::cout << "#(" << vertex << ")#"; + std::cout << vertex << ", "; } - std::cout << std::endl; + std::cout << "] ( " << simplexTree.filtration(sh); + // User can re-assign a new filtration value directly in the blocker (default is the maximal value of boudaries) + simplexTree.assign_filtration(sh, simplexTree.filtration(sh) + 1.); + + std::cout << " + 1. ) = " << result << std::endl; + return result; }); - simplexTree.initialize_filtration(); std::cout << "********************************************************************\n"; std::cout << "* The complex contains " << simplexTree.num_simplices() << " simplices\n"; std::cout << " - dimension " << simplexTree.dimension() << " - filtration " << simplexTree.filtration() << "\n"; diff --git a/src/Simplex_tree/example/cech_complex_step_by_step.cpp b/src/Simplex_tree/example/cech_complex_step_by_step.cpp deleted file mode 100644 index 1805c792..00000000 --- a/src/Simplex_tree/example/cech_complex_step_by_step.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/* This file is part of the Gudhi Library. The Gudhi library - * (Geometric Understanding in Higher Dimensions) is a generic C++ - * library for computational topology. - * - * Author(s): Clément Maria - * - * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include - -// #include -// #include -// #include -#include -#include -#include - -#include - -#include -#include -#include // infinity -#include // for pair -#include - -// ---------------------------------------------------------------------------- -// rips_persistence_step_by_step is an example of each step that is required to -// build a Rips over a Simplex_tree. Please refer to rips_persistence to see -// how to do the same thing with the Rips_complex wrapper for less detailed -// steps. -// ---------------------------------------------------------------------------- - -// Types definition -using Simplex_tree = Gudhi::Simplex_tree; -using Vertex_handle = Simplex_tree::Vertex_handle; -using Simplex_handle = Simplex_tree::Simplex_handle; -using Filtration_value = Simplex_tree::Filtration_value; -using Siblings = Simplex_tree::Siblings; -using Graph_t = boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS -, boost::property < vertex_filtration_t, Filtration_value > -, boost::property < edge_filtration_t, Filtration_value > ->; -using Edge_t = std::pair< Vertex_handle, Vertex_handle >; - -using Kernel = CGAL::Epick_d< CGAL::Dimension_tag<2> >;// CGAL::Dynamic_dimension_tag >; -using Point = Kernel::Point_d; -using Traits = CGAL::Min_sphere_of_points_d_traits_d; -using Min_sphere = CGAL::Min_sphere_of_spheres_d; - -using Points_off_reader = Gudhi::Points_off_reader; - -class Cech_blocker { - public: - bool operator()(Simplex_handle sh) { - std::vector points; - for (auto vertex : simplex_tree_.simplex_vertex_range(sh)) { - points.push_back(point_cloud_[vertex]); - std::cout << "#(" << vertex << ")#"; - } - Min_sphere ms(points.begin(),points.end()); - Filtration_value radius = ms.radius(); - std::cout << "radius = " << radius << " - " << (radius > threshold_) << std::endl; - simplex_tree_.assign_filtration(sh, radius); - return (radius > threshold_); - } - Cech_blocker(Simplex_tree& simplex_tree, Filtration_value threshold, const std::vector& point_cloud) - : simplex_tree_(simplex_tree), - threshold_(threshold), - point_cloud_(point_cloud) { } - private: - Simplex_tree simplex_tree_; - Filtration_value threshold_; - std::vector point_cloud_; -}; - -template< typename InputPointRange> -Graph_t compute_proximity_graph(InputPointRange &points, Filtration_value threshold); - -void program_options(int argc, char * argv[] - , std::string & off_file_points - , Filtration_value & threshold - , int & dim_max); - -int main(int argc, char * argv[]) { - std::string off_file_points; - Filtration_value threshold; - int dim_max; - - program_options(argc, argv, off_file_points, threshold, dim_max); - - // Extract the points from the file filepoints - Points_off_reader off_reader(off_file_points); - - // Compute the proximity graph of the points - Graph_t prox_graph = compute_proximity_graph(off_reader.get_point_cloud(), threshold); - - //Min_sphere sph1(off_reader.get_point_cloud()[0], off_reader.get_point_cloud()[1], off_reader.get_point_cloud()[2]); - // Construct the Rips complex in a Simplex Tree - Simplex_tree st; - // insert the proximity graph in the simplex tree - st.insert_graph(prox_graph); - // expand the graph until dimension dim_max - st.expansion_with_blockers(dim_max, Cech_blocker(st, threshold, off_reader.get_point_cloud())); - - std::cout << "The complex contains " << st.num_simplices() << " simplices \n"; - std::cout << " and has dimension " << st.dimension() << " \n"; - - // Sort the simplices in the order of the filtration - st.initialize_filtration(); - - std::cout << "********************************************************************\n"; - // Display the Simplex_tree - Can not be done in the middle of 2 inserts - std::cout << "* The complex contains " << st.num_simplices() << " simplices\n"; - std::cout << " - dimension " << st.dimension() << " - filtration " << st.filtration() << "\n"; - std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; - for (auto f_simplex : st.filtration_simplex_range()) { - std::cout << " " << "[" << st.filtration(f_simplex) << "] "; - for (auto vertex : st.simplex_vertex_range(f_simplex)) { - std::cout << static_cast(vertex) << " "; - } - std::cout << std::endl; - } - - return 0; -} - -void program_options(int argc, char * argv[] - , std::string & off_file_points - , Filtration_value & threshold - , int & dim_max) { - namespace po = boost::program_options; - po::options_description hidden("Hidden options"); - hidden.add_options() - ("input-file", po::value(&off_file_points), - "Name of an OFF file containing a point set.\n"); - - po::options_description visible("Allowed options", 100); - visible.add_options() - ("help,h", "produce help message") - ("max-edge-length,r", - po::value(&threshold)->default_value(std::numeric_limits::infinity()), - "Maximal length of an edge for the Rips complex construction.") - ("cpx-dimension,d", po::value(&dim_max)->default_value(1), - "Maximal dimension of the Rips complex we want to compute."); - - po::positional_options_description pos; - pos.add("input-file", 1); - - po::options_description all; - all.add(visible).add(hidden); - - po::variables_map vm; - po::store(po::command_line_parser(argc, argv). - options(all).positional(pos).run(), vm); - po::notify(vm); - - if (vm.count("help") || !vm.count("input-file")) { - std::cout << std::endl; - std::cout << "Construct a Cech complex defined on a set of input points.\n \n"; - - std::cout << "Usage: " << argv[0] << " [options] input-file" << std::endl << std::endl; - std::cout << visible << std::endl; - std::abort(); - } -} - -/** Output the proximity graph of the points. - * - * If points contains n elements, the proximity graph is the graph - * with n vertices, and an edge [u,v] iff the distance function between - * points u and v is smaller than threshold. - * - * The type PointCloud furnishes .begin() and .end() methods, that return - * iterators with value_type Point. - */ -template< typename InputPointRange> -Graph_t compute_proximity_graph(InputPointRange &points, Filtration_value threshold) { - std::vector< Edge_t > edges; - std::vector< Filtration_value > edges_fil; - - Kernel k; - Vertex_handle idx_u, idx_v; - Filtration_value fil; - idx_u = 0; - for (auto it_u = points.begin(); it_u != points.end(); ++it_u) { - idx_v = idx_u + 1; - for (auto it_v = it_u + 1; it_v != points.end(); ++it_v, ++idx_v) { - fil = k.squared_distance_d_object()(*it_u, *it_v); - // For Cech Complex, threshold is a radius (distance /2) - fil = std::sqrt(fil) / 2.; - if (fil <= threshold) { - edges.emplace_back(idx_u, idx_v); - edges_fil.push_back(fil); - } - } - ++idx_u; - } - - Graph_t skel_graph(edges.begin() - , edges.end() - , edges_fil.begin() - , idx_u); // number of points labeled from 0 to idx_u-1 - - auto vertex_prop = boost::get(vertex_filtration_t(), skel_graph); - - boost::graph_traits::vertex_iterator vi, vi_end; - for (std::tie(vi, vi_end) = boost::vertices(skel_graph); - vi != vi_end; ++vi) { - boost::put(vertex_prop, *vi, 0.); - } - - return skel_graph; -} diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index ff31fd89..72cb9401 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1081,31 +1081,23 @@ class Simplex_tree { } } - - - /*-------------------------------------------------------------------------------------------------------------------------*/ - /*-------------------------------------------------------------------------------------------------------------------------*/ - /*-------------------------------------------------------------------------------------------------------------------------*/ - public: - /** \brief Expands the Simplex_tree containing only its one skeleton - * until dimension max_dim. + /** \brief Expands the Simplex_tree containing only its one skeleton until dimension max_dim according with a user + * given blocker expansion oracle * - * The expanded simplicial complex until dimension \f$d\f$ - * attached to a graph \f$G\f$ is the maximal simplicial complex of - * dimension at most \f$d\f$ admitting the graph \f$G\f$ as \f$1\f$-skeleton. - * The filtration value assigned to a simplex is the maximal filtration - * value of one of its edges. + * The expanded simplicial complex until dimension \f$d\f$ attached to a graph \f$G\f$ is the maximal simplicial + * complex of dimension at most \f$d\f$ admitting the graph \f$G\f$ as \f$1\f$-skeleton. + * The filtration value assigned to a simplex is the maximal filtration value of one of its edges. + * The blocker expansion oracle shall answer true on a Simplex_handle if this Simplex_handle has to be removed, + * false otherwise. The blocker expansion oracle can re-assign the filtration value. * - * The Simplex_tree must contain no simplex of dimension bigger than - * 1 when calling the method. */ + * The Simplex_tree must contain no simplex of dimension bigger than 1 when calling the method. */ template< typename Blocker > void expansion_with_blockers(int max_dim, Blocker blocker_expansion_function) { dimension_ = max_dim; // Loop must be from the end to the beginning, as higher dimension simplex are always on the left part of the tree for (auto& simplex : boost::adaptors::reverse(root_.members())) { if (has_children(&simplex)) { - std::cout << " *** root on " << static_cast(simplex.first) << std::endl; siblings_expansion_with_blockers(simplex.second.children(), max_dim - 1, blocker_expansion_function); } } @@ -1113,7 +1105,7 @@ class Simplex_tree { } private: - /** \brief Recursive expansion of the simplex tree.*/ + /** \brief Recursive expansion with blockers of the simplex tree.*/ template< typename Blocker > void siblings_expansion_with_blockers(Siblings* siblings, // must contain elements int k, Blocker blocker_expansion_function) { @@ -1131,22 +1123,16 @@ class Simplex_tree { std::vector > intersection; while(next != simplex) { bool to_be_inserted = true; - std::cout << "to_be_inserted = " << to_be_inserted << " dim = " << k << " simplex = " << simplex->first << " - next = " << next->first << std::endl; - + Filtration_value filt = simplex->second.filtration(); + // If all the boundaries are present, 'next' needs to be inserted for (auto& border : boundary_simplex_range(simplex)) { - to_be_inserted = to_be_inserted && find_child(border, next->first); - - for (auto vertex : simplex_vertex_range(border)) { - std::cout << "(" << vertex << ")"; - } - std::cout << " | "; + Simplex_handle border_child = find_child(border, next->first); + to_be_inserted = to_be_inserted && (border_child != null_simplex()); + filt = std::max(filt, filtration(border_child)); } - std::cout << std::endl; if (to_be_inserted) { - std::cout << next->first << " to be inserted." << std::endl; - intersection.emplace_back(next->first, Node(nullptr, 0.0)); + intersection.emplace_back(next->first, Node(nullptr, filt)); } - // loop until simplex is reached next++; } @@ -1158,34 +1144,50 @@ class Simplex_tree { intersection); // boost::container::ordered_unique_range_t // intersection must be cleared before the function to be called recursively intersection.clear(); - simplex->second.assign_children(new_sib); - siblings_expansion_with_blockers(new_sib, k - 1, blocker_expansion_function); + + std::vector blocked_new_sib_list; + // As all intersections are inserted, we can call the blocker function on all new_sib members + for (auto new_sib_member = new_sib->members().begin(); + new_sib_member != new_sib->members().end(); + new_sib_member++) { + bool blocker_result = blocker_expansion_function(new_sib_member); + // new_sib member has been blocked by the blocker function + // add it to the list to be removed - do not perform it while looping on it + if (blocker_result) + blocked_new_sib_list.push_back(new_sib_member); + } + bool removed = false; + for (auto& blocked_new_sib_member : blocked_new_sib_list){ + removed = removed || remove_maximal_simplex(blocked_new_sib_member); + } + if (removed) { + // ensure the children property + simplex->second.assign_children(siblings); + } else { + // ensure recursive call + simplex->second.assign_children(new_sib); + siblings_expansion_with_blockers(new_sib, k - 1, blocker_expansion_function); + } } else { // ensure the children property simplex->second.assign_children(siblings); intersection.clear(); } - } - } - /** \private Returns true if vh is a member of sh*/ - bool find_child(Simplex_handle sh, Vertex_handle vh) { + /* \private Returns the Simplex_handle composed of the vertex list (from the Simplex_handle), plus the given + * Vertex_handle. + * Returns null_simplex() if it does not exist + */ + Simplex_handle find_child(Simplex_handle sh, Vertex_handle vh) { std::vector child = {vh}; - std::cout << "+" << vh; for (auto vertex : simplex_vertex_range(sh)) { - std::cout << "+" << vertex; child.push_back(vertex); } - std::cout << " => " << (find(child) != null_simplex()) << "___ "; - return find(child) != null_simplex(); + return find(child); } - /*-------------------------------------------------------------------------------------------------------------------------*/ - /*-------------------------------------------------------------------------------------------------------------------------*/ - /*-------------------------------------------------------------------------------------------------------------------------*/ - public: /** \brief Write the hasse diagram of the simplicial complex in os. * @@ -1295,11 +1297,12 @@ class Simplex_tree { public: /** \brief Remove a maximal simplex. * @param[in] sh Simplex handle on the maximal simplex to remove. + * @return true if siblings was deleted, false otherwise. * \pre Please check the simplex has no coface before removing it. * \exception std::invalid_argument In debug mode, if sh has children. * \post Be aware that removing is shifting data in a flat_map (initialize_filtration to be done). */ - void remove_maximal_simplex(Simplex_handle sh) { + bool remove_maximal_simplex(Simplex_handle sh) { // Guarantee the simplex has no children GUDHI_CHECK(!has_children(sh), std::invalid_argument("Simplex_tree::remove_maximal_simplex - argument has children")); @@ -1315,7 +1318,9 @@ class Simplex_tree { // Sibling is emptied : must be deleted, and its parent must point on his own Sibling child->oncles()->members().at(child->parent()).assign_children(child->oncles()); delete child; + return true; } + return false; } private: -- cgit v1.2.3 From 40aaa716132bb2f6a6110e229d91345618bf1088 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 5 Jul 2017 17:50:45 +0000 Subject: Checkin tests and fixes git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2586 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 0f9cbe3d6b94e939e151dea989ae99f7e4f3bffa --- src/Simplex_tree/example/CMakeLists.txt | 8 +- src/Simplex_tree/example/block.cpp | 80 ------- .../example/graph_expansion_with_blocker.cpp | 79 +++++++ src/Simplex_tree/test/CMakeLists.txt | 8 + .../simplex_tree_graph_expansion_unit_test.cpp | 235 +++++++++++++++++++++ src/common/include/gudhi/Points_off_io.h | 2 +- 6 files changed, 328 insertions(+), 84 deletions(-) delete mode 100644 src/Simplex_tree/example/block.cpp create mode 100644 src/Simplex_tree/example/graph_expansion_with_blocker.cpp create mode 100644 src/Simplex_tree/test/simplex_tree_graph_expansion_unit_test.cpp diff --git a/src/Simplex_tree/example/CMakeLists.txt b/src/Simplex_tree/example/CMakeLists.txt index 4557deb3..c414c019 100644 --- a/src/Simplex_tree/example/CMakeLists.txt +++ b/src/Simplex_tree/example/CMakeLists.txt @@ -36,8 +36,10 @@ if(GMP_FOUND AND CGAL_FOUND) install(TARGETS Simplex_tree_example_alpha_shapes_3_from_off DESTINATION bin) endif() -add_executable ( Simplex_tree_example_block block.cpp ) +add_executable ( Simplex_tree_example_graph_expansion_with_blocker graph_expansion_with_blocker.cpp ) if (TBB_FOUND) - target_link_libraries(Simplex_tree_example_block ${TBB_LIBRARIES}) + target_link_libraries(Simplex_tree_example_graph_expansion_with_blocker ${TBB_LIBRARIES}) endif() -add_test(NAME Simplex_tree_example_block COMMAND $) +add_test(NAME Simplex_tree_example_graph_expansion_with_blocker COMMAND $) + +install(TARGETS Simplex_tree_example_graph_expansion_with_blocker DESTINATION bin) diff --git a/src/Simplex_tree/example/block.cpp b/src/Simplex_tree/example/block.cpp deleted file mode 100644 index 67697b89..00000000 --- a/src/Simplex_tree/example/block.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* This file is part of the Gudhi Library. The Gudhi library - * (Geometric Understanding in Higher Dimensions) is a generic C++ - * library for computational topology. - * - * Author(s): Vincent Rouvreau - * - * Copyright (C) 2014 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include - -#include - -using Simplex_tree = Gudhi::Simplex_tree<>; -using Simplex_handle = Simplex_tree::Simplex_handle; - -int main(int argc, char * const argv[]) { - - // Construct the Simplex Tree with a 1-skeleton graph example - Simplex_tree simplexTree; - - simplexTree.insert_simplex({0, 1}, 0.); - simplexTree.insert_simplex({0, 2}, 1.); - simplexTree.insert_simplex({0, 3}, 2.); - simplexTree.insert_simplex({1, 2}, 3.); - simplexTree.insert_simplex({1, 3}, 4.); - simplexTree.insert_simplex({2, 3}, 5.); - simplexTree.insert_simplex({2, 4}, 6.); - simplexTree.insert_simplex({3, 6}, 7.); - simplexTree.insert_simplex({4, 5}, 8.); - simplexTree.insert_simplex({4, 6}, 9.); - simplexTree.insert_simplex({5, 6}, 10.); - simplexTree.insert_simplex({6}, 10.); - - simplexTree.expansion_with_blockers(3, [&](Simplex_handle sh){ - bool result = false; - std::cout << "Blocker on ["; - // User can loop on the vertices from the given simplex_handle i.e. - for (auto vertex : simplexTree.simplex_vertex_range(sh)) { - // We block the expansion, if the vertex '6' is in the given list of vertices - if (vertex == 6) - result = true; - std::cout << vertex << ", "; - } - std::cout << "] ( " << simplexTree.filtration(sh); - // User can re-assign a new filtration value directly in the blocker (default is the maximal value of boudaries) - simplexTree.assign_filtration(sh, simplexTree.filtration(sh) + 1.); - - std::cout << " + 1. ) = " << result << std::endl; - - return result; - }); - - std::cout << "********************************************************************\n"; - std::cout << "* The complex contains " << simplexTree.num_simplices() << " simplices\n"; - std::cout << " - dimension " << simplexTree.dimension() << " - filtration " << simplexTree.filtration() << "\n"; - std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; - for (auto f_simplex : simplexTree.filtration_simplex_range()) { - std::cout << " " << "[" << simplexTree.filtration(f_simplex) << "] "; - for (auto vertex : simplexTree.simplex_vertex_range(f_simplex)) - std::cout << "(" << vertex << ")"; - std::cout << std::endl; - } - - return 0; -} diff --git a/src/Simplex_tree/example/graph_expansion_with_blocker.cpp b/src/Simplex_tree/example/graph_expansion_with_blocker.cpp new file mode 100644 index 00000000..d0d3f038 --- /dev/null +++ b/src/Simplex_tree/example/graph_expansion_with_blocker.cpp @@ -0,0 +1,79 @@ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): Vincent Rouvreau + * + * Copyright (C) 2014 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include + +#include + +using Simplex_tree = Gudhi::Simplex_tree<>; +using Simplex_handle = Simplex_tree::Simplex_handle; + +int main(int argc, char * const argv[]) { + + // Construct the Simplex Tree with a 1-skeleton graph example + Simplex_tree simplexTree; + + simplexTree.insert_simplex({0, 1}, 0.); + simplexTree.insert_simplex({0, 2}, 1.); + simplexTree.insert_simplex({0, 3}, 2.); + simplexTree.insert_simplex({1, 2}, 3.); + simplexTree.insert_simplex({1, 3}, 4.); + simplexTree.insert_simplex({2, 3}, 5.); + simplexTree.insert_simplex({2, 4}, 6.); + simplexTree.insert_simplex({3, 6}, 7.); + simplexTree.insert_simplex({4, 5}, 8.); + simplexTree.insert_simplex({4, 6}, 9.); + simplexTree.insert_simplex({5, 6}, 10.); + simplexTree.insert_simplex({6}, 10.); + + simplexTree.expansion_with_blockers(3, [&](Simplex_handle sh){ + bool result = false; + std::cout << "Blocker on ["; + // User can loop on the vertices from the given simplex_handle i.e. + for (auto vertex : simplexTree.simplex_vertex_range(sh)) { + // We block the expansion, if the vertex '6' is in the given list of vertices + if (vertex == 6) + result = true; + std::cout << vertex << ", "; + } + std::cout << "] ( " << simplexTree.filtration(sh); + // User can re-assign a new filtration value directly in the blocker (default is the maximal value of boudaries) + simplexTree.assign_filtration(sh, simplexTree.filtration(sh) + 1.); + + std::cout << " + 1. ) = " << result << std::endl; + + return result; + }); + + std::cout << "********************************************************************\n"; + std::cout << "* The complex contains " << simplexTree.num_simplices() << " simplices\n"; + std::cout << " - dimension " << simplexTree.dimension() << " - filtration " << simplexTree.filtration() << "\n"; + std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; + for (auto f_simplex : simplexTree.filtration_simplex_range()) { + std::cout << " " << "[" << simplexTree.filtration(f_simplex) << "] "; + for (auto vertex : simplexTree.simplex_vertex_range(f_simplex)) + std::cout << "(" << vertex << ")"; + std::cout << std::endl; + } + + return 0; +} diff --git a/src/Simplex_tree/test/CMakeLists.txt b/src/Simplex_tree/test/CMakeLists.txt index 17b0f2c2..2408d937 100644 --- a/src/Simplex_tree/test/CMakeLists.txt +++ b/src/Simplex_tree/test/CMakeLists.txt @@ -13,3 +13,11 @@ endif() file(COPY "simplex_tree_for_unit_test.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) gudhi_add_coverage_test(Simplex_tree_test_unit) + +add_executable ( Simplex_tree_test_unit_graph_expansion simplex_tree_graph_expansion_unit_test.cpp ) +target_link_libraries(Simplex_tree_test_unit_graph_expansion ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +if (TBB_FOUND) + target_link_libraries(Simplex_tree_test_unit_graph_expansion ${TBB_LIBRARIES}) +endif() + +gudhi_add_coverage_test(Simplex_tree_test_unit_graph_expansion) diff --git a/src/Simplex_tree/test/simplex_tree_graph_expansion_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_graph_expansion_unit_test.cpp new file mode 100644 index 00000000..bef82275 --- /dev/null +++ b/src/Simplex_tree/test/simplex_tree_graph_expansion_unit_test.cpp @@ -0,0 +1,235 @@ +#include +#include +#include +#include +#include // std::pair, std::make_pair +#include // float comparison +#include +#include // greater + +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MODULE "simplex_tree" +#include +#include + +// ^ +// /!\ Nothing else from Simplex_tree shall be included to test includes are well defined. +#include "gudhi/Simplex_tree.h" + +using namespace Gudhi; + +typedef boost::mpl::list, Simplex_tree> list_of_tested_variants; + + +bool AreAlmostTheSame(float a, float b) { + return std::fabs(a - b) < std::numeric_limits::epsilon(); +} + +BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_expansion_with_blockers_3, typeST, list_of_tested_variants) { + using Simplex_handle = typename typeST::Simplex_handle; + // Construct the Simplex Tree with a 1-skeleton graph example + typeST simplex_tree; + + simplex_tree.insert_simplex({0, 1}, 0.); + simplex_tree.insert_simplex({0, 2}, 1.); + simplex_tree.insert_simplex({0, 3}, 2.); + simplex_tree.insert_simplex({1, 2}, 3.); + simplex_tree.insert_simplex({1, 3}, 4.); + simplex_tree.insert_simplex({2, 3}, 5.); + simplex_tree.insert_simplex({2, 4}, 6.); + simplex_tree.insert_simplex({3, 6}, 7.); + simplex_tree.insert_simplex({4, 5}, 8.); + simplex_tree.insert_simplex({4, 6}, 9.); + simplex_tree.insert_simplex({5, 6}, 10.); + simplex_tree.insert_simplex({6}, 10.); + + simplex_tree.expansion_with_blockers(3, [&](Simplex_handle sh){ + bool result = false; + std::cout << "Blocker on ["; + // User can loop on the vertices from the given simplex_handle i.e. + for (auto vertex : simplex_tree.simplex_vertex_range(sh)) { + // We block the expansion, if the vertex '6' is in the given list of vertices + if (vertex == 6) + result = true; + std::cout << vertex << ", "; + } + std::cout << "] ( " << simplex_tree.filtration(sh); + // User can re-assign a new filtration value directly in the blocker (default is the maximal value of boudaries) + simplex_tree.assign_filtration(sh, simplex_tree.filtration(sh) + 1.); + + std::cout << " + 1. ) = " << result << std::endl; + + return result; + }); + + std::cout << "********************************************************************\n"; + std::cout << "simplex_tree_expansion_with_blockers_3\n"; + std::cout << "********************************************************************\n"; + std::cout << "* The complex contains " << simplex_tree.num_simplices() << " simplices\n"; + std::cout << " - dimension " << simplex_tree.dimension() << " - filtration " << simplex_tree.filtration() << "\n"; + std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; + for (auto f_simplex : simplex_tree.filtration_simplex_range()) { + std::cout << " " << "[" << simplex_tree.filtration(f_simplex) << "] "; + for (auto vertex : simplex_tree.simplex_vertex_range(f_simplex)) + std::cout << "(" << vertex << ")"; + std::cout << std::endl; + } + + BOOST_CHECK(simplex_tree.num_simplices() == 23); + BOOST_CHECK(simplex_tree.dimension() == 3); + // {4, 5, 6} shall be blocked + BOOST_CHECK(simplex_tree.find({4, 5, 6}) == simplex_tree.null_simplex()); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({0,1,2})), 4.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({0,1,3})), 5.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({0,2,3})), 6.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({1,2,3})), 6.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({0,1,2,3})), 7.)); + +} + +BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_expansion_with_blockers_2, typeST, list_of_tested_variants) { + using Simplex_handle = typename typeST::Simplex_handle; + // Construct the Simplex Tree with a 1-skeleton graph example + typeST simplex_tree; + + simplex_tree.insert_simplex({0, 1}, 0.); + simplex_tree.insert_simplex({0, 2}, 1.); + simplex_tree.insert_simplex({0, 3}, 2.); + simplex_tree.insert_simplex({1, 2}, 3.); + simplex_tree.insert_simplex({1, 3}, 4.); + simplex_tree.insert_simplex({2, 3}, 5.); + simplex_tree.insert_simplex({2, 4}, 6.); + simplex_tree.insert_simplex({3, 6}, 7.); + simplex_tree.insert_simplex({4, 5}, 8.); + simplex_tree.insert_simplex({4, 6}, 9.); + simplex_tree.insert_simplex({5, 6}, 10.); + simplex_tree.insert_simplex({6}, 10.); + + simplex_tree.expansion_with_blockers(2, [&](Simplex_handle sh){ + bool result = false; + std::cout << "Blocker on ["; + // User can loop on the vertices from the given simplex_handle i.e. + for (auto vertex : simplex_tree.simplex_vertex_range(sh)) { + // We block the expansion, if the vertex '6' is in the given list of vertices + if (vertex == 6) + result = true; + std::cout << vertex << ", "; + } + std::cout << "] ( " << simplex_tree.filtration(sh); + // User can re-assign a new filtration value directly in the blocker (default is the maximal value of boudaries) + simplex_tree.assign_filtration(sh, simplex_tree.filtration(sh) + 1.); + + std::cout << " + 1. ) = " << result << std::endl; + + return result; + }); + + std::cout << "********************************************************************\n"; + std::cout << "simplex_tree_expansion_with_blockers_2\n"; + std::cout << "********************************************************************\n"; + std::cout << "* The complex contains " << simplex_tree.num_simplices() << " simplices\n"; + std::cout << " - dimension " << simplex_tree.dimension() << " - filtration " << simplex_tree.filtration() << "\n"; + std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; + for (auto f_simplex : simplex_tree.filtration_simplex_range()) { + std::cout << " " << "[" << simplex_tree.filtration(f_simplex) << "] "; + for (auto vertex : simplex_tree.simplex_vertex_range(f_simplex)) + std::cout << "(" << vertex << ")"; + std::cout << std::endl; + } + + BOOST_CHECK(simplex_tree.num_simplices() == 22); + BOOST_CHECK(simplex_tree.dimension() == 2); + // {4, 5, 6} shall be blocked + BOOST_CHECK(simplex_tree.find({4, 5, 6}) == simplex_tree.null_simplex()); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({0,1,2})), 4.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({0,1,3})), 5.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({0,2,3})), 6.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({1,2,3})), 6.)); + BOOST_CHECK(simplex_tree.find({0,1,2,3}) == simplex_tree.null_simplex()); +} + +BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_expansion, typeST, list_of_tested_variants) { + // Construct the Simplex Tree with a 1-skeleton graph example + typeST simplex_tree; + + simplex_tree.insert_simplex({0, 1}, 0.); + simplex_tree.insert_simplex({0, 2}, 1.); + simplex_tree.insert_simplex({0, 3}, 2.); + simplex_tree.insert_simplex({1, 2}, 3.); + simplex_tree.insert_simplex({1, 3}, 4.); + simplex_tree.insert_simplex({2, 3}, 5.); + simplex_tree.insert_simplex({2, 4}, 6.); + simplex_tree.insert_simplex({3, 6}, 7.); + simplex_tree.insert_simplex({4, 5}, 8.); + simplex_tree.insert_simplex({4, 6}, 9.); + simplex_tree.insert_simplex({5, 6}, 10.); + simplex_tree.insert_simplex({6}, 10.); + + simplex_tree.expansion(3); + std::cout << "********************************************************************\n"; + std::cout << "simplex_tree_expansion_3\n"; + std::cout << "********************************************************************\n"; + std::cout << "* The complex contains " << simplex_tree.num_simplices() << " simplices\n"; + std::cout << " - dimension " << simplex_tree.dimension() << " - filtration " << simplex_tree.filtration() << "\n"; + std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; + for (auto f_simplex : simplex_tree.filtration_simplex_range()) { + std::cout << " " << "[" << simplex_tree.filtration(f_simplex) << "] "; + for (auto vertex : simplex_tree.simplex_vertex_range(f_simplex)) + std::cout << "(" << vertex << ")"; + std::cout << std::endl; + } + + BOOST_CHECK(simplex_tree.num_simplices() == 24); + BOOST_CHECK(simplex_tree.dimension() == 3); + + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({4,5,6})), 10.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({0,1,2})), 3.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({0,1,3})), 4.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({0,2,3})), 5.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({1,2,3})), 5.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({0,1,2,3})), 5.)); + +} + +BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_expansion_2, typeST, list_of_tested_variants) { + // Construct the Simplex Tree with a 1-skeleton graph example + typeST simplex_tree; + + simplex_tree.insert_simplex({0, 1}, 0.); + simplex_tree.insert_simplex({0, 2}, 1.); + simplex_tree.insert_simplex({0, 3}, 2.); + simplex_tree.insert_simplex({1, 2}, 3.); + simplex_tree.insert_simplex({1, 3}, 4.); + simplex_tree.insert_simplex({2, 3}, 5.); + simplex_tree.insert_simplex({2, 4}, 6.); + simplex_tree.insert_simplex({3, 6}, 7.); + simplex_tree.insert_simplex({4, 5}, 8.); + simplex_tree.insert_simplex({4, 6}, 9.); + simplex_tree.insert_simplex({5, 6}, 10.); + simplex_tree.insert_simplex({6}, 10.); + + simplex_tree.expansion(2); + + std::cout << "********************************************************************\n"; + std::cout << "simplex_tree_expansion_2\n"; + std::cout << "********************************************************************\n"; + std::cout << "* The complex contains " << simplex_tree.num_simplices() << " simplices\n"; + std::cout << " - dimension " << simplex_tree.dimension() << " - filtration " << simplex_tree.filtration() << "\n"; + std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; + for (auto f_simplex : simplex_tree.filtration_simplex_range()) { + std::cout << " " << "[" << simplex_tree.filtration(f_simplex) << "] "; + for (auto vertex : simplex_tree.simplex_vertex_range(f_simplex)) + std::cout << "(" << vertex << ")"; + std::cout << std::endl; + } + + BOOST_CHECK(simplex_tree.num_simplices() == 23); + BOOST_CHECK(simplex_tree.dimension() == 2); + + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({4,5,6})), 10.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({0,1,2})), 3.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({0,1,3})), 4.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({0,2,3})), 5.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({1,2,3})), 5.)); + BOOST_CHECK(simplex_tree.find({0,1,2,3}) == simplex_tree.null_simplex()); +} diff --git a/src/common/include/gudhi/Points_off_io.h b/src/common/include/gudhi/Points_off_io.h index 2104b411..29af8a8a 100644 --- a/src/common/include/gudhi/Points_off_io.h +++ b/src/common/include/gudhi/Points_off_io.h @@ -85,7 +85,7 @@ class Points_off_visitor_reader { std::cout << std::endl; #endif // DEBUG_TRACES // Fill the point cloud - point_cloud.push_back(Point_d(point.end() - point.begin(), point.begin(), point.end())); + point_cloud.push_back(Point_d(point.begin(), point.end())); } // Off_reader visitor maximal_face implementation - Only points are read -- cgit v1.2.3 From 73c3f473fa9d4dc6965607edd1ad748d26cfb86b Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 6 Jul 2017 07:10:41 +0000 Subject: Doc example addition git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2587 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: eec20e1b4242460fbe97a9622d69ad35bfdca8b7 --- src/Simplex_tree/doc/Intro_simplex_tree.h | 9 ++++++--- src/Simplex_tree/include/gudhi/Simplex_tree.h | 2 +- src/common/doc/main_page.h | 3 +++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Simplex_tree/doc/Intro_simplex_tree.h b/src/Simplex_tree/doc/Intro_simplex_tree.h index f5b72ff6..769491d9 100644 --- a/src/Simplex_tree/doc/Intro_simplex_tree.h +++ b/src/Simplex_tree/doc/Intro_simplex_tree.h @@ -67,10 +67,13 @@ Information of the Simplex Tree: Number of vertices = 10 Number of simplices = 98 \endcode * * \li - * Simplex_tree/example_alpha_shapes_3_simplex_tree_from_off_file.cpp - Simplex tree is computed and displayed from a 3D alpha - * complex (Requires CGAL, GMP and GMPXX to be installed) - * + * Simplex_tree/example_alpha_shapes_3_simplex_tree_from_off_file.cpp - Simplex tree is computed and displayed + * from a 3D alpha complex (Requires CGAL, GMP and GMPXX to be installed). * + * \li + * Simplex_tree/graph_expansion_with_blocker.cpp - Simple simplex tree construction from a one-skeleton graph with + * a simple blocker expansion method. + * * \subsection filteredcomplexeshassecomplex Hasse complex * The second one is the Hasse_complex. The Hasse complex is a data structure representing explicitly all co-dimension * 1 incidence relations in a complex. It is consequently faster when accessing the boundary of a simplex, but is less diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 72cb9401..b7ec2c1c 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1089,7 +1089,7 @@ class Simplex_tree { * complex of dimension at most \f$d\f$ admitting the graph \f$G\f$ as \f$1\f$-skeleton. * The filtration value assigned to a simplex is the maximal filtration value of one of its edges. * The blocker expansion oracle shall answer true on a Simplex_handle if this Simplex_handle has to be removed, - * false otherwise. The blocker expansion oracle can re-assign the filtration value. + * false otherwise. The blocker expansion oracle can re-assign the filtration value if needed. * * The Simplex_tree must contain no simplex of dimension bigger than 1 when calling the method. */ template< typename Blocker > diff --git a/src/common/doc/main_page.h b/src/common/doc/main_page.h index bd4615f5..7219bcfa 100644 --- a/src/common/doc/main_page.h +++ b/src/common/doc/main_page.h @@ -364,6 +364,8 @@ make doxygen * Simplex_tree/example_alpha_shapes_3_simplex_tree_from_off_file.cpp * \li * Simplex_tree/simplex_tree_from_cliques_of_graph.cpp + * \li + * Simplex_tree/graph_expansion_with_blocker.cpp * \li * Persistent_cohomology/alpha_complex_3d_persistence.cpp * \li @@ -450,6 +452,7 @@ make doxygen * @example Simplex_tree/simple_simplex_tree.cpp * @example Simplex_tree/example_alpha_shapes_3_simplex_tree_from_off_file.cpp * @example Simplex_tree/simplex_tree_from_cliques_of_graph.cpp + * @example Simplex_tree/graph_expansion_with_blocker.cpp * @example Skeleton_blocker/Skeleton_blocker_from_simplices.cpp * @example Skeleton_blocker/Skeleton_blocker_iteration.cpp * @example Skeleton_blocker/Skeleton_blocker_link.cpp -- cgit v1.2.3 From deb3ac325f84a6e023923da4cc8e2886d98c3132 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 6 Jul 2017 07:35:16 +0000 Subject: Uused variable git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2589 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: eb0f479d8bdd70010918c80e2902eed9a25806c4 --- src/Simplex_tree/example/simple_simplex_tree.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Simplex_tree/example/simple_simplex_tree.cpp b/src/Simplex_tree/example/simple_simplex_tree.cpp index f27d7ab8..33face2a 100644 --- a/src/Simplex_tree/example/simple_simplex_tree.cpp +++ b/src/Simplex_tree/example/simple_simplex_tree.cpp @@ -250,7 +250,6 @@ int main(int argc, char * const argv[]) { else std::cout << "***- NO IT ISN'T\n"; - invSimplexVector = { 0, 1 }; simplexFound = simplexTree.find({ 0, 1 }); std::cout << "**************IS THE SIMPLEX {0,1} IN THE SIMPLEX TREE ?\n"; if (simplexFound != simplexTree.null_simplex()) -- cgit v1.2.3 From 4832d865981bb74c8afc7240e953adc8f54c52b0 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 6 Jul 2017 15:38:44 +0000 Subject: Plot functions now returns a plot that can be modified before to be shown Add confidence band in plot_persistence_diagram Cythonization of read_lower_triangular_matrix_from_csv_file and read_persistence_intervals functions Add Python tests of read functions git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/persistence_diagram_improvement@2590 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 522ec31e9ad3a9a688875612d246114704b8c74e --- src/common/include/gudhi/reader_utils.h | 2 +- src/cython/CMakeLists.txt | 2 +- src/cython/cython/persistence_graphical_tools.py | 4 +- src/cython/cython/reader_utils.pyx | 95 ++++++++++++++++++++++ src/cython/doc/pyplots/barcode_persistence.py | 2 +- src/cython/doc/pyplots/diagram_persistence.py | 8 +- ...ex_diagram_persistence_from_off_file_example.py | 4 +- ...ex_diagram_persistence_from_off_file_example.py | 5 +- ...ex_diagram_persistence_from_off_file_example.py | 5 +- .../example/gudhi_graphical_tools_example.py | 9 +- ...ersistence_from_distance_matrix_file_example.py | 4 +- src/cython/example/rips_persistence_diagram.py | 3 +- ...complex_plain_homology_from_off_file_example.py | 4 +- src/cython/gudhi.pyx.in | 1 + src/cython/include/Reader_utils_interface.h | 54 ++++++++++++ src/cython/include/Rips_complex_interface.h | 2 +- src/cython/test/test_reader_utils.py | 81 ++++++++++++++++++ 17 files changed, 267 insertions(+), 18 deletions(-) create mode 100644 src/cython/cython/reader_utils.pyx create mode 100644 src/cython/include/Reader_utils_interface.h create mode 100755 src/cython/test/test_reader_utils.py diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index 8e99acfc..f16ae61d 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -359,7 +359,7 @@ If `only_this_dim` = -1, dimension is ignored and all lines are returned. If `only_this_dim` is >= 0, only the lines where dimension = `only_this_dim` (or where dimension is not specified) are returned. The return value is an `std::vector>` -where `dim` is an `int`, `birth` a `double`, and `death` a `double`. +where `birth` a `double`, and `death` a `double`. Note: the function does not check that birth <= death. **/ inline std::vector> read_persistence_intervals_in_dimension(std::string const& filename, int only_this_dim = -1) { diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index 99badffb..f427b3c5 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -100,7 +100,7 @@ if(CYTHON_FOUND) file(COPY "${CMAKE_SOURCE_DIR}/data/distance_matrix/full_square_distance_matrix.csv" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/doc/") # Persistence graphical tools examples file(COPY "${CMAKE_SOURCE_DIR}/data/bitmap/3d_torus.txt" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/doc/") - file(COPY "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/doc/") + file(COPY "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/doc/") if (NOT CGAL_VERSION VERSION_LESS 4.8.1) # If CGAL_VERSION >= 4.8.1, include subsampling diff --git a/src/cython/cython/persistence_graphical_tools.py b/src/cython/cython/persistence_graphical_tools.py index 70ff6001..da709b8a 100755 --- a/src/cython/cython/persistence_graphical_tools.py +++ b/src/cython/cython/persistence_graphical_tools.py @@ -113,13 +113,13 @@ def plot_persistence_barcode(persistence, alpha=0.6): plt.show() def plot_persistence_diagram(persistence, alpha=0.6, band_boot=0.): - """This function plots the persistence diagram with confidence band. + """This function plots the persistence diagram with an optional confidence band. :param persistence: The persistence to plot. :type persistence: list of tuples(dimension, tuple(birth, death)). :param alpha: alpha value in [0.0, 1.0] for points and horizontal infinity line (default is 0.6). :type alpha: float. - :param band_boot: bootstrap band + :param band_boot: bootstrap band (not displayed if :math:`\leq` 0.) :type band_boot: float. :returns: plot -- A diagram plot of persistence. """ diff --git a/src/cython/cython/reader_utils.pyx b/src/cython/cython/reader_utils.pyx new file mode 100644 index 00000000..14976167 --- /dev/null +++ b/src/cython/cython/reader_utils.pyx @@ -0,0 +1,95 @@ +from cython cimport numeric +from libcpp.vector cimport vector +from libcpp.string cimport string +from libcpp.map cimport map +from libcpp.pair cimport pair +import os + +"""This file is part of the Gudhi Library. The Gudhi library + (Geometric Understanding in Higher Dimensions) is a generic C++ + library for computational topology. + + Author(s): Vincent Rouvreau + + Copyright (C) 2017 INRIA + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +""" + +__author__ = "Vincent Rouvreau" +__copyright__ = "Copyright (C) 2017 INRIA" +__license__ = "GPL v3" + +cdef extern from "Reader_utils_interface.h" namespace "Gudhi": + vector[vector[double]] read_matrix_from_csv_file(string off_file, char separator) + map[int, vector[pair[double, double]]] read_pers_intervals_grouped_by_dimension(string filename) + vector[pair[double, double]] read_pers_intervals_in_dimension(string filename, int only_this_dim) + +def read_lower_triangular_matrix_from_csv_file(csv_file='', separator=';'): + """Read lower triangular matrix from a CSV style file. + + :param csv_file: A CSV file style name. + :type csv_file: string + :param separator: The value separator in the CSV file. Default value is ';' + :type separator: char + + :returns: The lower triangular matrix. + :rtype: vector[vector[double]] + """ + if csv_file is not '': + if os.path.isfile(csv_file): + return read_matrix_from_csv_file(str.encode(csv_file), str.encode(separator)[0]) + print("file " + csv_file + " not set or not found.") + return [] + +def read_persistence_intervals_grouped_by_dimension(persistence_file=''): + """Reads a file containing persistence intervals. + Each line might contain 2, 3 or 4 values: [[field] dimension] birth death + The return value is an `map[dim, vector[pair[birth, death]]]` + where `dim` is an `int`, `birth` a `double`, and `death` a `double`. + Note: the function does not check that birth <= death. + + :param persistence_file: A persistence file style name. + :type persistence_file: string + + :returns: The persistence pairs grouped by dimension. + :rtype: map[int, vector[pair[double, double]]] + """ + if persistence_file is not '': + if os.path.isfile(persistence_file): + return read_pers_intervals_grouped_by_dimension(str.encode(persistence_file)) + print("file " + persistence_file + " not set or not found.") + return [] + +def read_persistence_intervals_in_dimension(persistence_file='', only_this_dim=-1): + """Reads a file containing persistence intervals. + Each line might contain 2, 3 or 4 values: [[field] dimension] birth death + If `only_this_dim` = -1, dimension is ignored and all lines are returned. + If `only_this_dim` is >= 0, only the lines where dimension = `only_this_dim` + (or where dimension is not specified) are returned. + The return value is an `vector[pair[birth, death]]` + where `birth` a `double`, and `death` a `double`. + Note: the function does not check that birth <= death. + + :param persistence_file: A persistence file style name. + :type persistence_file: string + + :returns: The persistence pairs grouped by dimension. + :rtype: map[int, vector[pair[double, double]]] + """ + if persistence_file is not '': + if os.path.isfile(persistence_file): + return read_pers_intervals_in_dimension(str.encode(persistence_file), only_this_dim) + print("file " + persistence_file + " not set or not found.") + return [] diff --git a/src/cython/doc/pyplots/barcode_persistence.py b/src/cython/doc/pyplots/barcode_persistence.py index c06ac5a7..b021049f 100755 --- a/src/cython/doc/pyplots/barcode_persistence.py +++ b/src/cython/doc/pyplots/barcode_persistence.py @@ -1,5 +1,5 @@ import gudhi -periodic_cc = gudhi.PeriodicCubicalComplex(perseus_file='../3d_torus.txt') +periodic_cc = gudhi.PeriodicCubicalComplex(perseus_file='3d_torus.txt') diag = periodic_cc.persistence() gudhi.plot_persistence_barcode(diag) diff --git a/src/cython/doc/pyplots/diagram_persistence.py b/src/cython/doc/pyplots/diagram_persistence.py index b4714fe3..56d6c50f 100755 --- a/src/cython/doc/pyplots/diagram_persistence.py +++ b/src/cython/doc/pyplots/diagram_persistence.py @@ -1,5 +1,7 @@ import gudhi -alpha_complex = gudhi.AlphaComplex(off_file='../tore3D_300.off') -diag = alpha_complex.persistence() -gudhi.plot_persistence_diagram(diag) +rips_complex = gudhi.RipsComplex(off_file='tore3D_1307.off', max_edge_length=0.2) +simplex_tree = rips_complex.create_simplex_tree(max_dimension=3) +diag = simplex_tree.persistence() +pplot = gudhi.plot_persistence_diagram(diag, band_boot=0.13) +pplot.show() diff --git a/src/cython/example/alpha_complex_diagram_persistence_from_off_file_example.py b/src/cython/example/alpha_complex_diagram_persistence_from_off_file_example.py index adedc7d2..b4487be4 100755 --- a/src/cython/example/alpha_complex_diagram_persistence_from_off_file_example.py +++ b/src/cython/example/alpha_complex_diagram_persistence_from_off_file_example.py @@ -38,6 +38,7 @@ parser = argparse.ArgumentParser(description='AlphaComplex creation from ' 'points from the given OFF file.') parser.add_argument("-f", "--file", type=str, required=True) parser.add_argument("-a", "--max_alpha_square", type=float, default=0.5) +parser.add_argument("-b", "--band_boot", type=float, default=0.) parser.add_argument('--no-diagram', default=False, action='store_true' , help='Flag for not to display the diagrams') args = parser.parse_args() @@ -63,7 +64,8 @@ with open(args.file, 'r') as f: print(simplex_tree.betti_numbers()) if args.no_diagram == False: - gudhi.plot_persistence_diagram(diag) + pplot = gudhi.plot_persistence_diagram(diag, band_boot=args.band_boot) + pplot.show() else: print(args.file, "is not a valid OFF file") diff --git a/src/cython/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py b/src/cython/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py index 2371c36c..e3f362dc 100755 --- a/src/cython/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py +++ b/src/cython/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py @@ -40,6 +40,7 @@ parser.add_argument("-f", "--file", type=str, required=True) parser.add_argument("-a", "--max_alpha_square", type=float, required=True) parser.add_argument("-n", "--number_of_landmarks", type=int, required=True) parser.add_argument("-d", "--limit_dimension", type=int, required=True) +parser.add_argument("-b", "--band_boot", type=float, default=0.) parser.add_argument('--no-diagram', default=False, action='store_true' , help='Flag for not to display the diagrams') args = parser.parse_args() @@ -70,8 +71,8 @@ with open(args.file, 'r') as f: print(simplex_tree.betti_numbers()) if args.no_diagram == False: - gudhi.plot_persistence_diagram(diag) - + pplot = gudhi.plot_persistence_diagram(diag, band_boot=args.band_boot) + pplot.show() else: print(args.file, "is not a valid OFF file") diff --git a/src/cython/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py b/src/cython/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py index 5748aa8a..c236d992 100755 --- a/src/cython/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py +++ b/src/cython/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py @@ -40,6 +40,7 @@ parser.add_argument("-f", "--file", type=str, required=True) parser.add_argument("-a", "--max_alpha_square", type=float, required=True) parser.add_argument("-n", "--number_of_landmarks", type=int, required=True) parser.add_argument("-d", "--limit_dimension", type=int, required=True) +parser.add_argument("-b", "--band_boot", type=float, default=0.) parser.add_argument('--no-diagram', default=False, action='store_true' , help='Flag for not to display the diagrams') args = parser.parse_args() @@ -70,8 +71,8 @@ with open(args.file, 'r') as f: print(simplex_tree.betti_numbers()) if args.no_diagram == False: - gudhi.plot_persistence_diagram(diag) - + pplot = gudhi.plot_persistence_diagram(diag, band_boot=args.band_boot) + pplot.show() else: print(args.file, "is not a valid OFF file") diff --git a/src/cython/example/gudhi_graphical_tools_example.py b/src/cython/example/gudhi_graphical_tools_example.py index bc3b16ec..ed87806b 100755 --- a/src/cython/example/gudhi_graphical_tools_example.py +++ b/src/cython/example/gudhi_graphical_tools_example.py @@ -44,4 +44,11 @@ gudhi.plot_persistence_barcode(persistence) print("#####################################################################") print("Show diagram persistence example") -gudhi.plot_persistence_diagram(persistence) +pplot = gudhi.plot_persistence_diagram(persistence) +pplot.show() + +print("#####################################################################") +print("Show diagram persistence example with a confidence band") + +pplot = gudhi.plot_persistence_diagram(persistence, band_boot=0.2) +pplot.show() 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 984dbf1b..3baebd17 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 @@ -39,6 +39,7 @@ parser = argparse.ArgumentParser(description='RipsComplex creation from ' parser.add_argument("-f", "--file", type=str, required=True) parser.add_argument("-e", "--max_edge_length", type=float, default=0.5) parser.add_argument("-d", "--max_dimension", type=int, default=1) +parser.add_argument("-b", "--band_boot", type=float, default=0.) parser.add_argument('--no-diagram', default=False, action='store_true' , help='Flag for not to display the diagrams') args = parser.parse_args() @@ -61,4 +62,5 @@ print("betti_numbers()=") print(simplex_tree.betti_numbers()) if args.no_diagram == False: - gudhi.plot_persistence_diagram(diag) + pplot = gudhi.plot_persistence_diagram(diag, band_boot=args.band_boot) + pplot.show() diff --git a/src/cython/example/rips_persistence_diagram.py b/src/cython/example/rips_persistence_diagram.py index 4e5cd2c8..9bfea41c 100755 --- a/src/cython/example/rips_persistence_diagram.py +++ b/src/cython/example/rips_persistence_diagram.py @@ -39,4 +39,5 @@ simplex_tree = rips.create_simplex_tree(max_dimension=1) diag = simplex_tree.persistence(homology_coeff_field=2, min_persistence=0) print("diag=", diag) -gudhi.plot_persistence_diagram(diag) +pplot = gudhi.plot_persistence_diagram(diag) +pplot.show() diff --git a/src/cython/example/tangential_complex_plain_homology_from_off_file_example.py b/src/cython/example/tangential_complex_plain_homology_from_off_file_example.py index 4845eb47..6145e7f2 100755 --- a/src/cython/example/tangential_complex_plain_homology_from_off_file_example.py +++ b/src/cython/example/tangential_complex_plain_homology_from_off_file_example.py @@ -37,6 +37,7 @@ parser = argparse.ArgumentParser(description='TangentialComplex creation from ' '- Constructs a tangential complex with the ' 'points from the given OFF file') parser.add_argument("-f", "--file", type=str, required=True) +parser.add_argument("-b", "--band_boot", type=float, default=0.) parser.add_argument('--no-diagram', default=False, action='store_true' , help='Flag for not to display the diagrams') args = parser.parse_args() @@ -59,7 +60,8 @@ with open(args.file, 'r') as f: print(st.betti_numbers()) if args.no_diagram == False: - gudhi.plot_persistence_diagram(diag) + pplot = gudhi.plot_persistence_diagram(diag, band_boot=args.band_boot) + pplot.show() else: print(args.file, "is not a valid OFF file") diff --git a/src/cython/gudhi.pyx.in b/src/cython/gudhi.pyx.in index 34d7c3b5..ed2d28cc 100644 --- a/src/cython/gudhi.pyx.in +++ b/src/cython/gudhi.pyx.in @@ -30,6 +30,7 @@ include "cython/rips_complex.pyx" include "cython/cubical_complex.pyx" include "cython/periodic_cubical_complex.pyx" include "cython/persistence_graphical_tools.py" +include "cython/reader_utils.pyx" include "cython/witness_complex.pyx" include "cython/strong_witness_complex.pyx" @GUDHI_CYTHON_ALPHA_COMPLEX@ diff --git a/src/cython/include/Reader_utils_interface.h b/src/cython/include/Reader_utils_interface.h new file mode 100644 index 00000000..b87b6cca --- /dev/null +++ b/src/cython/include/Reader_utils_interface.h @@ -0,0 +1,54 @@ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): Vincent Rouvreau + * + * Copyright (C) 2017 INRIA + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef INCLUDE_READER_UTILS_INTERFACE_H_ +#define INCLUDE_READER_UTILS_INTERFACE_H_ + +#include + +#include +#include +#include + +namespace Gudhi { + +// Redefine functions with a different name in order the original name can be used in the Python version. +std::vector> read_matrix_from_csv_file(const std::string& filename, + const char separator = ';') { + return read_lower_triangular_matrix_from_csv_file(filename, separator); +} + +inline std::map>> + read_pers_intervals_grouped_by_dimension(std::string const& filename) { + return read_persistence_intervals_grouped_by_dimension(filename); +} + +inline std::vector> + read_pers_intervals_in_dimension(std::string const& filename, int only_this_dim = -1) { + return read_persistence_intervals_in_dimension(filename, only_this_dim); +} + + +} // namespace Gudhi + + +#endif // INCLUDE_READER_UTILS_INTERFACE_H_ diff --git a/src/cython/include/Rips_complex_interface.h b/src/cython/include/Rips_complex_interface.h index 6d813f4a..d06ee4bd 100644 --- a/src/cython/include/Rips_complex_interface.h +++ b/src/cython/include/Rips_complex_interface.h @@ -66,7 +66,7 @@ class Rips_complex_interface { } else { // Rips construction where values is a distance matrix Distance_matrix distances = - read_lower_triangular_matrix_from_csv_file::Filtration_value>(file_name); + Gudhi::read_lower_triangular_matrix_from_csv_file::Filtration_value>(file_name); rips_complex_ = new Rips_complex::Filtration_value>(distances, threshold); } } diff --git a/src/cython/test/test_reader_utils.py b/src/cython/test/test_reader_utils.py new file mode 100755 index 00000000..517bf109 --- /dev/null +++ b/src/cython/test/test_reader_utils.py @@ -0,0 +1,81 @@ +import gudhi + +"""This file is part of the Gudhi Library. The Gudhi library + (Geometric Understanding in Higher Dimensions) is a generic C++ + library for computational topology. + + Author(s): Vincent Rouvreau + + Copyright (C) 2017 INRIA + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +""" + +__author__ = "Vincent Rouvreau" +__copyright__ = "Copyright (C) 2017 INRIA" +__license__ = "GPL v3" + + +def test_non_existing_csv_file(): + # Try to open a non existing file + matrix = gudhi.read_lower_triangular_matrix_from_csv_file(csv_file='pouetpouettralala.toubiloubabdou') + assert matrix == [] + +def test_full_square_distance_matrix_csv_file(): + # Create test file + test_file = open('full_square_distance_matrix.csv', 'w') + test_file.write('0;1;2;3;\n1;0;4;5;\n2;4;0;6;\n3;5;6;0;') + test_file.close() + matrix = gudhi.read_lower_triangular_matrix_from_csv_file(csv_file="full_square_distance_matrix.csv") + assert matrix == [[], [1.0], [2.0, 4.0], [3.0, 5.0, 6.0]] + +def test_lower_triangular_distance_matrix_csv_file(): + # Create test file + test_file = open('lower_triangular_distance_matrix.csv', 'w') + test_file.write('\n1,\n2,3,\n4,5,6,\n7,8,9,10,') + test_file.close() + matrix = gudhi.read_lower_triangular_matrix_from_csv_file(csv_file="lower_triangular_distance_matrix.csv", separator=",") + assert matrix == [[], [1.0], [2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0, 10.0]] + +def test_non_existing_persistence_file(): + # Try to open a non existing file + persistence = gudhi.read_persistence_intervals_grouped_by_dimension(persistence_file='pouetpouettralala.toubiloubabdou') + assert persistence == [] + persistence = gudhi.read_persistence_intervals_in_dimension(persistence_file='pouetpouettralala.toubiloubabdou', only_this_dim=1) + assert persistence == [] + +def test_read_persistence_intervals_without_dimension(): + # Create test file + test_file = open('persistence_intervals_without_dimension.pers', 'w') + test_file.write('# Simple persistence diagram without dimension\n2.7 3.7\n9.6 14.\n34.2 34.974\n3. inf') + test_file.close() + persistence = gudhi.read_persistence_intervals_in_dimension(persistence_file='persistence_intervals_without_dimension.pers') + assert persistence == [[2.7, 3.7], [9.6, 14.], [34.2, 34.974], [3., float('Inf')]] + persistence = gudhi.read_persistence_intervals_in_dimension(persistence_file='persistence_intervals_without_dimension.pers', only_this_dim=15) + assert persistence == [[2.7, 3.7], [9.6, 14.], [34.2, 34.974], [3., float('Inf')]] + persistence = gudhi.read_persistence_intervals_grouped_by_dimension(persistence_file='persistence_intervals_without_dimension.pers') + assert persistence == {-1: [(2.7, 3.7), (9.6, 14.0), (34.2, 34.974), (3.0, float('Inf'))]} + +def test_read_persistence_intervals_with_dimension(): + # Create test file + test_file = open('persistence_intervals_with_dimension.pers', 'w') + test_file.write('# Simple persistence diagram with dimension\n0 2.7 3.7\n1 9.6 14.\n3 34.2 34.974\n1 3. inf') + test_file.close() + persistence = gudhi.read_persistence_intervals_in_dimension(persistence_file='persistence_intervals_with_dimension.pers') + assert persistence == [[2.7, 3.7], [9.6, 14.], [34.2, 34.974], [3., float('Inf')]] + persistence = gudhi.read_persistence_intervals_in_dimension(persistence_file='persistence_intervals_with_dimension.pers', only_this_dim=1) + # BUG !!! + assert persistence == [[2.7, 3.7], [9.6, 14.], [34.2, 34.974], [3., float('Inf')]] + persistence = gudhi.read_persistence_intervals_grouped_by_dimension(persistence_file='persistence_intervals_with_dimension.pers') + assert persistence == {0: [(2.7, 3.7)], 1: [(9.6, 14.0), (3.0, float('Inf'))], 3: [(34.2, 34.974)]} -- cgit v1.2.3 From 2c353d0c3db1c5c8fc11cb28ea65c90c559766a1 Mon Sep 17 00:00:00 2001 From: glisse Date: Mon, 10 Jul 2017 15:05:46 +0000 Subject: Cubical: use +inf instead of UINT_MAX as filtration value for non-simplices. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@2595 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: c578be16d9559b6d271cdb63be3a58a015735ab7 --- .../include/gudhi/Bitmap_cubical_complex.h | 27 +++++++++++----------- src/cython/test/test_cubical_complex.py | 4 ++-- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h index 5a87b9b8..f395de65 100644 --- a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h +++ b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h @@ -97,7 +97,7 @@ class Bitmap_cubical_complex : public T { * with filtration on top dimensional cells. **/ Bitmap_cubical_complex(const std::vector& dimensions, - const std::vector& top_dimensional_cells) : + const std::vector& top_dimensional_cells) : T(dimensions, top_dimensional_cells), key_associated_to_simplex(this->total_number_of_cells + 1) { for (size_t i = 0; i != this->total_number_of_cells; ++i) { @@ -111,13 +111,13 @@ class Bitmap_cubical_complex : public T { /** * Constructor that requires vector of elements of type unsigned, which gives number of top dimensional cells - * in the following directions and vector of element of a type T::filtration_type + * in the following directions and vector of element of a type Filtration_value * with filtration on top dimensional cells. The last parameter of the constructor is a vector of boolean of a length * equal to the dimension of cubical complex. * If the position i on this vector is true, then we impose periodic boundary conditions in this direction. **/ Bitmap_cubical_complex(const std::vector& dimensions, - const std::vector& top_dimensional_cells, + const std::vector& top_dimensional_cells, std::vector< bool > directions_in_which_periodic_b_cond_are_to_be_imposed) : T(dimensions, top_dimensional_cells, directions_in_which_periodic_b_cond_are_to_be_imposed), key_associated_to_simplex(this->total_number_of_cells + 1) { @@ -170,20 +170,20 @@ class Bitmap_cubical_complex : public T { if (globalDbg) { std::cerr << "unsigned dimension(const Simplex_handle& sh)\n"; } - if (sh != std::numeric_limits::max()) return this->get_dimension_of_a_cell(sh); + if (sh != null_simplex()) return this->get_dimension_of_a_cell(sh); return -1; } /** * Return the filtration of a cell pointed by the Simplex_handle. **/ - typename T::filtration_type filtration(Simplex_handle sh) { + Filtration_value filtration(Simplex_handle sh) { if (globalDbg) { - std::cerr << "T::filtration_type filtration(const Simplex_handle& sh)\n"; + std::cerr << "Filtration_value filtration(const Simplex_handle& sh)\n"; } // Returns the filtration value of a simplex. - if (sh != std::numeric_limits::max()) return this->data[sh]; - return std::numeric_limits::max(); + if (sh != null_simplex()) return this->data[sh]; + return std::numeric_limits::infinity(); } /** @@ -203,7 +203,7 @@ class Bitmap_cubical_complex : public T { if (globalDbg) { std::cerr << "Simplex_key key(const Simplex_handle& sh)\n"; } - if (sh != std::numeric_limits::max()) { + if (sh != null_simplex()) { return this->key_associated_to_simplex[sh]; } return this->null_key(); @@ -216,7 +216,7 @@ class Bitmap_cubical_complex : public T { if (globalDbg) { std::cerr << "Simplex_handle simplex(Simplex_key key)\n"; } - if (key != std::numeric_limits::max()) { + if (key != null_key()) { return this->simplex_associated_to_key[ key ]; } return null_simplex(); @@ -229,7 +229,7 @@ class Bitmap_cubical_complex : public T { if (globalDbg) { std::cerr << "void assign_key(Simplex_handle& sh, Simplex_key key)\n"; } - if (key == std::numeric_limits::max()) return; + if (key == null_key()) return; this->key_associated_to_simplex[sh] = key; this->simplex_associated_to_key[key] = sh; } @@ -566,8 +566,9 @@ class is_before_in_filtration { bool operator()(const typename Bitmap_cubical_complex::Simplex_handle& sh1, const typename Bitmap_cubical_complex::Simplex_handle& sh2) const { // Not using st_->filtration(sh1) because it uselessly tests for null_simplex. - typename T::filtration_type fil1 = CC_->data[sh1]; - typename T::filtration_type fil2 = CC_->data[sh2]; + typedef typename T::filtration_type Filtration_value; + Filtration_value fil1 = CC_->data[sh1]; + Filtration_value fil2 = CC_->data[sh2]; if (fil1 != fil2) { return fil1 < fil2; } diff --git a/src/cython/test/test_cubical_complex.py b/src/cython/test/test_cubical_complex.py index 2e281ee4..9a365823 100755 --- a/src/cython/test/test_cubical_complex.py +++ b/src/cython/test/test_cubical_complex.py @@ -67,7 +67,7 @@ def test_dimension_constructor(): top_dimensional_cells = [1,2,3,4,5,6,7,8,9]) assert cub.__is_defined() == True assert cub.__is_persistence_defined() == False - assert cub.persistence() == [(1, (0.0, 100.0)), (0, (0.0, 1.8446744073709552e+19))] + assert cub.persistence() == [(1, (0.0, 100.0)), (0, (0.0, float('inf')))] assert cub.__is_persistence_defined() == True assert cub.betti_numbers() == [1, 0] assert cub.persistent_betti_numbers(0, 1000) == [0, 0] @@ -80,7 +80,7 @@ def test_dimension_constructor(): cub = CubicalComplex(perseus_file='CubicalOneSphere.txt') assert cub.__is_defined() == True assert cub.__is_persistence_defined() == False - assert cub.persistence() == [(1, (0.0, 100.0)), (0, (0.0, 1.8446744073709552e+19))] + assert cub.persistence() == [(1, (0.0, 100.0)), (0, (0.0, float('inf')))] assert cub.__is_persistence_defined() == True assert cub.betti_numbers() == [1, 0, 0] assert cub.persistent_betti_numbers(0, 1000) == [1, 0, 0] -- cgit v1.2.3 From b8fdc4c7f6c30df5e7a28a0a23e697640f9d67cc Mon Sep 17 00:00:00 2001 From: glisse Date: Mon, 10 Jul 2017 18:58:12 +0000 Subject: simplex / complex confusion git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@2596 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 77c093029d3e2518260ce59705110df3fbfe11e3 --- src/cython/cython/simplex_tree.pyx | 48 ++++++++++++++--------------- src/cython/include/Simplex_tree_interface.h | 8 ++--- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/cython/cython/simplex_tree.pyx b/src/cython/cython/simplex_tree.pyx index 9d40a8b5..2acdac3c 100644 --- a/src/cython/cython/simplex_tree.pyx +++ b/src/cython/cython/simplex_tree.pyx @@ -183,10 +183,10 @@ cdef class SimplexTree: :returns: true if the simplex was found, false otherwise. :rtype: bool """ - cdef vector[int] complex + cdef vector[int] csimplex for i in simplex: - complex.push_back(i) - return self.thisptr.find_simplex(complex) + csimplex.push_back(i) + return self.thisptr.find_simplex(csimplex) def insert(self, simplex, filtration=0.0): """This function inserts the given N-simplex and its subfaces with the @@ -200,10 +200,10 @@ cdef class SimplexTree: :returns: true if the simplex was found, false otherwise. :rtype: bool """ - cdef vector[int] complex + cdef vector[int] csimplex for i in simplex: - complex.push_back(i) - return self.thisptr.insert_simplex_and_subfaces(complex, + csimplex.push_back(i) + return self.thisptr.insert_simplex_and_subfaces(csimplex, filtration) def get_filtration(self): @@ -232,35 +232,35 @@ cdef class SimplexTree: :returns: The (simplices of the) skeleton of a maximum dimension. :rtype: list of tuples(simplex, filtration) """ - cdef vector[pair[vector[int], double]] skeletons \ + cdef vector[pair[vector[int], double]] skeleton \ = self.thisptr.get_skeleton(dimension) ct = [] - for filtered_complex in skeletons: + for filtered_simplex in skeleton: v = [] - for vertex in filtered_complex.first: + for vertex in filtered_simplex.first: v.append(vertex) - ct.append((v, filtered_complex.second)) + ct.append((v, filtered_simplex.second)) return ct def get_star(self, simplex): - """This function returns the stars of a given N-simplex. + """This function returns the star of a given N-simplex. :param simplex: The N-simplex, represented by a list of vertex. :type simplex: list of int. :returns: The (simplices of the) star of a simplex. :rtype: list of tuples(simplex, filtration) """ - cdef vector[int] complex + cdef vector[int] csimplex for i in simplex: - complex.push_back(i) - cdef vector[pair[vector[int], double]] stars \ - = self.thisptr.get_star(complex) + csimplex.push_back(i) + cdef vector[pair[vector[int], double]] star \ + = self.thisptr.get_star(csimplex) ct = [] - for filtered_complex in stars: + for filtered_simplex in star: v = [] - for vertex in filtered_complex.first: + for vertex in filtered_simplex.first: v.append(vertex) - ct.append((v, filtered_complex.second)) + ct.append((v, filtered_simplex.second)) return ct def get_cofaces(self, simplex, codimension): @@ -275,17 +275,17 @@ cdef class SimplexTree: :returns: The (simplices of the) cofaces of a simplex :rtype: list of tuples(simplex, filtration) """ - cdef vector[int] complex + cdef vector[int] csimplex for i in simplex: - complex.push_back(i) + csimplex.push_back(i) cdef vector[pair[vector[int], double]] cofaces \ - = self.thisptr.get_cofaces(complex, codimension) + = self.thisptr.get_cofaces(csimplex, codimension) ct = [] - for filtered_complex in cofaces: + for filtered_simplex in cofaces: v = [] - for vertex in filtered_complex.first: + for vertex in filtered_simplex.first: v.append(vertex) - ct.append((v, filtered_complex.second)) + ct.append((v, filtered_simplex.second)) return ct def remove_maximal_simplex(self, simplex): diff --git a/src/cython/include/Simplex_tree_interface.h b/src/cython/include/Simplex_tree_interface.h index 45ce1916..09e7e992 100644 --- a/src/cython/include/Simplex_tree_interface.h +++ b/src/cython/include/Simplex_tree_interface.h @@ -70,14 +70,14 @@ class Simplex_tree_interface : public Simplex_tree { } // Do not interface this function, only used in strong witness interface for complex creation - bool insert_simplex(const std::vector& complex, Filtration_value filtration = 0) { - Insertion_result result = Base::insert_simplex(complex, filtration); + bool insert_simplex(const std::vector& simplex, Filtration_value filtration = 0) { + Insertion_result result = Base::insert_simplex(simplex, filtration); return (result.second); } // Do not interface this function, only used in strong witness interface for complex creation - bool insert_simplex_and_subfaces(const std::vector& complex, Filtration_value filtration = 0) { - Insertion_result result = Base::insert_simplex_and_subfaces(complex, filtration); + bool insert_simplex_and_subfaces(const std::vector& simplex, Filtration_value filtration = 0) { + Insertion_result result = Base::insert_simplex_and_subfaces(simplex, filtration); return (result.second); } -- cgit v1.2.3 From 0f8c2b9623fcfd8b346944b637681144b4c58318 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 7 Aug 2017 13:27:32 +0000 Subject: Fix test reader utils git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/persistence_diagram_improvement@2600 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 24bcf652d5374d158c6b4e90dd2233af7e153c49 --- src/cython/test/test_reader_utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cython/test/test_reader_utils.py b/src/cython/test/test_reader_utils.py index 517bf109..79dc9064 100755 --- a/src/cython/test/test_reader_utils.py +++ b/src/cython/test/test_reader_utils.py @@ -61,9 +61,9 @@ def test_read_persistence_intervals_without_dimension(): test_file.write('# Simple persistence diagram without dimension\n2.7 3.7\n9.6 14.\n34.2 34.974\n3. inf') test_file.close() persistence = gudhi.read_persistence_intervals_in_dimension(persistence_file='persistence_intervals_without_dimension.pers') - assert persistence == [[2.7, 3.7], [9.6, 14.], [34.2, 34.974], [3., float('Inf')]] + assert persistence == [(2.7, 3.7), (9.6, 14.), (34.2, 34.974), (3., float('Inf'))] persistence = gudhi.read_persistence_intervals_in_dimension(persistence_file='persistence_intervals_without_dimension.pers', only_this_dim=15) - assert persistence == [[2.7, 3.7], [9.6, 14.], [34.2, 34.974], [3., float('Inf')]] + assert persistence == [(2.7, 3.7), (9.6, 14.), (34.2, 34.974), (3., float('Inf'))] persistence = gudhi.read_persistence_intervals_grouped_by_dimension(persistence_file='persistence_intervals_without_dimension.pers') assert persistence == {-1: [(2.7, 3.7), (9.6, 14.0), (34.2, 34.974), (3.0, float('Inf'))]} @@ -73,9 +73,9 @@ def test_read_persistence_intervals_with_dimension(): test_file.write('# Simple persistence diagram with dimension\n0 2.7 3.7\n1 9.6 14.\n3 34.2 34.974\n1 3. inf') test_file.close() persistence = gudhi.read_persistence_intervals_in_dimension(persistence_file='persistence_intervals_with_dimension.pers') - assert persistence == [[2.7, 3.7], [9.6, 14.], [34.2, 34.974], [3., float('Inf')]] + assert persistence == [(2.7, 3.7), (9.6, 14.), (34.2, 34.974), (3., float('Inf'))] persistence = gudhi.read_persistence_intervals_in_dimension(persistence_file='persistence_intervals_with_dimension.pers', only_this_dim=1) # BUG !!! - assert persistence == [[2.7, 3.7], [9.6, 14.], [34.2, 34.974], [3., float('Inf')]] + assert persistence == [(2.7, 3.7), (9.6, 14.), (34.2, 34.974), (3., float('Inf'))] persistence = gudhi.read_persistence_intervals_grouped_by_dimension(persistence_file='persistence_intervals_with_dimension.pers') assert persistence == {0: [(2.7, 3.7)], 1: [(9.6, 14.0), (3.0, float('Inf'))], 3: [(34.2, 34.974)]} -- cgit v1.2.3 From 1129608c2add6f15538b3e281d75119f0e1bc8b0 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 8 Aug 2017 12:48:40 +0000 Subject: Fix bug in read_persistence_intervals_in_dimension for only_this_dim Add unitary tests for read_persistence Add .clang-format to clang format new files git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@2601 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 28e870973f9ebd686d503246202fa6d6a549e9e3 --- src/.clang-format | 90 ++++++ src/common/include/gudhi/reader_utils.h | 93 +++--- src/common/test/CMakeLists.txt | 7 + src/common/test/README | 2 +- .../test/persistence_intervals_with_dimension.pers | 5 + .../test/persistence_intervals_with_field.pers | 4 + .../persistence_intervals_without_dimension.pers | 7 + .../test/test_persistence_intervals_reader.cpp | 321 +++++++++++++++++++++ 8 files changed, 478 insertions(+), 51 deletions(-) create mode 100644 src/.clang-format create mode 100644 src/common/test/persistence_intervals_with_dimension.pers create mode 100644 src/common/test/persistence_intervals_with_field.pers create mode 100644 src/common/test/persistence_intervals_without_dimension.pers create mode 100644 src/common/test/test_persistence_intervals_reader.cpp diff --git a/src/.clang-format b/src/.clang-format new file mode 100644 index 00000000..dd4590c8 --- /dev/null +++ b/src/.clang-format @@ -0,0 +1,90 @@ +--- +Language: Cpp +# BasedOnStyle: Google +AccessModifierOffset: -1 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlinesLeft: true +AlignOperands: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: true +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: true +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Attach +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +ColumnLimit: 120 +CommentPragmas: '^ IWYU pragma:' +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: true +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] +IncludeCategories: + - Regex: '^<.*\.h>' + Priority: 1 + - Regex: '^<.*' + Priority: 2 + - Regex: '.*' + Priority: 3 +IndentCaseLabels: true +IndentWidth: 2 +IndentWrappedFunctionNames: false +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: false +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Left +ReflowComments: true +SortIncludes: false +SpaceAfterCStyleCast: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Auto +TabWidth: 8 +UseTab: Never +... + diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index f1684d78..bda93f4f 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -1,5 +1,5 @@ -/* This file is part of the Gudhi Library. The Gudhi library - * (Geometric Understanding in Higher Dimensions) is a generic C++ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ * library for computational topology. * * Author(s): Clement Maria, Pawel Dlotko, Clement Jamin @@ -36,6 +36,7 @@ #include #include #include // for pair +#include // for std::make_tuple // Keep this file tag for Doxygen to parse the code, otherwise, functions are not documented. // It is required for global functions and variables. @@ -52,7 +53,7 @@ * X21 X22 ... X2d
* etc
*/ -inline void read_points(std::string file_name, std::vector< std::vector< double > > & points) { +inline void read_points(std::string file_name, std::vector>& points) { std::ifstream in_file(file_name.c_str(), std::ios::in); if (!in_file.is_open()) { std::cerr << "Unable to open file " << file_name << std::endl; @@ -62,14 +63,13 @@ inline void read_points(std::string file_name, std::vector< std::vector< double std::string line; double x; while (getline(in_file, line)) { - std::vector< double > point; + std::vector point; std::istringstream iss(line); while (iss >> x) { point.push_back(x); } // Check for empty lines - if (!point.empty()) - points.push_back(point); + if (!point.empty()) points.push_back(point); } in_file.close(); } @@ -90,7 +90,7 @@ inline void read_points(std::string file_name, std::vector< std::vector< double * Every simplex must appear exactly once. * Simplices of dimension more than 1 are ignored. */ -template< typename Graph_t, typename Filtration_value, typename Vertex_handle > +template Graph_t read_graph(std::string file_name) { std::ifstream in_(file_name.c_str(), std::ios::in); if (!in_.is_open()) { @@ -100,10 +100,10 @@ Graph_t read_graph(std::string file_name) { throw std::invalid_argument(error_str); } - typedef std::pair< Vertex_handle, Vertex_handle > Edge_t; - std::vector< Edge_t > edges; - std::vector< Filtration_value > edges_fil; - std::map< Vertex_handle, Filtration_value > vertices; + typedef std::pair Edge_t; + std::vector edges; + std::vector edges_fil; + std::map vertices; std::string line; int dim; @@ -113,8 +113,7 @@ Graph_t read_graph(std::string file_name) { std::istringstream iss(line); while (iss >> dim) { switch (dim) { - case 0: - { + case 0: { iss >> u; iss >> fil; vertices[u] = fil; @@ -123,8 +122,7 @@ Graph_t read_graph(std::string file_name) { } break; } - case 1: - { + case 1: { iss >> u; iss >> v; iss >> fil; @@ -132,16 +130,13 @@ Graph_t read_graph(std::string file_name) { edges_fil.push_back(fil); break; } - default: - { - break; - } + default: { break; } } } } in_.close(); - if ((size_t) (max_h + 1) != vertices.size()) { + if ((size_t)(max_h + 1) != vertices.size()) { std::cerr << "Error: vertices must be labeled from 0 to n-1 \n"; } @@ -169,8 +164,8 @@ Graph_t read_graph(std::string file_name) { * Every simplex must appear exactly once. * Simplices of dimension more than 1 are ignored. */ -template< typename Vertex_handle, typename Filtration_value > -bool read_simplex(std::istream & in_, std::vector< Vertex_handle > & simplex, Filtration_value & fil) { +template +bool read_simplex(std::istream& in_, std::vector& simplex, Filtration_value& fil) { int dim = 0; if (!(in_ >> dim)) return false; Vertex_handle v; @@ -194,8 +189,8 @@ bool read_simplex(std::istream & in_, std::vector< Vertex_handle > & simplex, Fi * The key of a simplex is its position in the filtration order and also the number of its row in the file. * Dimi ki1 ki2 ... kiDimi Fili means that the ith simplex in the filtration has dimension Dimi, filtration value * fil1 and simplices with key ki1 ... kiDimi in its boundary.*/ -template< typename Simplex_key, typename Filtration_value > -bool read_hasse_simplex(std::istream & in_, std::vector< Simplex_key > & boundary, Filtration_value & fil) { +template +bool read_hasse_simplex(std::istream& in_, std::vector& boundary, Filtration_value& fil) { int dim; if (!(in_ >> dim)) return false; if (dim == 0) { @@ -214,7 +209,7 @@ bool read_hasse_simplex(std::istream & in_, std::vector< Simplex_key > & boundar /** * @brief Read a lower triangular distance matrix from a csv file. We assume that the .csv store the whole * (square) matrix. - * + * * @author Pawel Dlotko * * Square matrix file format:
@@ -231,13 +226,13 @@ bool read_hasse_simplex(std::istream & in_, std::vector< Simplex_key > & boundar * Dj1;Dj2;...;Dj(j-1);
* **/ -template< typename Filtration_value > -std::vector< std::vector< Filtration_value > > read_lower_triangular_matrix_from_csv_file(const std::string& filename, - const char separator = ';') { +template +std::vector> read_lower_triangular_matrix_from_csv_file(const std::string& filename, + const char separator = ';') { #ifdef DEBUG_TRACES std::cout << "Using procedure read_lower_triangular_matrix_from_csv_file \n"; #endif // DEBUG_TRACES - std::vector< std::vector< Filtration_value > > result; + std::vector> result; std::ifstream in; in.open(filename.c_str()); if (!in.is_open()) { @@ -248,7 +243,7 @@ std::vector< std::vector< Filtration_value > > read_lower_triangular_matrix_from // the first line is emtpy, so we ignore it: std::getline(in, line); - std::vector< Filtration_value > values_in_this_line; + std::vector values_in_this_line; result.push_back(values_in_this_line); int number_of_line = 0; @@ -256,11 +251,10 @@ std::vector< std::vector< Filtration_value > > read_lower_triangular_matrix_from // first, read the file line by line to a string: while (std::getline(in, line)) { // if line is empty, break - if (line.size() == 0) - break; + if (line.size() == 0) break; // if the last element of a string is comma: - if (line[ line.size() - 1 ] == separator) { + if (line[line.size() - 1] == separator) { // then shrink the string by one line.pop_back(); } @@ -273,7 +267,7 @@ std::vector< std::vector< Filtration_value > > read_lower_triangular_matrix_from // and now read the doubles. int number_of_entry = 0; - std::vector< Filtration_value > values_in_this_line; + std::vector values_in_this_line; while (iss.good()) { double entry; iss >> entry; @@ -282,7 +276,7 @@ std::vector< std::vector< Filtration_value > > read_lower_triangular_matrix_from } ++number_of_entry; } - if (!values_in_this_line.empty())result.push_back(values_in_this_line); + if (!values_in_this_line.empty()) result.push_back(values_in_this_line); ++number_of_line; } in.close(); @@ -309,7 +303,6 @@ Note: the function does not check that birth <= death. **/ template void read_persistence_intervals_and_dimension(std::string const& filename, OutputIterator out) { - std::ifstream in(filename); if (!in.is_open()) { std::string error_str("read_persistence_intervals_and_dimension - Unable to open file "); @@ -325,13 +318,12 @@ void read_persistence_intervals_and_dimension(std::string const& filename, Outpu double numbers[4]; int n = sscanf(line.c_str(), "%lf %lf %lf %lf", &numbers[0], &numbers[1], &numbers[2], &numbers[3]); if (n >= 2) { - //int field = (n == 4 ? static_cast(numbers[0]) : -1); int dim = (n >= 3 ? static_cast(numbers[n - 3]) : -1); *out++ = std::make_tuple(dim, numbers[n - 2], numbers[n - 1]); } } } -} // read_persistence_diagram_from_file +} /** Reads a file containing persistence intervals. @@ -340,33 +332,34 @@ The return value is an `std::map>>` where `dim` is an `int`, `birth` a `double`, and `death` a `double`. Note: the function does not check that birth <= death. **/ -inline std::map>> read_persistence_intervals_grouped_by_dimension(std::string const& filename) { - +inline std::map>> read_persistence_intervals_grouped_by_dimension( + std::string const& filename) { std::map>> ret; read_persistence_intervals_and_dimension( - filename, - boost::make_function_output_iterator([&ret](std::tuple t) { ret[get<0>(t)].push_back(std::make_pair(get<1>(t), get<2>(t))); })); + filename, boost::make_function_output_iterator([&ret](std::tuple t) { + ret[get<0>(t)].push_back(std::make_pair(get<1>(t), get<2>(t))); + })); return ret; -} // read_persistence_diagram_from_file - +} /** Reads a file containing persistence intervals. Each line might contain 2, 3 or 4 values: [[field] dimension] birth death If `only_this_dim` = -1, dimension is ignored and all lines are returned. -If `only_this_dim` is >= 0, only the lines where dimension = `only_this_dim` +If `only_this_dim` is >= 0, only the lines where dimension = `only_this_dim` (or where dimension is not specified) are returned. The return value is an `std::vector>` where `dim` is an `int`, `birth` a `double`, and `death` a `double`. Note: the function does not check that birth <= death. **/ -inline std::vector> read_persistence_intervals_in_dimension(std::string const& filename, int only_this_dim = -1) { - +inline std::vector> read_persistence_intervals_in_dimension(std::string const& filename, + int only_this_dim = -1) { std::vector> ret; read_persistence_intervals_and_dimension( - filename, - boost::make_function_output_iterator([&ret](std::tuple t) { ret.emplace_back(get<1>(t), get<2>(t)); })); + filename, boost::make_function_output_iterator([only_this_dim, &ret](std::tuple t) { + if (only_this_dim == get<0>(t) || only_this_dim == -1) ret.emplace_back(get<1>(t), get<2>(t)); + })); return ret; -} // read_persistence_diagram_from_file +} #endif // READER_UTILS_H_ diff --git a/src/common/test/CMakeLists.txt b/src/common/test/CMakeLists.txt index 5aa426d7..de3e765a 100644 --- a/src/common/test/CMakeLists.txt +++ b/src/common/test/CMakeLists.txt @@ -9,10 +9,17 @@ target_link_libraries(Common_test_points_off_reader ${Boost_UNIT_TEST_FRAMEWORK_ add_executable ( Common_test_distance_matrix_reader test_distance_matrix_reader.cpp ) target_link_libraries(Common_test_distance_matrix_reader ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +add_executable ( Common_test_persistence_intervals_reader test_persistence_intervals_reader.cpp ) +target_link_libraries(Common_test_persistence_intervals_reader ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + # Do not forget to copy test files in current binary dir file(COPY "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) file(COPY "${CMAKE_SOURCE_DIR}/data/distance_matrix/lower_triangular_distance_matrix.csv" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) file(COPY "${CMAKE_SOURCE_DIR}/data/distance_matrix/full_square_distance_matrix.csv" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) +file(COPY "${CMAKE_SOURCE_DIR}/src/common/test/persistence_intervals_with_dimension.pers" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) +file(COPY "${CMAKE_SOURCE_DIR}/src/common/test/persistence_intervals_with_field.pers" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) +file(COPY "${CMAKE_SOURCE_DIR}/src/common/test/persistence_intervals_without_dimension.pers" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) gudhi_add_coverage_test(Common_test_points_off_reader) gudhi_add_coverage_test(Common_test_distance_matrix_reader) +gudhi_add_coverage_test(Common_test_persistence_intervals_reader) diff --git a/src/common/test/README b/src/common/test/README index f2a7eb5a..a8e6efe9 100644 --- a/src/common/test/README +++ b/src/common/test/README @@ -7,7 +7,7 @@ make To launch with details: *********************** -./dtoffrw_UT --report_level=detailed --log_level=all +./Common_test_points_off_reader --report_level=detailed --log_level=all ==> echo $? returns 0 in case of success (non-zero otherwise) diff --git a/src/common/test/persistence_intervals_with_dimension.pers b/src/common/test/persistence_intervals_with_dimension.pers new file mode 100644 index 00000000..406748c8 --- /dev/null +++ b/src/common/test/persistence_intervals_with_dimension.pers @@ -0,0 +1,5 @@ +# Simple persistence diagram with dimension +0 2.7 3.7 +1 9.6 14. +3 34.2 34.974 +1 3. inf diff --git a/src/common/test/persistence_intervals_with_field.pers b/src/common/test/persistence_intervals_with_field.pers new file mode 100644 index 00000000..41dd9f1e --- /dev/null +++ b/src/common/test/persistence_intervals_with_field.pers @@ -0,0 +1,4 @@ +3 0 2.7 3.7 +3 1 9.6 14. +3 3 34.2 34.974 +3 1 3. inf diff --git a/src/common/test/persistence_intervals_without_dimension.pers b/src/common/test/persistence_intervals_without_dimension.pers new file mode 100644 index 00000000..76fa27f3 --- /dev/null +++ b/src/common/test/persistence_intervals_without_dimension.pers @@ -0,0 +1,7 @@ +# Simple persistence diagram without dimension +2.7 3.7 +9.6 14. +# Another comment +34.2 34.974 +3. inf +# End of file diff --git a/src/common/test/test_persistence_intervals_reader.cpp b/src/common/test/test_persistence_intervals_reader.cpp new file mode 100644 index 00000000..a06fff1e --- /dev/null +++ b/src/common/test/test_persistence_intervals_reader.cpp @@ -0,0 +1,321 @@ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): Vincent Rouvreau + * + * Copyright (C) 2017 INRIA + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include + +#include +#include +#include // for pair +#include +#include // for inf + +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MODULE "persistence_intervals_reader" +#include + +using Persistence_intervals_by_dimension = std::map>>; +using Persistence_intervals = std::vector>; +// Test files with only 2 parameters (persistence birth and death) per line in file +BOOST_AUTO_TEST_CASE( persistence_intervals_without_dimension ) +{ + Persistence_intervals_by_dimension expected_intervals_by_dimension; + expected_intervals_by_dimension[-1].push_back(std::make_pair(2.7, 3.7)); + expected_intervals_by_dimension[-1].push_back(std::make_pair(9.6, 14.)); + expected_intervals_by_dimension[-1].push_back(std::make_pair(34.2, 34.974)); + expected_intervals_by_dimension[-1].push_back(std::make_pair(3., std::numeric_limits::infinity())); + + Persistence_intervals_by_dimension persistence_intervals_by_dimension = + read_persistence_intervals_grouped_by_dimension("persistence_intervals_without_dimension.pers"); + + std::cout << "\nread_persistence_intervals_grouped_by_dimension - expected\n"; + for (auto map_iter : expected_intervals_by_dimension) { + std::cout << "key=" << map_iter.first; + for (auto vec_iter : map_iter.second) + std::cout << " [" << vec_iter.first << " ," << vec_iter.second << "] "; + } + + std::cout << "\nread_persistence_intervals_grouped_by_dimension - read\n"; + for (auto map_iter : persistence_intervals_by_dimension) { + std::cout << "key=" << map_iter.first; + for (auto vec_iter : map_iter.second) + std::cout << " [" << vec_iter.first << " ," << vec_iter.second << "] "; + } + + BOOST_CHECK(persistence_intervals_by_dimension == expected_intervals_by_dimension); + + Persistence_intervals expected_intervals_in_dimension; + expected_intervals_in_dimension.push_back(std::make_pair(2.7, 3.7)); + expected_intervals_in_dimension.push_back(std::make_pair(9.6, 14.)); + expected_intervals_in_dimension.push_back(std::make_pair(34.2, 34.974)); + expected_intervals_in_dimension.push_back(std::make_pair(3., std::numeric_limits::infinity())); + + Persistence_intervals persistence_intervals_in_dimension = + read_persistence_intervals_in_dimension("persistence_intervals_without_dimension.pers"); + + std::cout << "\nread_persistence_intervals_in_dimension - expected\n"; + for (auto vec_iter : expected_intervals_in_dimension) + std::cout << " [" << vec_iter.first << " ," << vec_iter.second << "] "; + + std::cout << "\nread_persistence_intervals_in_dimension - read\n"; + for (auto vec_iter : expected_intervals_in_dimension) + std::cout << " [" << vec_iter.first << " ," << vec_iter.second << "] "; + + BOOST_CHECK(persistence_intervals_in_dimension == expected_intervals_in_dimension); + + expected_intervals_in_dimension.clear(); + persistence_intervals_in_dimension = + read_persistence_intervals_in_dimension("persistence_intervals_without_dimension.pers", 0); + BOOST_CHECK(persistence_intervals_in_dimension == expected_intervals_in_dimension); + + expected_intervals_in_dimension.clear(); + persistence_intervals_in_dimension = + read_persistence_intervals_in_dimension("persistence_intervals_without_dimension.pers", 1); + BOOST_CHECK(persistence_intervals_in_dimension == expected_intervals_in_dimension); + + expected_intervals_in_dimension.clear(); + persistence_intervals_in_dimension = + read_persistence_intervals_in_dimension("persistence_intervals_without_dimension.pers", 2); + BOOST_CHECK(persistence_intervals_in_dimension == expected_intervals_in_dimension); + + expected_intervals_in_dimension.clear(); + persistence_intervals_in_dimension = + read_persistence_intervals_in_dimension("persistence_intervals_without_dimension.pers", 3); + BOOST_CHECK(persistence_intervals_in_dimension == expected_intervals_in_dimension); + +} +// Test files with 3 parameters (dimension birth death) per line in file +BOOST_AUTO_TEST_CASE( persistence_intervals_with_dimension ) +{ + Persistence_intervals_by_dimension expected_intervals_by_dimension; + expected_intervals_by_dimension[0].push_back(std::make_pair(2.7, 3.7)); + expected_intervals_by_dimension[1].push_back(std::make_pair(9.6, 14.)); + expected_intervals_by_dimension[3].push_back(std::make_pair(34.2, 34.974)); + expected_intervals_by_dimension[1].push_back(std::make_pair(3., std::numeric_limits::infinity())); + + Persistence_intervals_by_dimension persistence_intervals_by_dimension = + read_persistence_intervals_grouped_by_dimension("persistence_intervals_with_dimension.pers"); + + std::cout << "\nread_persistence_intervals_grouped_by_dimension - expected\n"; + for (auto map_iter : expected_intervals_by_dimension) { + std::cout << "key=" << map_iter.first; + for (auto vec_iter : map_iter.second) + std::cout << " [" << vec_iter.first << " ," << vec_iter.second << "] "; + } + + std::cout << "\nread_persistence_intervals_grouped_by_dimension - read\n"; + for (auto map_iter : persistence_intervals_by_dimension) { + std::cout << "key=" << map_iter.first; + for (auto vec_iter : map_iter.second) + std::cout << " [" << vec_iter.first << " ," << vec_iter.second << "] "; + } + + BOOST_CHECK(persistence_intervals_by_dimension == expected_intervals_by_dimension); + + Persistence_intervals expected_intervals_in_dimension; + expected_intervals_in_dimension.push_back(std::make_pair(2.7, 3.7)); + expected_intervals_in_dimension.push_back(std::make_pair(9.6, 14.)); + expected_intervals_in_dimension.push_back(std::make_pair(34.2, 34.974)); + expected_intervals_in_dimension.push_back(std::make_pair(3., std::numeric_limits::infinity())); + + Persistence_intervals persistence_intervals_in_dimension = + read_persistence_intervals_in_dimension("persistence_intervals_with_dimension.pers"); + + std::cout << "\nread_persistence_intervals_in_dimension - expected\n"; + for (auto vec_iter : expected_intervals_in_dimension) + std::cout << " [" << vec_iter.first << " ," << vec_iter.second << "] "; + + std::cout << "\nread_persistence_intervals_in_dimension - read\n"; + for (auto vec_iter : persistence_intervals_in_dimension) + std::cout << " [" << vec_iter.first << " ," << vec_iter.second << "] "; + + BOOST_CHECK(persistence_intervals_in_dimension == expected_intervals_in_dimension); + + expected_intervals_in_dimension.clear(); + expected_intervals_in_dimension.push_back(std::make_pair(2.7, 3.7)); + persistence_intervals_in_dimension = + read_persistence_intervals_in_dimension("persistence_intervals_with_dimension.pers", 0); + + std::cout << "\nread_persistence_intervals_in_dimension 0 - expected\n"; + for (auto vec_iter : expected_intervals_in_dimension) + std::cout << " [" << vec_iter.first << " ," << vec_iter.second << "] "; + + std::cout << "\nread_persistence_intervals_in_dimension 0 - read\n"; + for (auto vec_iter : persistence_intervals_in_dimension) + std::cout << " [" << vec_iter.first << " ," << vec_iter.second << "] "; + + BOOST_CHECK(persistence_intervals_in_dimension == expected_intervals_in_dimension); + + expected_intervals_in_dimension.clear(); + expected_intervals_in_dimension.push_back(std::make_pair(9.6, 14.)); + expected_intervals_in_dimension.push_back(std::make_pair(3., std::numeric_limits::infinity())); + persistence_intervals_in_dimension = + read_persistence_intervals_in_dimension("persistence_intervals_with_dimension.pers", 1); + + std::cout << "\nread_persistence_intervals_in_dimension 1 - expected\n"; + for (auto vec_iter : expected_intervals_in_dimension) + std::cout << " [" << vec_iter.first << " ," << vec_iter.second << "] "; + + std::cout << "\nread_persistence_intervals_in_dimension 1 - read\n"; + for (auto vec_iter : persistence_intervals_in_dimension) + std::cout << " [" << vec_iter.first << " ," << vec_iter.second << "] "; + + BOOST_CHECK(persistence_intervals_in_dimension == expected_intervals_in_dimension); + + expected_intervals_in_dimension.clear(); + persistence_intervals_in_dimension = + read_persistence_intervals_in_dimension("persistence_intervals_with_dimension.pers", 2); + + std::cout << "\nread_persistence_intervals_in_dimension 2 - expected\n"; + for (auto vec_iter : expected_intervals_in_dimension) + std::cout << " [" << vec_iter.first << " ," << vec_iter.second << "] "; + + std::cout << "\nread_persistence_intervals_in_dimension 2 - read\n"; + for (auto vec_iter : persistence_intervals_in_dimension) + std::cout << " [" << vec_iter.first << " ," << vec_iter.second << "] "; + + BOOST_CHECK(persistence_intervals_in_dimension == expected_intervals_in_dimension); + + expected_intervals_in_dimension.clear(); + expected_intervals_in_dimension.push_back(std::make_pair(34.2, 34.974)); + persistence_intervals_in_dimension = + read_persistence_intervals_in_dimension("persistence_intervals_with_dimension.pers", 3); + + std::cout << "\nread_persistence_intervals_in_dimension 3 - expected\n"; + for (auto vec_iter : expected_intervals_in_dimension) + std::cout << " [" << vec_iter.first << " ," << vec_iter.second << "] "; + + std::cout << "\nread_persistence_intervals_in_dimension 3 - read\n"; + for (auto vec_iter : persistence_intervals_in_dimension) + std::cout << " [" << vec_iter.first << " ," << vec_iter.second << "] "; + + BOOST_CHECK(persistence_intervals_in_dimension == expected_intervals_in_dimension); + +} + +// Test files with 4 parameters (field dimension birth death) per line in file +BOOST_AUTO_TEST_CASE( persistence_intervals_with_field ) +{ + Persistence_intervals_by_dimension expected_intervals_by_dimension; + expected_intervals_by_dimension[0].push_back(std::make_pair(2.7, 3.7)); + expected_intervals_by_dimension[1].push_back(std::make_pair(9.6, 14.)); + expected_intervals_by_dimension[3].push_back(std::make_pair(34.2, 34.974)); + expected_intervals_by_dimension[1].push_back(std::make_pair(3., std::numeric_limits::infinity())); + + Persistence_intervals_by_dimension persistence_intervals_by_dimension = + read_persistence_intervals_grouped_by_dimension("persistence_intervals_with_field.pers"); + + std::cout << "\nread_persistence_intervals_grouped_by_dimension - expected\n"; + for (auto map_iter : expected_intervals_by_dimension) { + std::cout << "key=" << map_iter.first; + for (auto vec_iter : map_iter.second) + std::cout << " [" << vec_iter.first << " ," << vec_iter.second << "] "; + } + + std::cout << "\nread_persistence_intervals_grouped_by_dimension - read\n"; + for (auto map_iter : persistence_intervals_by_dimension) { + std::cout << "key=" << map_iter.first; + for (auto vec_iter : map_iter.second) + std::cout << " [" << vec_iter.first << " ," << vec_iter.second << "] "; + } + + BOOST_CHECK(persistence_intervals_by_dimension == expected_intervals_by_dimension); + + Persistence_intervals expected_intervals_in_dimension; + expected_intervals_in_dimension.push_back(std::make_pair(2.7, 3.7)); + expected_intervals_in_dimension.push_back(std::make_pair(9.6, 14.)); + expected_intervals_in_dimension.push_back(std::make_pair(34.2, 34.974)); + expected_intervals_in_dimension.push_back(std::make_pair(3., std::numeric_limits::infinity())); + + Persistence_intervals persistence_intervals_in_dimension = + read_persistence_intervals_in_dimension("persistence_intervals_with_field.pers"); + + std::cout << "\nread_persistence_intervals_in_dimension - expected\n"; + for (auto vec_iter : expected_intervals_in_dimension) + std::cout << " [" << vec_iter.first << " ," << vec_iter.second << "] "; + + std::cout << "\nread_persistence_intervals_in_dimension - read\n"; + for (auto vec_iter : persistence_intervals_in_dimension) + std::cout << " [" << vec_iter.first << " ," << vec_iter.second << "] "; + + BOOST_CHECK(persistence_intervals_in_dimension == expected_intervals_in_dimension); + + expected_intervals_in_dimension.clear(); + expected_intervals_in_dimension.push_back(std::make_pair(2.7, 3.7)); + persistence_intervals_in_dimension = + read_persistence_intervals_in_dimension("persistence_intervals_with_field.pers", 0); + + std::cout << "\nread_persistence_intervals_in_dimension 0 - expected\n"; + for (auto vec_iter : expected_intervals_in_dimension) + std::cout << " [" << vec_iter.first << " ," << vec_iter.second << "] "; + + std::cout << "\nread_persistence_intervals_in_dimension 0 - read\n"; + for (auto vec_iter : persistence_intervals_in_dimension) + std::cout << " [" << vec_iter.first << " ," << vec_iter.second << "] "; + + BOOST_CHECK(persistence_intervals_in_dimension == expected_intervals_in_dimension); + + expected_intervals_in_dimension.clear(); + expected_intervals_in_dimension.push_back(std::make_pair(9.6, 14.)); + expected_intervals_in_dimension.push_back(std::make_pair(3., std::numeric_limits::infinity())); + persistence_intervals_in_dimension = + read_persistence_intervals_in_dimension("persistence_intervals_with_field.pers", 1); + + std::cout << "\nread_persistence_intervals_in_dimension 1 - expected\n"; + for (auto vec_iter : expected_intervals_in_dimension) + std::cout << " [" << vec_iter.first << " ," << vec_iter.second << "] "; + + std::cout << "\nread_persistence_intervals_in_dimension 1 - read\n"; + for (auto vec_iter : persistence_intervals_in_dimension) + std::cout << " [" << vec_iter.first << " ," << vec_iter.second << "] "; + + BOOST_CHECK(persistence_intervals_in_dimension == expected_intervals_in_dimension); + + expected_intervals_in_dimension.clear(); + persistence_intervals_in_dimension = + read_persistence_intervals_in_dimension("persistence_intervals_with_field.pers", 2); + + std::cout << "\nread_persistence_intervals_in_dimension 2 - expected\n"; + for (auto vec_iter : expected_intervals_in_dimension) + std::cout << " [" << vec_iter.first << " ," << vec_iter.second << "] "; + + std::cout << "\nread_persistence_intervals_in_dimension 2 - read\n"; + for (auto vec_iter : persistence_intervals_in_dimension) + std::cout << " [" << vec_iter.first << " ," << vec_iter.second << "] "; + + BOOST_CHECK(persistence_intervals_in_dimension == expected_intervals_in_dimension); + + expected_intervals_in_dimension.clear(); + expected_intervals_in_dimension.push_back(std::make_pair(34.2, 34.974)); + persistence_intervals_in_dimension = + read_persistence_intervals_in_dimension("persistence_intervals_with_field.pers", 3); + + std::cout << "\nread_persistence_intervals_in_dimension 3 - expected\n"; + for (auto vec_iter : expected_intervals_in_dimension) + std::cout << " [" << vec_iter.first << " ," << vec_iter.second << "] "; + + std::cout << "\nread_persistence_intervals_in_dimension 3 - read\n"; + for (auto vec_iter : persistence_intervals_in_dimension) + std::cout << " [" << vec_iter.first << " ," << vec_iter.second << "] "; + + BOOST_CHECK(persistence_intervals_in_dimension == expected_intervals_in_dimension); + +} -- cgit v1.2.3 From 295d60787357806ae9aac1bfab98f3fefcd759a0 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 8 Aug 2017 13:15:33 +0000 Subject: Fix persistence files reader unitary tests git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/persistence_diagram_improvement@2603 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 1b3ab678420a63b6607d15f350697eccc42b56f7 --- src/cython/test/test_reader_utils.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/cython/test/test_reader_utils.py b/src/cython/test/test_reader_utils.py index 79dc9064..25591fb3 100755 --- a/src/cython/test/test_reader_utils.py +++ b/src/cython/test/test_reader_utils.py @@ -62,8 +62,10 @@ def test_read_persistence_intervals_without_dimension(): test_file.close() persistence = gudhi.read_persistence_intervals_in_dimension(persistence_file='persistence_intervals_without_dimension.pers') assert persistence == [(2.7, 3.7), (9.6, 14.), (34.2, 34.974), (3., float('Inf'))] - persistence = gudhi.read_persistence_intervals_in_dimension(persistence_file='persistence_intervals_without_dimension.pers', only_this_dim=15) - assert persistence == [(2.7, 3.7), (9.6, 14.), (34.2, 34.974), (3., float('Inf'))] + persistence = gudhi.read_persistence_intervals_in_dimension(persistence_file='persistence_intervals_without_dimension.pers', only_this_dim=0) + assert persistence == [] + persistence = gudhi.read_persistence_intervals_in_dimension(persistence_file='persistence_intervals_without_dimension.pers', only_this_dim=1) + assert persistence == [] persistence = gudhi.read_persistence_intervals_grouped_by_dimension(persistence_file='persistence_intervals_without_dimension.pers') assert persistence == {-1: [(2.7, 3.7), (9.6, 14.0), (34.2, 34.974), (3.0, float('Inf'))]} @@ -74,8 +76,13 @@ def test_read_persistence_intervals_with_dimension(): test_file.close() persistence = gudhi.read_persistence_intervals_in_dimension(persistence_file='persistence_intervals_with_dimension.pers') assert persistence == [(2.7, 3.7), (9.6, 14.), (34.2, 34.974), (3., float('Inf'))] + persistence = gudhi.read_persistence_intervals_in_dimension(persistence_file='persistence_intervals_with_dimension.pers', only_this_dim=0) + assert persistence == [(2.7, 3.7)] persistence = gudhi.read_persistence_intervals_in_dimension(persistence_file='persistence_intervals_with_dimension.pers', only_this_dim=1) - # BUG !!! - assert persistence == [(2.7, 3.7), (9.6, 14.), (34.2, 34.974), (3., float('Inf'))] + assert persistence == [(9.6, 14.), (3., float('Inf'))] + persistence = gudhi.read_persistence_intervals_in_dimension(persistence_file='persistence_intervals_with_dimension.pers', only_this_dim=2) + assert persistence == [] + persistence = gudhi.read_persistence_intervals_in_dimension(persistence_file='persistence_intervals_with_dimension.pers', only_this_dim=3) + assert persistence == [(34.2, 34.974)] persistence = gudhi.read_persistence_intervals_grouped_by_dimension(persistence_file='persistence_intervals_with_dimension.pers') assert persistence == {0: [(2.7, 3.7)], 1: [(9.6, 14.0), (3.0, float('Inf'))], 3: [(34.2, 34.974)]} -- cgit v1.2.3 From fb19e46931baeb83f7547ea0cf734593e2a949a1 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 10 Aug 2017 07:12:08 +0000 Subject: Add Gudhi namespace git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/persistence_diagram_improvement@2605 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 6f004d1f7f8a741081181c1ead026fb952a21e6c --- .../test/test_persistence_intervals_reader.cpp | 37 +++++++++++----------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/common/test/test_persistence_intervals_reader.cpp b/src/common/test/test_persistence_intervals_reader.cpp index a06fff1e..be299376 100644 --- a/src/common/test/test_persistence_intervals_reader.cpp +++ b/src/common/test/test_persistence_intervals_reader.cpp @@ -27,6 +27,7 @@ #include // for pair #include #include // for inf +#include #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MODULE "persistence_intervals_reader" @@ -44,7 +45,7 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_without_dimension ) expected_intervals_by_dimension[-1].push_back(std::make_pair(3., std::numeric_limits::infinity())); Persistence_intervals_by_dimension persistence_intervals_by_dimension = - read_persistence_intervals_grouped_by_dimension("persistence_intervals_without_dimension.pers"); + Gudhi::read_persistence_intervals_grouped_by_dimension("persistence_intervals_without_dimension.pers"); std::cout << "\nread_persistence_intervals_grouped_by_dimension - expected\n"; for (auto map_iter : expected_intervals_by_dimension) { @@ -69,7 +70,7 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_without_dimension ) expected_intervals_in_dimension.push_back(std::make_pair(3., std::numeric_limits::infinity())); Persistence_intervals persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_without_dimension.pers"); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_without_dimension.pers"); std::cout << "\nread_persistence_intervals_in_dimension - expected\n"; for (auto vec_iter : expected_intervals_in_dimension) @@ -83,22 +84,22 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_without_dimension ) expected_intervals_in_dimension.clear(); persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_without_dimension.pers", 0); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_without_dimension.pers", 0); BOOST_CHECK(persistence_intervals_in_dimension == expected_intervals_in_dimension); expected_intervals_in_dimension.clear(); persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_without_dimension.pers", 1); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_without_dimension.pers", 1); BOOST_CHECK(persistence_intervals_in_dimension == expected_intervals_in_dimension); expected_intervals_in_dimension.clear(); persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_without_dimension.pers", 2); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_without_dimension.pers", 2); BOOST_CHECK(persistence_intervals_in_dimension == expected_intervals_in_dimension); expected_intervals_in_dimension.clear(); persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_without_dimension.pers", 3); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_without_dimension.pers", 3); BOOST_CHECK(persistence_intervals_in_dimension == expected_intervals_in_dimension); } @@ -112,7 +113,7 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_with_dimension ) expected_intervals_by_dimension[1].push_back(std::make_pair(3., std::numeric_limits::infinity())); Persistence_intervals_by_dimension persistence_intervals_by_dimension = - read_persistence_intervals_grouped_by_dimension("persistence_intervals_with_dimension.pers"); + Gudhi::read_persistence_intervals_grouped_by_dimension("persistence_intervals_with_dimension.pers"); std::cout << "\nread_persistence_intervals_grouped_by_dimension - expected\n"; for (auto map_iter : expected_intervals_by_dimension) { @@ -137,7 +138,7 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_with_dimension ) expected_intervals_in_dimension.push_back(std::make_pair(3., std::numeric_limits::infinity())); Persistence_intervals persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_with_dimension.pers"); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_with_dimension.pers"); std::cout << "\nread_persistence_intervals_in_dimension - expected\n"; for (auto vec_iter : expected_intervals_in_dimension) @@ -152,7 +153,7 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_with_dimension ) expected_intervals_in_dimension.clear(); expected_intervals_in_dimension.push_back(std::make_pair(2.7, 3.7)); persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_with_dimension.pers", 0); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_with_dimension.pers", 0); std::cout << "\nread_persistence_intervals_in_dimension 0 - expected\n"; for (auto vec_iter : expected_intervals_in_dimension) @@ -168,7 +169,7 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_with_dimension ) expected_intervals_in_dimension.push_back(std::make_pair(9.6, 14.)); expected_intervals_in_dimension.push_back(std::make_pair(3., std::numeric_limits::infinity())); persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_with_dimension.pers", 1); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_with_dimension.pers", 1); std::cout << "\nread_persistence_intervals_in_dimension 1 - expected\n"; for (auto vec_iter : expected_intervals_in_dimension) @@ -182,7 +183,7 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_with_dimension ) expected_intervals_in_dimension.clear(); persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_with_dimension.pers", 2); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_with_dimension.pers", 2); std::cout << "\nread_persistence_intervals_in_dimension 2 - expected\n"; for (auto vec_iter : expected_intervals_in_dimension) @@ -197,7 +198,7 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_with_dimension ) expected_intervals_in_dimension.clear(); expected_intervals_in_dimension.push_back(std::make_pair(34.2, 34.974)); persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_with_dimension.pers", 3); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_with_dimension.pers", 3); std::cout << "\nread_persistence_intervals_in_dimension 3 - expected\n"; for (auto vec_iter : expected_intervals_in_dimension) @@ -221,7 +222,7 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_with_field ) expected_intervals_by_dimension[1].push_back(std::make_pair(3., std::numeric_limits::infinity())); Persistence_intervals_by_dimension persistence_intervals_by_dimension = - read_persistence_intervals_grouped_by_dimension("persistence_intervals_with_field.pers"); + Gudhi::read_persistence_intervals_grouped_by_dimension("persistence_intervals_with_field.pers"); std::cout << "\nread_persistence_intervals_grouped_by_dimension - expected\n"; for (auto map_iter : expected_intervals_by_dimension) { @@ -246,7 +247,7 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_with_field ) expected_intervals_in_dimension.push_back(std::make_pair(3., std::numeric_limits::infinity())); Persistence_intervals persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_with_field.pers"); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_with_field.pers"); std::cout << "\nread_persistence_intervals_in_dimension - expected\n"; for (auto vec_iter : expected_intervals_in_dimension) @@ -261,7 +262,7 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_with_field ) expected_intervals_in_dimension.clear(); expected_intervals_in_dimension.push_back(std::make_pair(2.7, 3.7)); persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_with_field.pers", 0); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_with_field.pers", 0); std::cout << "\nread_persistence_intervals_in_dimension 0 - expected\n"; for (auto vec_iter : expected_intervals_in_dimension) @@ -277,7 +278,7 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_with_field ) expected_intervals_in_dimension.push_back(std::make_pair(9.6, 14.)); expected_intervals_in_dimension.push_back(std::make_pair(3., std::numeric_limits::infinity())); persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_with_field.pers", 1); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_with_field.pers", 1); std::cout << "\nread_persistence_intervals_in_dimension 1 - expected\n"; for (auto vec_iter : expected_intervals_in_dimension) @@ -291,7 +292,7 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_with_field ) expected_intervals_in_dimension.clear(); persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_with_field.pers", 2); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_with_field.pers", 2); std::cout << "\nread_persistence_intervals_in_dimension 2 - expected\n"; for (auto vec_iter : expected_intervals_in_dimension) @@ -306,7 +307,7 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_with_field ) expected_intervals_in_dimension.clear(); expected_intervals_in_dimension.push_back(std::make_pair(34.2, 34.974)); persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_with_field.pers", 3); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_with_field.pers", 3); std::cout << "\nread_persistence_intervals_in_dimension 3 - expected\n"; for (auto vec_iter : expected_intervals_in_dimension) -- cgit v1.2.3 From b633404a13fe7acd2f0518b88219212f93758a49 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 10 Aug 2017 08:41:44 +0000 Subject: utf8 file format git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@2606 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 0541d16e8818dfc9cd6ecd7960c0ec5638cd8277 --- src/common/doc/file_formats.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/doc/file_formats.h b/src/common/doc/file_formats.h index c145b271..e1d1426e 100644 --- a/src/common/doc/file_formats.h +++ b/src/common/doc/file_formats.h @@ -2,7 +2,7 @@ * (Geometric Understanding in Higher Dimensions) is a generic C++ * library for computational topology. * -* Author(s): Clément Jamin +* Author(s): Clément Jamin * * Copyright (C) 2017 INRIA * -- cgit v1.2.3 From c7da4a2e7f8cb26c63ebc5c226c0cfefb5290755 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 10 Aug 2017 08:50:04 +0000 Subject: Fix Python2 compatibility git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/persistence_diagram_improvement@2607 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: b8744511b527f7117d3432c559dcb68b59253e53 --- src/cython/cython/reader_utils.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cython/cython/reader_utils.pyx b/src/cython/cython/reader_utils.pyx index 14976167..3a17c5a0 100644 --- a/src/cython/cython/reader_utils.pyx +++ b/src/cython/cython/reader_utils.pyx @@ -49,7 +49,7 @@ def read_lower_triangular_matrix_from_csv_file(csv_file='', separator=';'): """ if csv_file is not '': if os.path.isfile(csv_file): - return read_matrix_from_csv_file(str.encode(csv_file), str.encode(separator)[0]) + return read_matrix_from_csv_file(str.encode(csv_file), ord(separator[0])) print("file " + csv_file + " not set or not found.") return [] -- cgit v1.2.3 From 6166aad3e082119ead02413659cfb6ea2e661ef7 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 10 Aug 2017 09:22:04 +0000 Subject: Some modifications to file format documentation (utf8 test) git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@2608 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 2590184676603521a3ab175834670bb47a80c93b --- src/common/doc/file_formats.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/common/doc/file_formats.h b/src/common/doc/file_formats.h index e1d1426e..9d0415b1 100644 --- a/src/common/doc/file_formats.h +++ b/src/common/doc/file_formats.h @@ -34,18 +34,19 @@ namespace Gudhi { Such a file, whose extension is usually `.pers`, contains a list of persistence intervals.
Lines starting with `#` are ignored (comments).
Other lines might contain 2, 3 or 4 values (the number of values on each line must be the same for all lines): - \code{.unparsed} + \verbatim [[field] dimension] birth death - \endcode + \endverbatim Here is a simple sample file: - \code{.unparsed} - # Beautiful persistence diagram + \verbatim + # Persistence diagram example 2 2.7 3.7 2 9.6 14. + # Some comments 3 34.2 34.974 4 3. inf - \endcode + \endverbatim Other sample files can be found in the `data/persistence_diagram` folder. */ -- cgit v1.2.3 From 2fc118133e76f05fc55d86cf32883223191fe473 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 17 Aug 2017 16:10:46 +0000 Subject: Add file formats for Python. Binding for persistence write files Launch py.test with the command "python -m pytest" (shall work everywhere) git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/persistence_diagram_improvement@2611 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 9443a7eb5b580ece7708ff57949ad08339c1c5c3 --- .../include/gudhi/Persistent_cohomology.h | 13 +++++++--- .../modules/GUDHI_third_party_libraries.cmake | 2 -- src/common/doc/file_formats.h | 6 ++++- src/cython/CMakeLists.txt | 14 +++++----- src/cython/cython/simplex_tree.pyx | 22 +++++++++++++++- src/cython/doc/_templates/layout.html | 1 + src/cython/doc/fileformats.rst | 30 ++++++++++++++++++++++ src/cython/doc/reader_utils_ref.rst | 11 ++++++++ 8 files changed, 84 insertions(+), 15 deletions(-) create mode 100644 src/cython/doc/fileformats.rst create mode 100644 src/cython/doc/reader_utils_ref.rst diff --git a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h index 672fda48..e0a147b3 100644 --- a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h +++ b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h @@ -591,10 +591,17 @@ class Persistent_cohomology { std::ofstream diagram_out(diagram_name.c_str()); cmp_intervals_by_length cmp(cpx_); std::sort(std::begin(persistent_pairs_), std::end(persistent_pairs_), cmp); + bool has_infinity = std::numeric_limits::has_infinity; for (auto pair : persistent_pairs_) { - diagram_out << cpx_->dimension(get<0>(pair)) << " " - << cpx_->filtration(get<0>(pair)) << " " - << cpx_->filtration(get<1>(pair)) << std::endl; + // Special case on windows, inf is "1.#INF" + if (has_infinity && cpx_->filtration(get<1>(pair)) == std::numeric_limits::infinity()) { + diagram_out << cpx_->dimension(get<0>(pair)) << " " + << cpx_->filtration(get<0>(pair)) << " inf" << std::endl; + } else { + diagram_out << cpx_->dimension(get<0>(pair)) << " " + << cpx_->filtration(get<0>(pair)) << " " + << cpx_->filtration(get<1>(pair)) << std::endl; + } } } diff --git a/src/cmake/modules/GUDHI_third_party_libraries.cmake b/src/cmake/modules/GUDHI_third_party_libraries.cmake index 8f486118..e29ba40c 100644 --- a/src/cmake/modules/GUDHI_third_party_libraries.cmake +++ b/src/cmake/modules/GUDHI_third_party_libraries.cmake @@ -117,8 +117,6 @@ if(NOT GUDHI_CYTHON_PATH) endif(NOT GUDHI_CYTHON_PATH) if(PYTHONINTERP_FOUND AND CYTHON_FOUND) - # Unitary tests are available through py.test - find_program( PYTEST_PATH py.test ) # Default found version 2 if(PYTHON_VERSION_MAJOR EQUAL 2) # Documentation generation is available through sphinx diff --git a/src/common/doc/file_formats.h b/src/common/doc/file_formats.h index 9d0415b1..d715aa4d 100644 --- a/src/common/doc/file_formats.h +++ b/src/common/doc/file_formats.h @@ -26,7 +26,7 @@ namespace Gudhi { /*! \page fileformats File formats - + \tableofcontents \section FileFormatsPers Persistence Diagram @@ -49,6 +49,10 @@ namespace Gudhi { \endverbatim Other sample files can be found in the `data/persistence_diagram` folder. + + Such files can be generated with `Gudhi::persistent_cohomology::Persistent_cohomology::output_diagram()` and read with + `Gudhi::read_persistence_intervals_and_dimension()`, `Gudhi::read_persistence_intervals_grouped_by_dimension()` or + `Gudhi::read_persistence_intervals_in_dimension()`. */ } // namespace Gudhi diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index f427b3c5..a06be008 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -16,7 +16,7 @@ function( add_gudhi_cython_lib THE_LIB ) endfunction( add_gudhi_cython_lib ) if(CYTHON_FOUND) - message("++ ${PYTHON_EXECUTABLE} v.${PYTHON_VERSION_STRING} - Cython is ${CYTHON_EXECUTABLE} - py.test is ${PYTEST_PATH} - Sphinx is ${SPHINX_PATH}") + message("++ ${PYTHON_EXECUTABLE} v.${PYTHON_VERSION_STRING} - Cython is ${CYTHON_EXECUTABLE} - 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', ") @@ -305,13 +305,11 @@ if(CYTHON_FOUND) set_tests_properties(witness_complex_from_nearest_landmark_table_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") # Unitary tests are available through py.test - if(PYTEST_PATH) - add_test( - NAME gudhi_cython_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} "${PYTEST_PATH}") - set_tests_properties(gudhi_cython_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") - endif(PYTEST_PATH) + add_test( + NAME gudhi_cython_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} -m pytest) + set_tests_properties(gudhi_cython_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") # Documentation generation is available through sphinx if(SPHINX_PATH) diff --git a/src/cython/cython/simplex_tree.pyx b/src/cython/cython/simplex_tree.pyx index 2acdac3c..9e3b2345 100644 --- a/src/cython/cython/simplex_tree.pyx +++ b/src/cython/cython/simplex_tree.pyx @@ -61,6 +61,7 @@ cdef extern from "Persistent_cohomology_interface.h" namespace "Gudhi": 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) # SimplexTree python interface cdef class SimplexTree: @@ -385,7 +386,7 @@ cdef class SimplexTree: complex in a specific dimension. :param dimension: The specific dimension. - :type from_value: int. + :type dimension: int. :returns: The persistence intervals. :rtype: list of pair of float @@ -399,3 +400,22 @@ cdef class SimplexTree: print("intervals_in_dim function requires persistence function" " to be launched first.") return intervals_result + + def write_persistence_diagram(self, persistence_file=''): + """This function writes the persistence intervals of the simplicial + complex in a user given file name. + + :param persistence_file: The specific dimension. + :type persistence_file: string. + + :note: intervals_in_dim function requires persistence function to be + launched first. + """ + if self.pcohptr != NULL: + if persistence_file != '': + self.pcohptr.write_output_diagram(str.encode(persistence_file)) + else: + print("persistence_file must be specified") + else: + print("intervals_in_dim function requires persistence function" + " to be launched first.") diff --git a/src/cython/doc/_templates/layout.html b/src/cython/doc/_templates/layout.html index b11c1236..243f33c6 100644 --- a/src/cython/doc/_templates/layout.html +++ b/src/cython/doc/_templates/layout.html @@ -65,6 +65,7 @@ {#- old style sidebars: using blocks -- should be deprecated #} {%- block sidebartoc %}

GUDHI

+

File formats

GUDHI installation

Acknowledging the GUDHI library

Index

diff --git a/src/cython/doc/fileformats.rst b/src/cython/doc/fileformats.rst new file mode 100644 index 00000000..36225b6d --- /dev/null +++ b/src/cython/doc/fileformats.rst @@ -0,0 +1,30 @@ +File formats +############ + +To find the correct function to read the files, please refer to :doc:`reader_utils_ref` + +Persistence Diagram +******************* + +Such a file, whose extension is usually ``.pers``, contains a list of persistence intervals. + +Lines starting with ``#`` are ignored (comments). + +Other lines might contain 2, 3 or 4 values (the number of values on each line must be the same for all lines):: + + [[field] dimension] birth death + +Here is a simple sample file:: + + # Persistence diagram example + 2 2.7 3.7 + 2 9.6 14. + # Some comments + 3 34.2 34.974 + 4 3. inf + +Other sample files can be found in the data/persistence_diagram folder. + +Such files can be generated with :meth:`gudhi.SimplexTree.write_persistence_diagram` and read with +:meth:`gudhi.read_persistence_intervals_grouped_by_dimension`, or +:meth:`gudhi.read_persistence_intervals_in_dimension`. diff --git a/src/cython/doc/reader_utils_ref.rst b/src/cython/doc/reader_utils_ref.rst new file mode 100644 index 00000000..9c1ea6fc --- /dev/null +++ b/src/cython/doc/reader_utils_ref.rst @@ -0,0 +1,11 @@ +============================= +Reader utils reference manual +============================= + +.. autofunction:: gudhi.read_off + +.. autofunction:: gudhi.read_lower_triangular_matrix_from_csv_file + +.. autofunction:: gudhi.read_persistence_intervals_grouped_by_dimension + +.. autofunction:: gudhi.read_persistence_intervals_in_dimension -- cgit v1.2.3 From 5b92662a7ed71546efb4a3697bc0b3e2b315fefc Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 18 Aug 2017 06:19:31 +0000 Subject: Add display function in file format doc git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/persistence_diagram_improvement@2612 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: b51ffdf8f7be07c6745ca2b6501c51a350deffd2 --- src/cython/doc/fileformats.rst | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/cython/doc/fileformats.rst b/src/cython/doc/fileformats.rst index 36225b6d..156ef4e4 100644 --- a/src/cython/doc/fileformats.rst +++ b/src/cython/doc/fileformats.rst @@ -1,16 +1,16 @@ File formats ############ -To find the correct function to read the files, please refer to :doc:`reader_utils_ref` - Persistence Diagram ******************* -Such a file, whose extension is usually ``.pers``, contains a list of persistence intervals. +Such a file, whose extension is usually ``.pers``, contains a list of +persistence intervals. Lines starting with ``#`` are ignored (comments). -Other lines might contain 2, 3 or 4 values (the number of values on each line must be the same for all lines):: +Other lines might contain 2, 3 or 4 values (the number of values on each line +must be the same for all lines):: [[field] dimension] birth death @@ -25,6 +25,9 @@ Here is a simple sample file:: Other sample files can be found in the data/persistence_diagram folder. -Such files can be generated with :meth:`gudhi.SimplexTree.write_persistence_diagram` and read with +Such files can be generated with +:meth:`gudhi.SimplexTree.write_persistence_diagram`, read with :meth:`gudhi.read_persistence_intervals_grouped_by_dimension`, or -:meth:`gudhi.read_persistence_intervals_in_dimension`. +:meth:`gudhi.read_persistence_intervals_in_dimension` and displayed with +:meth:`gudhi.plot_persistence_barcode` or +:meth:`gudhi.plot_persistence_diagram`. -- cgit v1.2.3 From ef36c8b63bc353ac9d4e6982b9bba6797d546e51 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 18 Aug 2017 09:40:19 +0000 Subject: Fix sphinx bug when python3 is not in /usr/bin git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/persistence_diagram_improvement@2613 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 07f67d4cc1f3b558b191115e0979ce3ce0580206 --- src/cmake/modules/GUDHI_third_party_libraries.cmake | 2 +- src/cython/CMakeLists.txt | 1 + src/cython/doc/python3-sphinx-build | 11 ----------- src/cython/doc/python3-sphinx-build.in | 11 +++++++++++ 4 files changed, 13 insertions(+), 12 deletions(-) delete mode 100755 src/cython/doc/python3-sphinx-build create mode 100755 src/cython/doc/python3-sphinx-build.in diff --git a/src/cmake/modules/GUDHI_third_party_libraries.cmake b/src/cmake/modules/GUDHI_third_party_libraries.cmake index e29ba40c..dbf2106a 100644 --- a/src/cmake/modules/GUDHI_third_party_libraries.cmake +++ b/src/cmake/modules/GUDHI_third_party_libraries.cmake @@ -123,7 +123,7 @@ if(PYTHONINTERP_FOUND AND CYTHON_FOUND) find_program( SPHINX_PATH sphinx-build ) elseif(PYTHON_VERSION_MAJOR EQUAL 3) # No sphinx-build in Pyton3, just hack it - set(SPHINX_PATH "${CMAKE_SOURCE_DIR}/${GUDHI_CYTHON_PATH}/doc/python3-sphinx-build") + set(SPHINX_PATH "${CMAKE_CURRENT_BINARY_DIR}/${GUDHI_CYTHON_PATH}/doc/python3-sphinx-build") else() message(FATAL_ERROR "ERROR: Try to compile the Cython interface. Python version ${PYTHON_VERSION_STRING} is not valid.") endif(PYTHON_VERSION_MAJOR EQUAL 2) diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index a06be008..ab5ea9ef 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -194,6 +194,7 @@ if(CYTHON_FOUND) endif(UNIX) # set sphinx-build in make files + configure_file(doc/python3-sphinx-build.in "${CMAKE_CURRENT_BINARY_DIR}/doc/python3-sphinx-build" @ONLY) configure_file(doc/Makefile.in "${CMAKE_CURRENT_BINARY_DIR}/doc/Makefile" @ONLY) configure_file(doc/make.bat.in "${CMAKE_CURRENT_BINARY_DIR}/doc/make.bat" @ONLY) diff --git a/src/cython/doc/python3-sphinx-build b/src/cython/doc/python3-sphinx-build deleted file mode 100755 index 44b94169..00000000 --- a/src/cython/doc/python3-sphinx-build +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/python3 - -""" -Emulate sphinx-build for python3 -""" - -from sys import exit, argv -from sphinx import main - -if __name__ == '__main__': - exit(main(argv)) diff --git a/src/cython/doc/python3-sphinx-build.in b/src/cython/doc/python3-sphinx-build.in new file mode 100755 index 00000000..c97965f5 --- /dev/null +++ b/src/cython/doc/python3-sphinx-build.in @@ -0,0 +1,11 @@ +#!@PYTHON_EXECUTABLE@ + +""" +Emulate sphinx-build for python3 +""" + +from sys import exit, argv +from sphinx import main + +if __name__ == '__main__': + exit(main(argv)) -- cgit v1.2.3 From 962ed22cc9f8a3de681e8543f3558b37525a5681 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 22 Aug 2017 13:19:58 +0000 Subject: Version files modification for new release git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@2616 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 8296050aef9e6658cd98080075f4047487e21b68 --- CMakeGUDHIVersion.txt | 2 +- src/Doxyfile | 2 +- src/cython/doc/conf.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeGUDHIVersion.txt b/CMakeGUDHIVersion.txt index 3d9add66..d5620218 100644 --- a/CMakeGUDHIVersion.txt +++ b/CMakeGUDHIVersion.txt @@ -1,6 +1,6 @@ set (GUDHI_MAJOR_VERSION 2) set (GUDHI_MINOR_VERSION 0) -set (GUDHI_PATCH_VERSION 1.beta) +set (GUDHI_PATCH_VERSION 1-rc1) set(GUDHI_VERSION ${GUDHI_MAJOR_VERSION}.${GUDHI_MINOR_VERSION}.${GUDHI_PATCH_VERSION}) message(STATUS "GUDHI version : ${GUDHI_VERSION}") diff --git a/src/Doxyfile b/src/Doxyfile index 2fecf5fb..6c01aefc 100644 --- a/src/Doxyfile +++ b/src/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "GUDHI" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = "2.0.0" +PROJECT_NUMBER = "2.0.1-rc1" # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/src/cython/doc/conf.py b/src/cython/doc/conf.py index 42bfd59c..072f7a94 100755 --- a/src/cython/doc/conf.py +++ b/src/cython/doc/conf.py @@ -69,7 +69,7 @@ copyright = u'2016, GUDHI Editorial Board' # The short X.Y version. version = '2.0' # The full version, including alpha/beta/rc tags. -release = '2.0.0' +release = '2.0.1-rc1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -- cgit v1.2.3 -- cgit v1.2.3 From ff75dab4aa40bcea9400f861bbdf1bd133f892d1 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 25 Aug 2017 06:31:41 +0000 Subject: bug in Python SimplexTree (needs string) Doc issue in alpha_complex user doc git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@2629 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: ab35f6f64af33414002d6899275170f781e9cfa8 --- src/cython/cython/simplex_tree.pyx | 1 + src/cython/doc/alpha_complex_user.rst | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cython/cython/simplex_tree.pyx b/src/cython/cython/simplex_tree.pyx index 9e3b2345..47aa5311 100644 --- a/src/cython/cython/simplex_tree.pyx +++ b/src/cython/cython/simplex_tree.pyx @@ -2,6 +2,7 @@ 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. The Gudhi library (Geometric Understanding in Higher Dimensions) is a generic C++ diff --git a/src/cython/doc/alpha_complex_user.rst b/src/cython/doc/alpha_complex_user.rst index e8268ef1..ff62390b 100644 --- a/src/cython/doc/alpha_complex_user.rst +++ b/src/cython/doc/alpha_complex_user.rst @@ -142,7 +142,7 @@ Prune above given filtration value ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The simplex tree is pruned from the given maximum alpha squared value (cf. `Simplex_tree::prune_above_filtration()` -int he `C++ version `_). +in the `C++ version `_). In the following example, the value is given by the user as argument of the program. -- cgit v1.2.3 From 4be27acc9ad9d1c1d8f67c0c3839022b910b8b75 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 25 Aug 2017 08:13:28 +0000 Subject: Code review : use boost::adaptors::reverse(intersection) instead of std::reverse Doc review : siblings make no sense to a user git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2630 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 0c9f2b3159294687241ad994e0c7fa7098d31285 --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index b7ec2c1c..7815b95d 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1138,10 +1138,10 @@ class Simplex_tree { } if (intersection.size() != 0) { // Reverse the order to insert - std::reverse(std::begin(intersection), std::end(intersection)); + //std::reverse(std::begin(intersection), std::end(intersection)); Siblings * new_sib = new Siblings(siblings, // oncles simplex->first, // parent - intersection); // boost::container::ordered_unique_range_t + boost::adaptors::reverse(intersection)); // boost::container::ordered_unique_range_t // intersection must be cleared before the function to be called recursively intersection.clear(); @@ -1297,7 +1297,7 @@ class Simplex_tree { public: /** \brief Remove a maximal simplex. * @param[in] sh Simplex handle on the maximal simplex to remove. - * @return true if siblings was deleted, false otherwise. + * @return true if simplex was deleted, false otherwise. * \pre Please check the simplex has no coface before removing it. * \exception std::invalid_argument In debug mode, if sh has children. * \post Be aware that removing is shifting data in a flat_map (initialize_filtration to be done). -- cgit v1.2.3 From 3d2b438a5d6c08b84df3aefe4a0753f4f0c3e49c Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 25 Aug 2017 09:56:37 +0000 Subject: Doc review : expansion_with_blockers doc Code review : blocker_expansion_function reamed block_simplex. Add of concept in doc. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2631 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 5746beb589e80e329cc7233c5cb54d733256f793 --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 34 +++++++++++++++++---------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 7815b95d..88092b3d 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1082,23 +1082,31 @@ class Simplex_tree { } public: - /** \brief Expands the Simplex_tree containing only its one skeleton until dimension max_dim according with a user - * given blocker expansion oracle + /** \brief Expands a simplex tree containing only a graph. Simplices corresponding to cliques in the graph are added + * incrementally, faces before cofaces, unless the simplex has dimension larger than `max_dim` or `block_simplex` + * returns true for this simplex. * - * The expanded simplicial complex until dimension \f$d\f$ attached to a graph \f$G\f$ is the maximal simplicial - * complex of dimension at most \f$d\f$ admitting the graph \f$G\f$ as \f$1\f$-skeleton. - * The filtration value assigned to a simplex is the maximal filtration value of one of its edges. - * The blocker expansion oracle shall answer true on a Simplex_handle if this Simplex_handle has to be removed, - * false otherwise. The blocker expansion oracle can re-assign the filtration value if needed. + * @param[in] max_dim Expansion maximal dimension value. + * @param[in] block_simplex Blocker oracle. Its concept is bool block_simplex(Simplex_handle sh) * - * The Simplex_tree must contain no simplex of dimension bigger than 1 when calling the method. */ + * The function identifies a candidate simplex whose faces are all already in the complex, inserts + * it with a filtration value corresponding to the maximum of the filtration values of the faces, then calls + * `block_simplex` on a `Simplex_handle` for this new simplex. If `block_simplex` returns true, the simplex is + * removed, otherwise it is kept. Note that the evaluation of `block_simplex` is a good time to update the + * filtration value of the simplex if you want a customized value. The algorithm then proceeds with the next + * candidate. + * + * @warning several candidates of the same dimension may be inserted simultaneously before calling `block_simplex`, + * so if you examine the complex in `block_simplex`, you may hit a few simplices that have not been vetted by + * `block_simplex` yet. + */ template< typename Blocker > - void expansion_with_blockers(int max_dim, Blocker blocker_expansion_function) { + void expansion_with_blockers(int max_dim, Blocker block_simplex) { dimension_ = max_dim; // Loop must be from the end to the beginning, as higher dimension simplex are always on the left part of the tree for (auto& simplex : boost::adaptors::reverse(root_.members())) { if (has_children(&simplex)) { - siblings_expansion_with_blockers(simplex.second.children(), max_dim - 1, blocker_expansion_function); + siblings_expansion_with_blockers(simplex.second.children(), max_dim - 1, block_simplex); } } dimension_ = max_dim - dimension_; @@ -1108,7 +1116,7 @@ class Simplex_tree { /** \brief Recursive expansion with blockers of the simplex tree.*/ template< typename Blocker > void siblings_expansion_with_blockers(Siblings* siblings, // must contain elements - int k, Blocker blocker_expansion_function) { + int k, Blocker block_simplex) { if (dimension_ > k) { dimension_ = k; } @@ -1150,7 +1158,7 @@ class Simplex_tree { for (auto new_sib_member = new_sib->members().begin(); new_sib_member != new_sib->members().end(); new_sib_member++) { - bool blocker_result = blocker_expansion_function(new_sib_member); + bool blocker_result = block_simplex(new_sib_member); // new_sib member has been blocked by the blocker function // add it to the list to be removed - do not perform it while looping on it if (blocker_result) @@ -1166,7 +1174,7 @@ class Simplex_tree { } else { // ensure recursive call simplex->second.assign_children(new_sib); - siblings_expansion_with_blockers(new_sib, k - 1, blocker_expansion_function); + siblings_expansion_with_blockers(new_sib, k - 1, block_simplex); } } else { // ensure the children property -- cgit v1.2.3 From fa0388bc3896f881b35fa6c333ceb0116d3e7fdb Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 25 Aug 2017 13:36:42 +0000 Subject: Code review : find_child implementation improvement git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2632 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: c4024b5a56b64dd168a5de1422a857ccebd606fb --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 88092b3d..aa097a38 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1189,11 +1189,16 @@ class Simplex_tree { * Returns null_simplex() if it does not exist */ Simplex_handle find_child(Simplex_handle sh, Vertex_handle vh) { - std::vector child = {vh}; - for (auto vertex : simplex_vertex_range(sh)) { - child.push_back(vertex); - } - return find(child); + if (!has_children(sh)) + return null_simplex(); + + Simplex_handle child = sh->second.children()->find(vh); + // Specific case of boost::flat_map does not find, returns boost::flat_map::end() + // in simplex tree we want a null_simplex() + if (child == sh->second.children()->members().end()) + return null_simplex(); + + return child; } public: -- cgit v1.2.3 From eead3066ec52bdc1eaedf5d6bbd3957ce711b036 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 25 Aug 2017 14:37:50 +0000 Subject: Code review : no need to clear intersection git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2633 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 9a59d20c5786b012229cc5db45181ba165af8f8a --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index aa097a38..b1767f63 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1146,13 +1146,9 @@ class Simplex_tree { } if (intersection.size() != 0) { // Reverse the order to insert - //std::reverse(std::begin(intersection), std::end(intersection)); Siblings * new_sib = new Siblings(siblings, // oncles simplex->first, // parent boost::adaptors::reverse(intersection)); // boost::container::ordered_unique_range_t - // intersection must be cleared before the function to be called recursively - intersection.clear(); - std::vector blocked_new_sib_list; // As all intersections are inserted, we can call the blocker function on all new_sib members for (auto new_sib_member = new_sib->members().begin(); @@ -1179,7 +1175,6 @@ class Simplex_tree { } else { // ensure the children property simplex->second.assign_children(siblings); - intersection.clear(); } } } -- cgit v1.2.3 From 3e9006eeb1c731e63fce5aa71802997284abe461 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 25 Aug 2017 15:33:05 +0000 Subject: Code review : dimension_ is now set on the fly git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2634 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 12974878db3242c442c09268437de4d56e704593 --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index b1767f63..ee173c70 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1102,23 +1102,20 @@ class Simplex_tree { */ template< typename Blocker > void expansion_with_blockers(int max_dim, Blocker block_simplex) { - dimension_ = max_dim; // Loop must be from the end to the beginning, as higher dimension simplex are always on the left part of the tree for (auto& simplex : boost::adaptors::reverse(root_.members())) { if (has_children(&simplex)) { - siblings_expansion_with_blockers(simplex.second.children(), max_dim - 1, block_simplex); + siblings_expansion_with_blockers(simplex.second.children(), max_dim, max_dim - 1, block_simplex); } } - dimension_ = max_dim - dimension_; } private: /** \brief Recursive expansion with blockers of the simplex tree.*/ template< typename Blocker > - void siblings_expansion_with_blockers(Siblings* siblings, // must contain elements - int k, Blocker block_simplex) { - if (dimension_ > k) { - dimension_ = k; + void siblings_expansion_with_blockers(Siblings* siblings, int max_dim, int k, Blocker block_simplex) { + if (dimension_ < max_dim - k) { + dimension_ = max_dim - k; } if (k == 0) return; @@ -1170,7 +1167,7 @@ class Simplex_tree { } else { // ensure recursive call simplex->second.assign_children(new_sib); - siblings_expansion_with_blockers(new_sib, k - 1, block_simplex); + siblings_expansion_with_blockers(new_sib, max_dim, k - 1, block_simplex); } } else { // ensure the children property -- cgit v1.2.3 From 5fb66b3c664b2343776b97327c4bde9eb6c69351 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 30 Aug 2017 09:18:40 +0000 Subject: Code review better use a break to end loop when we know it is not needed to be inserted. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2640 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 2f5fe60856598f0b45c86fd91beda407bcf6938d --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index ee173c70..f7df277c 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1132,7 +1132,10 @@ class Simplex_tree { // If all the boundaries are present, 'next' needs to be inserted for (auto& border : boundary_simplex_range(simplex)) { Simplex_handle border_child = find_child(border, next->first); - to_be_inserted = to_be_inserted && (border_child != null_simplex()); + if (border_child == null_simplex()) { + to_be_inserted=false; + break; + } filt = std::max(filt, filtration(border_child)); } if (to_be_inserted) { -- cgit v1.2.3 From 94bf43f9d92f546837f5120379ffdc08bf274302 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 5 Sep 2017 15:47:24 +0000 Subject: Tests and compilation are now from sources (even if doc and examples are copied) This modification does not fix it for the doc git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cythonization_improvement@2645 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 0fa4850747d3f18cd54e0622ef1831d5d5c5a0df --- src/cython/CMakeLists.txt | 123 ++++++++++++++++++++++++++++++++++------------ src/cython/gudhi.pyx.in | 18 +++---- src/cython/setup.py.in | 2 +- 3 files changed, 102 insertions(+), 41 deletions(-) diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index ab5ea9ef..a12b6029 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -73,13 +73,11 @@ if(CYTHON_FOUND) set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DCGAL_EIGEN3_ENABLED', ") endif (EIGEN3_FOUND) - # Copy recursively include, cython, example, doc and test repositories before packages finding + # Copy recursively example and doc repositories before packages finding # Some tests and doc files are removed in case some packages are not found - file(COPY include DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - file(COPY cython DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(COPY example DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - file(COPY test DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(COPY doc DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + # Developper version for doc images file(GLOB GUDHI_DEV_DOC_IMAGES "${CMAKE_SOURCE_DIR}/src/*/doc/*.png") file(COPY ${GUDHI_DEV_DOC_IMAGES} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/doc/img") @@ -104,9 +102,9 @@ if(CYTHON_FOUND) if (NOT CGAL_VERSION VERSION_LESS 4.8.1) # If CGAL_VERSION >= 4.8.1, include subsampling - set(GUDHI_CYTHON_SUBSAMPLING "include 'cython/subsampling.pyx'") - set(GUDHI_CYTHON_TANGENTIAL_COMPLEX "include 'cython/tangential_complex.pyx'") - set(GUDHI_CYTHON_BOTTLENECK_DISTANCE "include 'cython/bottleneck_distance.pyx'") + set(GUDHI_CYTHON_SUBSAMPLING "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/subsampling.pyx'") + set(GUDHI_CYTHON_TANGENTIAL_COMPLEX "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/tangential_complex.pyx'") + set(GUDHI_CYTHON_BOTTLENECK_DISTANCE "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/bottleneck_distance.pyx'") else (NOT CGAL_VERSION VERSION_LESS 4.8.1) # Remove subsampling unitary tests file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/test/test_subsampling.py) @@ -125,7 +123,7 @@ if(CYTHON_FOUND) endif (NOT CGAL_VERSION VERSION_LESS 4.8.1) if (NOT CGAL_VERSION VERSION_LESS 4.7.0) # If CGAL_VERSION >= 4.7.0, include alpha - set(GUDHI_CYTHON_ALPHA_COMPLEX "include 'cython/alpha_complex.pyx'") + set(GUDHI_CYTHON_ALPHA_COMPLEX "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/alpha_complex.pyx'") else (NOT CGAL_VERSION VERSION_LESS 4.7.0) # Remove alpha complex unitary tests file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/test/test_alpha_complex.py) @@ -136,9 +134,9 @@ if(CYTHON_FOUND) if (NOT CGAL_VERSION VERSION_LESS 4.6.0) # If CGAL_VERSION >= 4.6.0, include euclidean versions of witness complex set(GUDHI_CYTHON_EUCLIDEAN_WITNESS_COMPLEX - "include 'cython/euclidean_witness_complex.pyx'\ninclude 'cython/euclidean_strong_witness_complex.pyx'\n") + "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/euclidean_witness_complex.pyx'\ninclude '${CMAKE_CURRENT_SOURCE_DIR}/cython/euclidean_strong_witness_complex.pyx'\n") else (NOT CGAL_VERSION VERSION_LESS 4.6.0) - # Remove alpha complex unitary tests + # Remove euclidean witness complex unitary tests file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/test/test_euclidean_witness_complex.py) file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/doc/euclidean_witness_complex_ref.rst") file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/doc/euclidean_strong_witness_complex_ref.rst") @@ -177,6 +175,7 @@ if(CYTHON_FOUND) # Loop on INCLUDE_DIRECTORIES PROPERTY get_property(GUDHI_INCLUDE_DIRECTORIES DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES) foreach(GUDHI_INCLUDE_DIRECTORY ${GUDHI_INCLUDE_DIRECTORIES}) + message(" --- ${GUDHI_INCLUDE_DIRECTORY} ---") set(GUDHI_CYTHON_INCLUDE_DIRS "${GUDHI_CYTHON_INCLUDE_DIRS}'${GUDHI_INCLUDE_DIRECTORY}', ") endforeach() set(GUDHI_CYTHON_INCLUDE_DIRS "${GUDHI_CYTHON_INCLUDE_DIRS}'${CMAKE_SOURCE_DIR}/${GUDHI_CYTHON_PATH}/include', ") @@ -220,97 +219,159 @@ if(CYTHON_FOUND) # Test examples if (NOT CGAL_VERSION VERSION_LESS 4.8.1) + # Bottleneck add_test(NAME alpha_rips_persistence_bottleneck_distance_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/example/alpha_rips_persistence_bottleneck_distance.py" + COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/alpha_rips_persistence_bottleneck_distance.py" -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -t 0.15 -d 3) set_tests_properties(alpha_rips_persistence_bottleneck_distance_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") add_test(NAME bottleneck_basic_example_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/example/bottleneck_basic_example.py") + COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/bottleneck_basic_example.py") set_tests_properties(bottleneck_basic_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + add_test( + NAME test_bottleneck_distance_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_bottleneck_distance.py) + set_tests_properties(test_bottleneck_distance_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + + # Tangential add_test(NAME tangential_complex_plain_homology_from_off_file_example_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/example/tangential_complex_plain_homology_from_off_file_example.py" + COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/tangential_complex_plain_homology_from_off_file_example.py" --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off) set_tests_properties(tangential_complex_plain_homology_from_off_file_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + add_test( + NAME test_tangential_complex_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_tangential_complex.py) + set_tests_properties(test_tangential_complex_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + + # Euclidean witness add_test(NAME euclidean_strong_witness_complex_diagram_persistence_from_off_file_example_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py" + COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py" --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -a 1.0 -n 20 -d 2) set_tests_properties(euclidean_strong_witness_complex_diagram_persistence_from_off_file_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") add_test(NAME euclidean_witness_complex_diagram_persistence_from_off_file_example_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py" + COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py" --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -a 1.0 -n 20 -d 2) set_tests_properties(euclidean_witness_complex_diagram_persistence_from_off_file_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + + add_test( + NAME test_euclidean_witness_complex_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_euclidean_witness_complex.py) + set_tests_properties(test_euclidean_witness_complex_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + endif (NOT CGAL_VERSION VERSION_LESS 4.8.1) if (NOT CGAL_VERSION VERSION_LESS 4.7.0) + # Alpha add_test(NAME alpha_complex_from_points_example_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/example/alpha_complex_from_points_example.py") + COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/alpha_complex_from_points_example.py") set_tests_properties(alpha_complex_from_points_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") add_test(NAME alpha_complex_diagram_persistence_from_off_file_example_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/example/alpha_complex_diagram_persistence_from_off_file_example.py" + COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/alpha_complex_diagram_persistence_from_off_file_example.py" --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -a 0.6) set_tests_properties(alpha_complex_diagram_persistence_from_off_file_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") - endif (NOT CGAL_VERSION VERSION_LESS 4.7.0) - if (NOT CGAL_VERSION VERSION_LESS 4.6.0) - endif (NOT CGAL_VERSION VERSION_LESS 4.6.0) + add_test( + NAME test_alpha_complex_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_alpha_complex.py) + set_tests_properties(test_alpha_complex_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + + endif (NOT CGAL_VERSION VERSION_LESS 4.7.0) + # Cubical add_test(NAME periodic_cubical_complex_barcode_persistence_from_perseus_file_example_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/example/periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py" + COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py" --no-barcode -f ${CMAKE_SOURCE_DIR}/data/bitmap/CubicalTwoSphere.txt) set_tests_properties(periodic_cubical_complex_barcode_persistence_from_perseus_file_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") add_test(NAME random_cubical_complex_persistence_example_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/example/random_cubical_complex_persistence_example.py" + COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/random_cubical_complex_persistence_example.py" 10 10 10) set_tests_properties(random_cubical_complex_persistence_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + add_test( + NAME test_cubical_complex_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_cubical_complex.py) + set_tests_properties(test_cubical_complex_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + + # Rips add_test(NAME rips_complex_diagram_persistence_from_distance_matrix_file_example_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/example/rips_complex_diagram_persistence_from_distance_matrix_file_example.py" + COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/rips_complex_diagram_persistence_from_distance_matrix_file_example.py" --no-diagram -f ${CMAKE_SOURCE_DIR}/data/distance_matrix/lower_triangular_distance_matrix.csv -e 12.0 -d 3) set_tests_properties(rips_complex_diagram_persistence_from_distance_matrix_file_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") add_test(NAME rips_complex_diagram_persistence_from_off_file_example_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/example/rips_complex_diagram_persistence_from_off_file_example.py + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example/rips_complex_diagram_persistence_from_off_file_example.py --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -e 0.25 -d 3) set_tests_properties(rips_complex_diagram_persistence_from_off_file_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") add_test(NAME rips_complex_from_points_example_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/example/rips_complex_from_points_example.py) + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example/rips_complex_from_points_example.py) set_tests_properties(rips_complex_from_points_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + add_test( + NAME test_rips_complex_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_rips_complex.py) + set_tests_properties(test_rips_complex_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + + # Simplex tree add_test(NAME simplex_tree_example_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/example/simplex_tree_example.py) + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example/simplex_tree_example.py) set_tests_properties(simplex_tree_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + add_test( + NAME test_simplex_tree_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_simplex_tree.py) + set_tests_properties(test_simplex_tree_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + + # Witness add_test(NAME witness_complex_from_nearest_landmark_table_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/example/witness_complex_from_nearest_landmark_table.py) + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example/witness_complex_from_nearest_landmark_table.py) set_tests_properties(witness_complex_from_nearest_landmark_table_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") - # Unitary tests are available through py.test add_test( - NAME gudhi_cython_py_test + NAME test_witness_complex_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_witness_complex.py) + set_tests_properties(test_witness_complex_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + + # Reader utils + add_test( + NAME test_reader_utils_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_reader_utils.py) + set_tests_properties(test_reader_utils_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + + # Subsampling + add_test( + NAME test_subsampling_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} -m pytest) - set_tests_properties(gudhi_cython_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_subsampling.py) + set_tests_properties(test_subsampling_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") # Documentation generation is available through sphinx if(SPHINX_PATH) diff --git a/src/cython/gudhi.pyx.in b/src/cython/gudhi.pyx.in index ed2d28cc..1141673a 100644 --- a/src/cython/gudhi.pyx.in +++ b/src/cython/gudhi.pyx.in @@ -24,15 +24,15 @@ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 INRIA" __license__ = "GPL v3" -include "cython/off_reader.pyx" -include "cython/simplex_tree.pyx" -include "cython/rips_complex.pyx" -include "cython/cubical_complex.pyx" -include "cython/periodic_cubical_complex.pyx" -include "cython/persistence_graphical_tools.py" -include "cython/reader_utils.pyx" -include "cython/witness_complex.pyx" -include "cython/strong_witness_complex.pyx" +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@ diff --git a/src/cython/setup.py.in b/src/cython/setup.py.in index c1a1717a..fefa36bb 100644 --- a/src/cython/setup.py.in +++ b/src/cython/setup.py.in @@ -29,7 +29,7 @@ __license__ = "GPL v3" gudhi = Extension( "gudhi", - sources = ['gudhi.pyx',], + 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@], -- cgit v1.2.3 From c15a3570fa54e837c27f0e5b862e7bb5c16302d7 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 7 Sep 2017 13:17:19 +0000 Subject: Python documentation is now built from sources to the build directory. Missing bibtex and images to be "as before" git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cythonization_improvement@2649 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 0deda91875e34ce534c88a601cfb167d9c7dfa01 --- src/cython/CMakeLists.txt | 200 ++++++++------------- src/cython/doc/Makefile.in | 44 ----- src/cython/doc/alpha_complex_user.rst | 3 +- src/cython/doc/conf.py | 90 +--------- src/cython/doc/cubical_complex_user.rst | 10 +- src/cython/doc/examples.rst | 19 +- src/cython/doc/generate_examples.py | 43 ----- src/cython/doc/make.bat.in | 67 ------- .../doc/persistence_graphical_tools_user.rst | 13 +- src/cython/doc/pyplots/barcode_persistence.py | 3 +- src/cython/doc/pyplots/diagram_persistence.py | 3 +- src/cython/doc/rips_complex_user.rst | 6 +- src/cython/doc/tangential_complex_user.rst | 3 +- src/cython/gudhi.pyx.in | 3 + 14 files changed, 131 insertions(+), 376 deletions(-) delete mode 100644 src/cython/doc/Makefile.in delete mode 100755 src/cython/doc/generate_examples.py delete mode 100644 src/cython/doc/make.bat.in diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index a12b6029..6c8232ea 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -73,33 +73,6 @@ if(CYTHON_FOUND) set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DCGAL_EIGEN3_ENABLED', ") endif (EIGEN3_FOUND) - # Copy recursively example and doc repositories before packages finding - # Some tests and doc files are removed in case some packages are not found - file(COPY example DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - file(COPY doc DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - - # Developper version for doc images - file(GLOB GUDHI_DEV_DOC_IMAGES "${CMAKE_SOURCE_DIR}/src/*/doc/*.png") - file(COPY ${GUDHI_DEV_DOC_IMAGES} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/doc/img") - file(GLOB GUDHI_DEV_DOC_IMAGES "${CMAKE_SOURCE_DIR}/src/*/doc/*.svg") - file(COPY ${GUDHI_DEV_DOC_IMAGES} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/doc/img") - # User version for doc images - file(GLOB GUDHI_USER_DOC_IMAGES "${CMAKE_SOURCE_DIR}/doc/*/*.png") - file(COPY ${GUDHI_USER_DOC_IMAGES} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/doc/img") - file(GLOB GUDHI_USER_DOC_IMAGES "${CMAKE_SOURCE_DIR}/doc/*/*.svg") - file(COPY ${GUDHI_USER_DOC_IMAGES} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/doc/img") - # Biblio - file(GLOB GUDHI_BIB_FILES "${CMAKE_SOURCE_DIR}/biblio/*.bib") - file(COPY ${GUDHI_BIB_FILES} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/doc/") - # Cubical complex perseus doc example - file(GLOB GUDHI_CUBICAL_PERSEUS_FILES "${CMAKE_SOURCE_DIR}/data/bitmap/*cubicalcomplexdoc.txt") - file(COPY ${GUDHI_CUBICAL_PERSEUS_FILES} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/doc/") - file(COPY "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/doc/") - file(COPY "${CMAKE_SOURCE_DIR}/data/distance_matrix/full_square_distance_matrix.csv" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/doc/") - # Persistence graphical tools examples - file(COPY "${CMAKE_SOURCE_DIR}/data/bitmap/3d_torus.txt" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/doc/") - file(COPY "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/doc/") - if (NOT CGAL_VERSION VERSION_LESS 4.8.1) # If CGAL_VERSION >= 4.8.1, include subsampling set(GUDHI_CYTHON_SUBSAMPLING "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/subsampling.pyx'") @@ -192,11 +165,6 @@ if(CYTHON_FOUND) set( GUDHI_CYTHON_RUNTIME_LIBRARY_DIRS "${GUDHI_CYTHON_LIBRARY_DIRS}") endif(UNIX) - # set sphinx-build in make files - configure_file(doc/python3-sphinx-build.in "${CMAKE_CURRENT_BINARY_DIR}/doc/python3-sphinx-build" @ONLY) - configure_file(doc/Makefile.in "${CMAKE_CURRENT_BINARY_DIR}/doc/Makefile" @ONLY) - configure_file(doc/make.bat.in "${CMAKE_CURRENT_BINARY_DIR}/doc/make.bat" @ONLY) - # 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 @@ -222,52 +190,46 @@ if(CYTHON_FOUND) # Bottleneck add_test(NAME alpha_rips_persistence_bottleneck_distance_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/alpha_rips_persistence_bottleneck_distance.py" + COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" + ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/alpha_rips_persistence_bottleneck_distance.py" -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -t 0.15 -d 3) - set_tests_properties(alpha_rips_persistence_bottleneck_distance_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") add_test(NAME bottleneck_basic_example_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/bottleneck_basic_example.py") - set_tests_properties(bottleneck_basic_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" + ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/bottleneck_basic_example.py") - add_test( - NAME test_bottleneck_distance_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_bottleneck_distance.py) - set_tests_properties(test_bottleneck_distance_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + add_test(NAME test_bottleneck_distance_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_bottleneck_distance.py) # Tangential add_test(NAME tangential_complex_plain_homology_from_off_file_example_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/tangential_complex_plain_homology_from_off_file_example.py" + COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" + ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/tangential_complex_plain_homology_from_off_file_example.py" --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off) - set_tests_properties(tangential_complex_plain_homology_from_off_file_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") - add_test( - NAME test_tangential_complex_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_tangential_complex.py) - set_tests_properties(test_tangential_complex_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + add_test(NAME test_tangential_complex_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_tangential_complex.py) # Euclidean witness add_test(NAME euclidean_strong_witness_complex_diagram_persistence_from_off_file_example_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py" + COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" + ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py" --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -a 1.0 -n 20 -d 2) - set_tests_properties(euclidean_strong_witness_complex_diagram_persistence_from_off_file_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") add_test(NAME euclidean_witness_complex_diagram_persistence_from_off_file_example_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py" + COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" + ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py" --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -a 1.0 -n 20 -d 2) - set_tests_properties(euclidean_witness_complex_diagram_persistence_from_off_file_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") - add_test( - NAME test_euclidean_witness_complex_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_euclidean_witness_complex.py) - set_tests_properties(test_euclidean_witness_complex_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + add_test(NAME test_euclidean_witness_complex_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_euclidean_witness_complex.py) endif (NOT CGAL_VERSION VERSION_LESS 4.8.1) @@ -275,115 +237,105 @@ if(CYTHON_FOUND) # Alpha add_test(NAME alpha_complex_from_points_example_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/alpha_complex_from_points_example.py") - set_tests_properties(alpha_complex_from_points_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" + ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/alpha_complex_from_points_example.py") add_test(NAME alpha_complex_diagram_persistence_from_off_file_example_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/alpha_complex_diagram_persistence_from_off_file_example.py" + COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" + ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/alpha_complex_diagram_persistence_from_off_file_example.py" --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -a 0.6) - set_tests_properties(alpha_complex_diagram_persistence_from_off_file_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") - add_test( - NAME test_alpha_complex_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_alpha_complex.py) - set_tests_properties(test_alpha_complex_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + add_test(NAME test_alpha_complex_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_alpha_complex.py) endif (NOT CGAL_VERSION VERSION_LESS 4.7.0) # Cubical add_test(NAME periodic_cubical_complex_barcode_persistence_from_perseus_file_example_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py" + COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" + ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py" --no-barcode -f ${CMAKE_SOURCE_DIR}/data/bitmap/CubicalTwoSphere.txt) - set_tests_properties(periodic_cubical_complex_barcode_persistence_from_perseus_file_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") add_test(NAME random_cubical_complex_persistence_example_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/random_cubical_complex_persistence_example.py" + COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" + ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/random_cubical_complex_persistence_example.py" 10 10 10) - set_tests_properties(random_cubical_complex_persistence_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") - add_test( - NAME test_cubical_complex_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_cubical_complex.py) - set_tests_properties(test_cubical_complex_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + add_test(NAME test_cubical_complex_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_cubical_complex.py) # Rips add_test(NAME rips_complex_diagram_persistence_from_distance_matrix_file_example_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/rips_complex_diagram_persistence_from_distance_matrix_file_example.py" + COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" + ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/rips_complex_diagram_persistence_from_distance_matrix_file_example.py" --no-diagram -f ${CMAKE_SOURCE_DIR}/data/distance_matrix/lower_triangular_distance_matrix.csv -e 12.0 -d 3) - set_tests_properties(rips_complex_diagram_persistence_from_distance_matrix_file_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") add_test(NAME rips_complex_diagram_persistence_from_off_file_example_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example/rips_complex_diagram_persistence_from_off_file_example.py + COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" + ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example/rips_complex_diagram_persistence_from_off_file_example.py --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -e 0.25 -d 3) - set_tests_properties(rips_complex_diagram_persistence_from_off_file_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") add_test(NAME rips_complex_from_points_example_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example/rips_complex_from_points_example.py) - set_tests_properties(rips_complex_from_points_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" + ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example/rips_complex_from_points_example.py) - add_test( - NAME test_rips_complex_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_rips_complex.py) - set_tests_properties(test_rips_complex_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + add_test(NAME test_rips_complex_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_rips_complex.py) # Simplex tree add_test(NAME simplex_tree_example_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example/simplex_tree_example.py) - set_tests_properties(simplex_tree_example_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" + ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example/simplex_tree_example.py) - add_test( - NAME test_simplex_tree_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_simplex_tree.py) - set_tests_properties(test_simplex_tree_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + add_test(NAME test_simplex_tree_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_simplex_tree.py) # Witness add_test(NAME witness_complex_from_nearest_landmark_table_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example/witness_complex_from_nearest_landmark_table.py) - set_tests_properties(witness_complex_from_nearest_landmark_table_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" + ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example/witness_complex_from_nearest_landmark_table.py) - add_test( - NAME test_witness_complex_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_witness_complex.py) - set_tests_properties(test_witness_complex_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + add_test(NAME test_witness_complex_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_witness_complex.py) # Reader utils - add_test( - NAME test_reader_utils_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_reader_utils.py) - set_tests_properties(test_reader_utils_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") + add_test(NAME test_reader_utils_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_reader_utils.py) # Subsampling - add_test( - NAME test_subsampling_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_subsampling.py) - set_tests_properties(test_subsampling_py_test PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}") - - # Documentation generation is available through sphinx - if(SPHINX_PATH) - if (UNIX) - add_custom_target(sphinx - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc - DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/gudhi.so" - COMMAND make html doctest) - else (UNIX) - add_custom_target(sphinx - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc - COMMAND make.bat html doctest) - endif (UNIX) - endif(SPHINX_PATH) + add_test(NAME test_subsampling_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_subsampling.py) + + # Documentation generation is available through sphinx - requires all modules + if(SPHINX_PATH AND NOT CGAL_VERSION VERSION_LESS 4.8.1) + # set sphinx-build in make files + configure_file(doc/python3-sphinx-build.in "${CMAKE_CURRENT_BINARY_DIR}/doc/python3-sphinx-build" @ONLY) + + add_custom_target(sphinx + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doc + COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" + ${SPHINX_PATH} -b html . "${CMAKE_CURRENT_BINARY_DIR}/sphinx" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/gudhi.so") + + add_test(NAME sphinx_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" + ${SPHINX_PATH} -b doctest ${CMAKE_CURRENT_SOURCE_DIR}/doc "${CMAKE_CURRENT_BINARY_DIR}/sphinx") + + endif(SPHINX_PATH AND NOT CGAL_VERSION VERSION_LESS 4.8.1) endif(CYTHON_FOUND) diff --git a/src/cython/doc/Makefile.in b/src/cython/doc/Makefile.in deleted file mode 100644 index 526350b3..00000000 --- a/src/cython/doc/Makefile.in +++ /dev/null @@ -1,44 +0,0 @@ -# Makefile for Sphinx documentation -# - -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = @SPHINX_PATH@ -PAPER = -BUILDDIR = _build - -# User-friendly check for sphinx-build -ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) -$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) -endif - -# Internal variables. -PAPEROPT_a4 = -D latex_paper_size=a4 -PAPEROPT_letter = -D latex_paper_size=letter -ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . -# the i18n builder cannot share the environment and doctrees with the others -I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . - -.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext - -help: - @echo "Please use \`make ' where is one of" - @echo " html to make standalone HTML files" - @echo " doctest to run all doctests embedded in the documentation (if enabled)" - -clean: - rm -f examples.inc - rm -rf $(BUILDDIR)/* - -# GUDHI specific : Examples.inc is generated with generate_examples.py (and deleted on clean) - -html: - ./generate_examples.py - $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." - -doctest: - $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest - @echo "Testing of doctests in the sources finished, look at the " \ - "results in $(BUILDDIR)/doctest/output.txt." diff --git a/src/cython/doc/alpha_complex_user.rst b/src/cython/doc/alpha_complex_user.rst index e8268ef1..e541e6d3 100644 --- a/src/cython/doc/alpha_complex_user.rst +++ b/src/cython/doc/alpha_complex_user.rst @@ -158,7 +158,8 @@ Then, it is asked to display information about the alpha complex: .. testcode:: import gudhi - alpha_complex = gudhi.AlphaComplex(off_file='alphacomplexdoc.off') + alpha_complex = gudhi.AlphaComplex(off_file=gudhi.__root_source_dir__ + \ + '/data/points/alphacomplexdoc.off') simplex_tree = alpha_complex.create_simplex_tree(max_alpha_square=59.0) result_str = 'Alpha complex is of dimension ' + repr(simplex_tree.dimension()) + ' - ' + \ repr(simplex_tree.num_simplices()) + ' simplices - ' + \ diff --git a/src/cython/doc/conf.py b/src/cython/doc/conf.py index 072f7a94..19a880d4 100755 --- a/src/cython/doc/conf.py +++ b/src/cython/doc/conf.py @@ -21,7 +21,7 @@ import os #sys.path.insert(0, os.path.abspath('.')) # Path to Gudhi.so from source path -sys.path.insert(0, os.path.abspath('..')) +sys.path.insert(0, os.path.abspath('.')) # -- General configuration ------------------------------------------------ @@ -58,18 +58,20 @@ source_suffix = '.rst' # The master toctree document. master_doc = 'index' +import gudhi + # General information about the project. -project = u'GUDHI' -copyright = u'2016, GUDHI Editorial Board' +project = gudhi.__name__ +copyright = gudhi.__copyright__ # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = '2.0' +version = gudhi.__version__ # The full version, including alpha/beta/rc tags. -release = '2.0.1-rc1' +#release = '2.0.1-rc1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -198,81 +200,3 @@ html_static_path = ['_static'] # Output file base name for HTML help builder. htmlhelp_basename = 'GUDHIdoc' - -# -- Options for LaTeX output --------------------------------------------- - -latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', - -# The font size ('10pt', '11pt' or '12pt'). -#'pointsize': '10pt', - -# Additional stuff for the LaTeX preamble. -#'preamble': '', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - ('index', 'GUDHI.tex', u'GUDHI Documentation', - u'Vincent Rouvreau', 'manual'), -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -#latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -#latex_use_parts = False - -# If true, show page references after internal links. -#latex_show_pagerefs = False - -# If true, show URL addresses after external links. -#latex_show_urls = False - -# Documents to append as an appendix to all manuals. -#latex_appendices = [] - -# If false, no module index is generated. -#latex_domain_indices = True - - -# -- Options for manual page output --------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ('index', 'gudhi', u'GUDHI Documentation', - [u'Vincent Rouvreau'], 1) -] - -# If true, show URL addresses after external links. -#man_show_urls = False - - -# -- Options for Texinfo output ------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - ('index', 'GUDHI', u'GUDHI Documentation', - u'Vincent Rouvreau', 'GUDHI', 'One line description of project.', - 'Miscellaneous'), -] - -# Documents to append as an appendix to all manuals. -#texinfo_appendices = [] - -# If false, no module index is generated. -#texinfo_domain_indices = True - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' - -# If true, do not generate a @detailmenu in the "Top" node's menu. -#texinfo_no_detailmenu = False diff --git a/src/cython/doc/cubical_complex_user.rst b/src/cython/doc/cubical_complex_user.rst index 344b9554..8c9a3ed6 100644 --- a/src/cython/doc/cubical_complex_user.rst +++ b/src/cython/doc/cubical_complex_user.rst @@ -97,12 +97,13 @@ The input file for the following complex is: .. literalinclude:: cubicalcomplexdoc.txt -.. centered:: cubicalcomplexdoc.txt +.. centered:: data/bitmap/cubicalcomplexdoc.txt .. testcode:: import gudhi - cubical_complex = gudhi.CubicalComplex(perseus_file='cubicalcomplexdoc.txt') + cubical_complex = gudhi.CubicalComplex(perseus_file=gudhi.__root_source_dir__ + \ + '/data/bitmap/cubicalcomplexdoc.txt') result_str = 'Cubical complex is of dimension ' + repr(cubical_complex.dimension()) + ' - ' + \ repr(cubical_complex.num_simplices()) + ' simplices.' print(result_str) @@ -129,14 +130,15 @@ For instance: .. literalinclude:: periodiccubicalcomplexdoc.txt -.. centered:: periodiccubicalcomplexdoc.txt +.. centered:: data/bitmap/periodiccubicalcomplexdoc.txt Indicate that we have imposed periodic boundary conditions in the direction x, but not in the direction y. .. testcode:: import gudhi - periodic_cc = gudhi.PeriodicCubicalComplex(perseus_file='periodiccubicalcomplexdoc.txt') + periodic_cc = gudhi.PeriodicCubicalComplex(perseus_file=gudhi.__root_source_dir__ + \ + '/data/bitmap/periodiccubicalcomplexdoc.txt') result_str = 'Periodic cubical complex is of dimension ' + repr(periodic_cc.dimension()) + ' - ' + \ repr(periodic_cc.num_simplices()) + ' simplices.' print(result_str) diff --git a/src/cython/doc/examples.rst b/src/cython/doc/examples.rst index a89e0596..1e596e18 100644 --- a/src/cython/doc/examples.rst +++ b/src/cython/doc/examples.rst @@ -1,4 +1,21 @@ Examples ######## -.. include:: examples.inc +.. only:: builder_html + + * :download:`rips_complex_from_points_example.py <../example/rips_complex_from_points_example.py>` + * :download:`alpha_complex_from_points_example.py <../example/alpha_complex_from_points_example.py>` + * :download:`simplex_tree_example.py <../example/simplex_tree_example.py>` + * :download:`alpha_rips_persistence_bottleneck_distance.py <../example/alpha_rips_persistence_bottleneck_distance.py>` + * :download:`tangential_complex_plain_homology_from_off_file_example.py <../example/tangential_complex_plain_homology_from_off_file_example.py>` + * :download:`alpha_complex_diagram_persistence_from_off_file_example.py <../example/alpha_complex_diagram_persistence_from_off_file_example.py>` + * :download:`periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py <../example/periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py>` + * :download:`bottleneck_basic_example.py <../example/bottleneck_basic_example.py>` + * :download:`gudhi_graphical_tools_example.py <../example/gudhi_graphical_tools_example.py>` + * :download:`witness_complex_from_nearest_landmark_table.py <../example/witness_complex_from_nearest_landmark_table.py>` + * :download:`euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py <../example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py>` + * :download:`euclidean_witness_complex_diagram_persistence_from_off_file_example.py <../example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py>` + * :download:`rips_complex_diagram_persistence_from_off_file_example.py <../example/rips_complex_diagram_persistence_from_off_file_example.py>` + * :download:`rips_complex_diagram_persistence_from_distance_matrix_file_example.py <../example/rips_complex_diagram_persistence_from_distance_matrix_file_example.py>` + * :download:`rips_persistence_diagram.py <../example/rips_persistence_diagram.py>` + * :download:`random_cubical_complex_persistence_example.py <../example/random_cubical_complex_persistence_example.py>` diff --git a/src/cython/doc/generate_examples.py b/src/cython/doc/generate_examples.py deleted file mode 100755 index d64d506c..00000000 --- a/src/cython/doc/generate_examples.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env python - -from os import listdir - -"""This file is part of the Gudhi Library. The Gudhi library - (Geometric Understanding in Higher Dimensions) is a generic C++ - library for computational topology. - - Author(s): Vincent Rouvreau - - Copyright (C) 2017 INRIA - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -""" - -__author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2017 INRIA" -__license__ = "GPL v3" - -""" -generate_examples.py generates examples.inc to be included in examples.rst. -Refer to Makefile and make.bat to see if it is correctly launched. -""" - -output_file = open('examples.inc','w') - -output_file.write('.. only:: builder_html\n\n') - -for file in listdir('../example/'): - output_file.write(" * :download:`" + file + " <../example/" + file + ">`\n") - -output_file.close() diff --git a/src/cython/doc/make.bat.in b/src/cython/doc/make.bat.in deleted file mode 100644 index ff1a6d56..00000000 --- a/src/cython/doc/make.bat.in +++ /dev/null @@ -1,67 +0,0 @@ -@ECHO OFF - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=@SPHINX_PATH@ -) -set BUILDDIR=_build -set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . -set I18NSPHINXOPTS=%SPHINXOPTS% . -if NOT "%PAPER%" == "" ( - set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% - set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% -) - -if "%1" == "" goto help - -if "%1" == "help" ( - :help - echo.Please use `make ^` where ^ is one of - echo. html to make standalone HTML files - echo. doctest to run all doctests embedded in the documentation if enabled - goto end -) - -if "%1" == "clean" ( - del examples.inc - for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i - del /q /s %BUILDDIR%\* - goto end -) - - -%SPHINXBUILD% 2> nul -if errorlevel 9009 ( - echo. - echo.The 'sphinx-build' command was not found. Make sure you have Sphinx - echo.installed, then set the SPHINXBUILD environment variable to point - echo.to the full path of the 'sphinx-build' executable. Alternatively you - echo.may add the Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.http://sphinx-doc.org/ - exit /b 1 -) - -:: GUDHI specific : Examples.inc is generated with generate_examples.py (and deleted on clean) - -if "%1" == "html" ( - generate_examples.py - %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The HTML pages are in %BUILDDIR%/html. - goto end -) - -if "%1" == "doctest" ( - %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest - if errorlevel 1 exit /b 1 - echo. - echo.Testing of doctests in the sources finished, look at the ^ -results in %BUILDDIR%/doctest/output.txt. - goto end -) - -:end diff --git a/src/cython/doc/persistence_graphical_tools_user.rst b/src/cython/doc/persistence_graphical_tools_user.rst index 13198162..9033331f 100644 --- a/src/cython/doc/persistence_graphical_tools_user.rst +++ b/src/cython/doc/persistence_graphical_tools_user.rst @@ -32,7 +32,8 @@ This function can display the persistence result as a barcode: import gudhi - periodic_cc = gudhi.PeriodicCubicalComplex(perseus_file='3d_torus.txt') + periodic_cc = gudhi.PeriodicCubicalComplex(perseus_file=gudhi.__root_source_dir__ + \ + '/data/bitmap/3d_torus.txt') diag = periodic_cc.persistence() plt = gudhi.plot_persistence_barcode(diag) plt.show() @@ -41,8 +42,10 @@ This function can display the persistence result as a barcode: import gudhi - periodic_cc = gudhi.PeriodicCubicalComplex(perseus_file='3d_torus.txt') + periodic_cc = gudhi.PeriodicCubicalComplex(perseus_file=gudhi.__root_source_dir__ + \ + '/data/bitmap/3d_torus.txt') diag = periodic_cc.persistence() + print("diag = ", diag) plt = gudhi.plot_persistence_barcode(diag) plt.show() @@ -55,7 +58,8 @@ This function can display the persistence result as a diagram: import gudhi - rips_complex = gudhi.RipsComplex(off_file='tore3D_1307.off', max_edge_length=0.2) + rips_complex = gudhi.RipsComplex(off_file=gudhi.__root_source_dir__ + \ + '/data/points/tore3D_1307.off', max_edge_length=0.2) simplex_tree = rips_complex.create_simplex_tree(max_dimension=3) diag = simplex_tree.persistence() plt = gudhi.plot_persistence_diagram(diag, band_boot=0.13) @@ -65,7 +69,8 @@ This function can display the persistence result as a diagram: import gudhi - rips_complex = gudhi.RipsComplex(off_file='tore3D_1307.off', max_edge_length=0.2) + rips_complex = gudhi.RipsComplex(off_file=gudhi.__root_source_dir__ + \ + '/data/points/tore3D_1307.off', max_edge_length=0.2) simplex_tree = rips_complex.create_simplex_tree(max_dimension=3) diag = simplex_tree.persistence() plt = gudhi.plot_persistence_diagram(diag, band_boot=0.13) diff --git a/src/cython/doc/pyplots/barcode_persistence.py b/src/cython/doc/pyplots/barcode_persistence.py index 9cd3149d..de33d506 100755 --- a/src/cython/doc/pyplots/barcode_persistence.py +++ b/src/cython/doc/pyplots/barcode_persistence.py @@ -1,6 +1,7 @@ import gudhi -periodic_cc = gudhi.PeriodicCubicalComplex(perseus_file='3d_torus.txt') +periodic_cc = gudhi.PeriodicCubicalComplex(perseus_file=gudhi.__root_source_dir__ + \ + '/data/bitmap/3d_torus.txt') diag = periodic_cc.persistence() plt = gudhi.plot_persistence_barcode(diag) plt.show() diff --git a/src/cython/doc/pyplots/diagram_persistence.py b/src/cython/doc/pyplots/diagram_persistence.py index 30661965..c2fbf801 100755 --- a/src/cython/doc/pyplots/diagram_persistence.py +++ b/src/cython/doc/pyplots/diagram_persistence.py @@ -1,6 +1,7 @@ import gudhi -rips_complex = gudhi.RipsComplex(off_file='tore3D_1307.off', max_edge_length=0.2) +rips_complex = gudhi.RipsComplex(off_file=gudhi.__root_source_dir__ + \ + '/data/points/tore3D_1307.off', max_edge_length=0.2) simplex_tree = rips_complex.create_simplex_tree(max_dimension=3) diag = simplex_tree.persistence() plt = gudhi.plot_persistence_diagram(diag, band_boot=0.13) diff --git a/src/cython/doc/rips_complex_user.rst b/src/cython/doc/rips_complex_user.rst index f9760976..6b48422b 100644 --- a/src/cython/doc/rips_complex_user.rst +++ b/src/cython/doc/rips_complex_user.rst @@ -101,7 +101,8 @@ Finally, it is asked to display information about the Rips complex. .. testcode:: import gudhi - rips_complex = gudhi.RipsComplex(off_file='alphacomplexdoc.off', max_edge_length=12.0) + rips_complex = gudhi.RipsComplex(off_file=gudhi.__root_source_dir__ + \ + '/data/points/alphacomplexdoc.off', max_edge_length=12.0) simplex_tree = rips_complex.create_simplex_tree(max_dimension=1) result_str = 'Rips complex is of dimension ' + repr(simplex_tree.dimension()) + ' - ' + \ repr(simplex_tree.num_simplices()) + ' simplices - ' + \ @@ -205,7 +206,8 @@ Finally, it is asked to display information about the Rips complex. .. testcode:: import gudhi - rips_complex = gudhi.RipsComplex(csv_file='full_square_distance_matrix.csv', max_edge_length=12.0) + rips_complex = gudhi.RipsComplex(csv_file=gudhi.__root_source_dir__ + \ + '/data/distance_matrix/full_square_distance_matrix.csv', max_edge_length=12.0) simplex_tree = rips_complex.create_simplex_tree(max_dimension=1) result_str = 'Rips complex is of dimension ' + repr(simplex_tree.dimension()) + ' - ' + \ repr(simplex_tree.num_simplices()) + ' simplices - ' + \ diff --git a/src/cython/doc/tangential_complex_user.rst b/src/cython/doc/tangential_complex_user.rst index 03f9fea6..d670cfdb 100644 --- a/src/cython/doc/tangential_complex_user.rst +++ b/src/cython/doc/tangential_complex_user.rst @@ -122,7 +122,8 @@ This example builds the Tangential complex of point set read in an OFF file. .. testcode:: import gudhi - tc = gudhi.TangentialComplex(off_file='alphacomplexdoc.off') + tc = gudhi.TangentialComplex(off_file=gudhi.__root_source_dir__ + \ + '/data/points/alphacomplexdoc.off') result_str = 'Tangential contains ' + repr(tc.num_simplices()) + \ ' simplices - ' + repr(tc.num_vertices()) + ' vertices.' print(result_str) diff --git a/src/cython/gudhi.pyx.in b/src/cython/gudhi.pyx.in index 1141673a..a8dd9f80 100644 --- a/src/cython/gudhi.pyx.in +++ b/src/cython/gudhi.pyx.in @@ -23,6 +23,9 @@ __author__ = "Vincent Rouvreau" __copyright__ = "Copyright (C) 2016 INRIA" __license__ = "GPL v3" +__version__ = "@GUDHI_VERSION@" +# This variable is used by doctest to find files +__root_source_dir__ = "@CMAKE_SOURCE_DIR@" include '@CMAKE_CURRENT_SOURCE_DIR@/cython/off_reader.pyx' include '@CMAKE_CURRENT_SOURCE_DIR@/cython/simplex_tree.pyx' -- cgit v1.2.3 From ef8a5bca22be47df00f61d660e84948f1f45f9ba Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 7 Sep 2017 16:07:41 +0000 Subject: Fix doc for user_version git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cythonization_improvement@2650 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 18aebd67968fd48ccfcfcfbff75c614496f4424e --- src/cython/doc/alpha_complex_sum.rst | 2 +- src/cython/doc/alpha_complex_user.rst | 6 +++--- src/cython/doc/bottleneck_distance_sum.rst | 2 +- src/cython/doc/cubical_complex_sum.rst | 22 +++++++++++----------- src/cython/doc/cubical_complex_user.rst | 2 +- src/cython/doc/index.rst | 8 +++++--- src/cython/doc/persistent_cohomology_sum.rst | 2 +- src/cython/doc/persistent_cohomology_user.rst | 2 +- src/cython/doc/rips_complex_sum.rst | 2 +- src/cython/doc/rips_complex_user.rst | 2 +- src/cython/doc/simplex_tree_sum.rst | 2 +- src/cython/doc/tangential_complex_sum.rst | 4 ++-- src/cython/doc/tangential_complex_user.rst | 14 +++++++------- src/cython/doc/witness_complex_sum.rst | 26 ++++++++++++++------------ src/cython/doc/witness_complex_user.rst | 4 ++-- 15 files changed, 52 insertions(+), 48 deletions(-) diff --git a/src/cython/doc/alpha_complex_sum.rst b/src/cython/doc/alpha_complex_sum.rst index a5f6420a..1680a712 100644 --- a/src/cython/doc/alpha_complex_sum.rst +++ b/src/cython/doc/alpha_complex_sum.rst @@ -5,7 +5,7 @@ +----------------------------------------------------------------+------------------------------------------------------------------------+ | .. figure:: | Alpha_complex is a simplicial complex constructed from the finite | -| img/alpha_complex_representation.png | cells of a Delaunay Triangulation. | +| ../../doc/Alpha_complex/alpha_complex_representation.png | cells of a Delaunay Triangulation. | | :alt: Alpha complex representation | | | :figclass: align-center | The filtration value of each simplex is computed as the square of the | | | circumradius of the simplex if the circumsphere is empty (the simplex | diff --git a/src/cython/doc/alpha_complex_user.rst b/src/cython/doc/alpha_complex_user.rst index e541e6d3..c3a13bef 100644 --- a/src/cython/doc/alpha_complex_user.rst +++ b/src/cython/doc/alpha_complex_user.rst @@ -75,7 +75,7 @@ In order to build the alpha complex, first, a Simplex tree is built from the cel (The filtration value is set to NaN, which stands for unknown value): .. figure:: - img/alpha_complex_doc.png + ../../doc/Alpha_complex/alpha_complex_doc.png :figclass: align-center :alt: Simplex tree structure construction example @@ -112,7 +112,7 @@ computes the filtration value of the triangle, and then propagates the filtratio here: .. figure:: - img/alpha_complex_doc_420.png + ../../doc/Alpha_complex/alpha_complex_doc_420.png :figclass: align-center :alt: Filtration value propagation example @@ -201,6 +201,6 @@ the program output is: CGAL citations ============== -.. bibliography:: how_to_cite_cgal.bib +.. bibliography:: ../../biblio/how_to_cite_cgal.bib :filter: docnames :style: unsrt diff --git a/src/cython/doc/bottleneck_distance_sum.rst b/src/cython/doc/bottleneck_distance_sum.rst index 5c475d0d..030fad9e 100644 --- a/src/cython/doc/bottleneck_distance_sum.rst +++ b/src/cython/doc/bottleneck_distance_sum.rst @@ -5,7 +5,7 @@ +-----------------------------------------------------------------+----------------------------------------------------------------------+ | .. figure:: | Bottleneck distance measures the similarity between two persistence | -| img/perturb_pd.png | diagrams. It's the shortest distance b for which there exists a | +| ../../doc/Bottleneck_distance/perturb_pd.png | diagrams. It's the shortest distance b for which there exists a | | :figclass: align-center | perfect matching between the points of the two diagrams (+ all the | | | diagonal points) such that any couple of matched points are at | | Bottleneck distance is the length of | distance at most b. | diff --git a/src/cython/doc/cubical_complex_sum.rst b/src/cython/doc/cubical_complex_sum.rst index 3ddf6375..280ad0e0 100644 --- a/src/cython/doc/cubical_complex_sum.rst +++ b/src/cython/doc/cubical_complex_sum.rst @@ -2,14 +2,14 @@ :Author: Pawel Dlotko :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 ================================================================= =================================== =================================== -+-----------------------------------------------------------------+----------------------------------------------------------------------+ -| .. figure:: | The cubical complex is an example of a structured complex useful in | -| img/Cubical_complex_representation.png | computational mathematics (specially rigorous numerics) and image | -| :alt: Cubical complex representation | analysis. | -| :figclass: align-center | | -| | | -| Cubical complex representation | | -+-----------------------------------------------------------------+----------------------------------------------------------------------+ -| :doc:`cubical_complex_user` | * :doc:`cubical_complex_ref` | -| | * :doc:`periodic_cubical_complex_ref` | -+-----------------------------------------------------------------+----------------------------------------------------------------------+ ++--------------------------------------------------------------------------+----------------------------------------------------------------------+ +| .. figure:: | The cubical complex is an example of a structured complex useful in | +| ../../doc/Bitmap_cubical_complex/Cubical_complex_representation.png | computational mathematics (specially rigorous numerics) and image | +| :alt: Cubical complex representation | analysis. | +| :figclass: align-center | | +| | | +| Cubical complex representation | | ++--------------------------------------------------------------------------+----------------------------------------------------------------------+ +| :doc:`cubical_complex_user` | * :doc:`cubical_complex_ref` | +| | * :doc:`periodic_cubical_complex_ref` | ++--------------------------------------------------------------------------+----------------------------------------------------------------------+ diff --git a/src/cython/doc/cubical_complex_user.rst b/src/cython/doc/cubical_complex_user.rst index 8c9a3ed6..36fa3ba9 100644 --- a/src/cython/doc/cubical_complex_user.rst +++ b/src/cython/doc/cubical_complex_user.rst @@ -157,6 +157,6 @@ End user programs are available in cython/example/ folder. Bibliography ============ -.. bibliography:: bibliography.bib +.. bibliography:: ../../bibliography.bib :filter: docnames :style: unsrt diff --git a/src/cython/doc/index.rst b/src/cython/doc/index.rst index f6d10567..3945d72a 100644 --- a/src/cython/doc/index.rst +++ b/src/cython/doc/index.rst @@ -1,8 +1,10 @@ GUDHI Python module documentation ################################# -.. image:: img/Gudhi_banner.png - :align: center +.. figure:: + ../../doc/common/Gudhi_banner.png + :alt: Gudhi banner + :figclass: align-center Introduction ************ @@ -81,6 +83,6 @@ Persistence graphical tools Bibliography ************ -.. bibliography:: bibliography.bib +.. bibliography:: ../../biblio/bibliography.bib :filter: docnames :style: unsrt diff --git a/src/cython/doc/persistent_cohomology_sum.rst b/src/cython/doc/persistent_cohomology_sum.rst index d1f79cb4..a26df1dc 100644 --- a/src/cython/doc/persistent_cohomology_sum.rst +++ b/src/cython/doc/persistent_cohomology_sum.rst @@ -4,7 +4,7 @@ +-----------------------------------------------------------------+-----------------------------------------------------------------------+ | .. figure:: | The theory of homology consists in attaching to a topological space | -| img/3DTorus_poch.png | a sequence of (homology) groups, capturing global topological | +| ../../doc/Persistent_cohomology/3DTorus_poch.png | a sequence of (homology) groups, capturing global topological | | :figclass: align-center | features like connected components, holes, cavities, etc. Persistent | | | homology studies the evolution -- birth, life and death -- of these | | Rips Persistent Cohomology on a 3D | features when the topological space is changing. Consequently, the | diff --git a/src/cython/doc/persistent_cohomology_user.rst b/src/cython/doc/persistent_cohomology_user.rst index 72f1a7f7..bf90c163 100644 --- a/src/cython/doc/persistent_cohomology_user.rst +++ b/src/cython/doc/persistent_cohomology_user.rst @@ -109,6 +109,6 @@ We provide several example files: run these examples with -h for details on thei Bibliography ============ -.. bibliography:: bibliography.bib +.. bibliography:: ../../biblio/bibliography.bib :filter: docnames :style: unsrt diff --git a/src/cython/doc/rips_complex_sum.rst b/src/cython/doc/rips_complex_sum.rst index 2b65fc19..5616bfa9 100644 --- a/src/cython/doc/rips_complex_sum.rst +++ b/src/cython/doc/rips_complex_sum.rst @@ -4,7 +4,7 @@ +----------------------------------------------------------------+------------------------------------------------------------------------+ | .. figure:: | Rips complex is a simplicial complex constructed from a one skeleton | -| img/rips_complex_representation.png | graph. | +| ../../doc/Rips_complex/rips_complex_representation.png | graph. | | :figclass: align-center | | | | The filtration value of each edge is computed from a user-given | | Rips complex representation | distance function and is inserted until a user-given threshold | diff --git a/src/cython/doc/rips_complex_user.rst b/src/cython/doc/rips_complex_user.rst index 6b48422b..96ba9944 100644 --- a/src/cython/doc/rips_complex_user.rst +++ b/src/cython/doc/rips_complex_user.rst @@ -26,7 +26,7 @@ structure, and then expands the simplicial complex when required. Vertex name correspond to the index of the point in the given range (aka. the point cloud). .. figure:: - img/rips_complex_representation.png + ../../doc/Rips_complex/rips_complex_representation.png :align: center Rips-complex one skeleton graph representation diff --git a/src/cython/doc/simplex_tree_sum.rst b/src/cython/doc/simplex_tree_sum.rst index 3174fb62..fb0e54c1 100644 --- a/src/cython/doc/simplex_tree_sum.rst +++ b/src/cython/doc/simplex_tree_sum.rst @@ -4,7 +4,7 @@ +----------------------------------------------------------------+------------------------------------------------------------------------+ | .. figure:: | The simplex tree is an efficient and flexible data structure for | -| img/Simplex_tree_representation.png | representing general (filtered) simplicial complexes. | +| ../../doc/Simplex_tree/Simplex_tree_representation.png | representing general (filtered) simplicial complexes. | | :alt: Simplex tree representation | | | :figclass: align-center | The data structure is described in | | | :cite:`boissonnatmariasimplextreealgorithmica` | diff --git a/src/cython/doc/tangential_complex_sum.rst b/src/cython/doc/tangential_complex_sum.rst index 2b05bc10..72b4d7ba 100644 --- a/src/cython/doc/tangential_complex_sum.rst +++ b/src/cython/doc/tangential_complex_sum.rst @@ -5,10 +5,10 @@ +----------------------------------------------------------------+------------------------------------------------------------------------+ | .. figure:: | A Tangential Delaunay complex is a simplicial complex designed to | -| img/tc_examples.png | reconstruct a :math:`k`-dimensional manifold embedded in :math:`d`- | +| ../../doc/Tangential_complex/tc_examples.png | reconstruct a :math:`k`-dimensional manifold embedded in :math:`d`- | | :figclass: align-center | dimensional Euclidean space. The input is a point sample coming from | | | an unknown manifold. The running time depends only linearly on the | -| **Tangential complex representation** | extrinsic dimension :math:`d` and exponentially on the intrinsic | +| Tangential complex representation | extrinsic dimension :math:`d` and exponentially on the intrinsic | | | dimension :math:`k`. | +----------------------------------------------------------------+------------------------------------------------------------------------+ | :doc:`tangential_complex_user` | :doc:`tangential_complex_ref` | diff --git a/src/cython/doc/tangential_complex_user.rst b/src/cython/doc/tangential_complex_user.rst index d670cfdb..efa6d7ce 100644 --- a/src/cython/doc/tangential_complex_user.rst +++ b/src/cython/doc/tangential_complex_user.rst @@ -22,7 +22,7 @@ Let us start with the description of the Tangential complex of a simple example, with :math:`k = 1` and :math:`d = 2`. The input data is 4 points :math:`P` located on a curve embedded in 2D. -.. figure:: img/tc_example_01.png +.. figure:: ../../doc/Tangential_complex/tc_example_01.png :alt: The input :figclass: align-center @@ -31,7 +31,7 @@ example, with :math:`k = 1` and :math:`d = 2`. The input data is 4 points For each point :math:`p`, estimate its tangent subspace :math:`T_p` (e.g. using PCA). -.. figure:: img/tc_example_02.png +.. figure:: ../../doc/Tangential_complex/tc_example_02.png :alt: The estimated normals :figclass: align-center @@ -42,7 +42,7 @@ Let us add the Voronoi diagram of the points in orange. For each point :math:`p`, construct its star in the Delaunay triangulation of :math:`P` restricted to :math:`T_p`. -.. figure:: img/tc_example_03.png +.. figure:: ../../doc/Tangential_complex/tc_example_03.png :alt: The Voronoi diagram :figclass: align-center @@ -62,7 +62,7 @@ simplex is not in the star of all its vertices. Let us take the same example. -.. figure:: img/tc_example_07_before.png +.. figure:: ../../doc/Tangential_complex/tc_example_07_before.png :alt: Before :figclass: align-center @@ -70,7 +70,7 @@ Let us take the same example. Let us slightly move the tangent subspace :math:`T_q` -.. figure:: img/tc_example_07_after.png +.. figure:: ../../doc/Tangential_complex/tc_example_07_after.png :alt: After :figclass: align-center @@ -79,7 +79,7 @@ Let us slightly move the tangent subspace :math:`T_q` Now, the star of :math:`Q` contains :math:`QP`, but the star of :math:`P` does not contain :math:`QP`. We have an inconsistency. -.. figure:: img/tc_example_08.png +.. figure:: ../../doc/Tangential_complex/tc_example_08.png :alt: After :figclass: align-center @@ -191,6 +191,6 @@ The output is: Bibliography ============ -.. bibliography:: bibliography.bib +.. bibliography:: ../../biblio/bibliography.bib :filter: docnames :style: unsrt diff --git a/src/cython/doc/witness_complex_sum.rst b/src/cython/doc/witness_complex_sum.rst index b65522ba..a8a126a0 100644 --- a/src/cython/doc/witness_complex_sum.rst +++ b/src/cython/doc/witness_complex_sum.rst @@ -3,15 +3,17 @@ :Euclidean version requires: CGAL :math:`\geq` 4.6.0 Eigen3 ================================================================= =================================== =================================== -+-----------------------------------------------------------------+----------------------------------------------------------------------+ -| .. image:: | Witness complex :math:`Wit(W,L)` is a simplicial complex defined on | -| img/Witness_complex_representation.png | two sets of points in :math:`\mathbb{R}^D`. | -| | | -| | The data structure is described in | -| | :cite:`boissonnatmariasimplextreealgorithmica`. | -+-----------------------------------------------------------------+----------------------------------------------------------------------+ -| :doc:`witness_complex_user` | * :doc:`witness_complex_ref` | -| | * :doc:`strong_witness_complex_ref` | -| | * :doc:`euclidean_witness_complex_ref` | -| | * :doc:`euclidean_strong_witness_complex_ref` | -+-----------------------------------------------------------------+----------------------------------------------------------------------+ ++-------------------------------------------------------------------+----------------------------------------------------------------------+ +| .. figure:: | Witness complex :math:`Wit(W,L)` is a simplicial complex defined on | +| ../../doc/Witness_complex/Witness_complex_representation.png | two sets of points in :math:`\mathbb{R}^D`. | +| :alt: Witness complex representation | | +| :figclass: align-center | The data structure is described in | +| | :cite:`boissonnatmariasimplextreealgorithmica`. | +| | | +| Witness complex representation | | ++-------------------------------------------------------------------+----------------------------------------------------------------------+ +| :doc:`witness_complex_user` | * :doc:`witness_complex_ref` | +| | * :doc:`strong_witness_complex_ref` | +| | * :doc:`euclidean_witness_complex_ref` | +| | * :doc:`euclidean_strong_witness_complex_ref` | ++-------------------------------------------------------------------+----------------------------------------------------------------------+ diff --git a/src/cython/doc/witness_complex_user.rst b/src/cython/doc/witness_complex_user.rst index aa9cbb2c..29413269 100644 --- a/src/cython/doc/witness_complex_user.rst +++ b/src/cython/doc/witness_complex_user.rst @@ -33,7 +33,7 @@ Both definitions can be relaxed by a real value :math:`\alpha`: which leads to definitions of **weak relaxed witness complex** (or just relaxed witness complex for short) and **strong relaxed witness complex** respectively. -.. figure:: img/swit.svg +.. figure:: ../../doc/Witness_complex/swit.svg :alt: Strongly witnessed simplex :figclass: align-center @@ -126,6 +126,6 @@ Here is an example of constructing a strong witness complex filtration and compu Bibliography ============ -.. bibliography:: bibliography.bib +.. bibliography:: ../../biblio/bibliography.bib :filter: docnames :style: unsrt -- cgit v1.2.3 From df9030e6c1df5fb735914eadd44cf27b86fce239 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 11 Sep 2017 15:12:01 +0000 Subject: Add comment for the dependency git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cythonization_improvement@2655 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: ab03b16bc884fe3291e3308e4a975b7c6232a861 --- src/cython/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index 6c8232ea..ea6e840a 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -326,6 +326,7 @@ if(CYTHON_FOUND) # set sphinx-build in make files configure_file(doc/python3-sphinx-build.in "${CMAKE_CURRENT_BINARY_DIR}/doc/python3-sphinx-build" @ONLY) + # sphinx target requires gudhi.so, because conf.py reads gudhi version from it add_custom_target(sphinx WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doc COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" -- cgit v1.2.3 From 03bb8ee15f7c8b71fd922a27ed02bca4c98825d9 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 11 Sep 2017 15:16:39 +0000 Subject: remove debug traces git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cythonization_improvement@2656 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 4ea039d0564268458ca64950113fbffdc86c10b3 --- src/cython/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index ea6e840a..7cf31a03 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -148,7 +148,6 @@ if(CYTHON_FOUND) # Loop on INCLUDE_DIRECTORIES PROPERTY get_property(GUDHI_INCLUDE_DIRECTORIES DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES) foreach(GUDHI_INCLUDE_DIRECTORY ${GUDHI_INCLUDE_DIRECTORIES}) - message(" --- ${GUDHI_INCLUDE_DIRECTORY} ---") set(GUDHI_CYTHON_INCLUDE_DIRS "${GUDHI_CYTHON_INCLUDE_DIRS}'${GUDHI_INCLUDE_DIRECTORY}', ") endforeach() set(GUDHI_CYTHON_INCLUDE_DIRS "${GUDHI_CYTHON_INCLUDE_DIRS}'${CMAKE_SOURCE_DIR}/${GUDHI_CYTHON_PATH}/include', ") -- cgit v1.2.3 From b9ca395bdade623ccfc58e92a98e90bf7eae6f17 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 11 Sep 2017 19:40:56 +0000 Subject: Code review: constify find_child and for instead of while loop git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2657 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: e136c1a8b6d5bbc213383f1e6a2e00a875424ad1 --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index f7df277c..f48dd048 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1124,9 +1124,8 @@ class Simplex_tree { return; // Reverse loop starting before the last one for 'next' to be the last one for (auto simplex = siblings->members().rbegin() + 1; simplex != siblings->members().rend(); simplex++) { - auto next = siblings->members().rbegin(); std::vector > intersection; - while(next != simplex) { + for(auto next = siblings->members().rbegin(); next != simplex; next++) { bool to_be_inserted = true; Filtration_value filt = simplex->second.filtration(); // If all the boundaries are present, 'next' needs to be inserted @@ -1141,8 +1140,6 @@ class Simplex_tree { if (to_be_inserted) { intersection.emplace_back(next->first, Node(nullptr, filt)); } - // loop until simplex is reached - next++; } if (intersection.size() != 0) { // Reverse the order to insert @@ -1183,7 +1180,7 @@ class Simplex_tree { * Vertex_handle. * Returns null_simplex() if it does not exist */ - Simplex_handle find_child(Simplex_handle sh, Vertex_handle vh) { + Simplex_handle find_child(Simplex_handle sh, Vertex_handle vh) const { if (!has_children(sh)) return null_simplex(); -- cgit v1.2.3 From fb41612243f07ee6faaca02f70d09d4501c24bb1 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 11 Sep 2017 19:49:36 +0000 Subject: Code review: remove reference and explicit type (instead of auto) git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2658 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 3ba33efc13a3a650f2c2d20bb803aca3b475603a --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index f48dd048..ff6ffa67 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1129,7 +1129,7 @@ class Simplex_tree { bool to_be_inserted = true; Filtration_value filt = simplex->second.filtration(); // If all the boundaries are present, 'next' needs to be inserted - for (auto& border : boundary_simplex_range(simplex)) { + for (Simplex_handle border : boundary_simplex_range(simplex)) { Simplex_handle border_child = find_child(border, next->first); if (border_child == null_simplex()) { to_be_inserted=false; -- cgit v1.2.3 From f25099a09b2c0c4a6a317f2c869bc819462d7edf Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 11 Sep 2017 19:53:33 +0000 Subject: Doc review: rephrase git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2659 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: b8a04218fa043e2bd273f77233d794e2c9522060 --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index ff6ffa67..5cb13053 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1097,8 +1097,8 @@ class Simplex_tree { * candidate. * * @warning several candidates of the same dimension may be inserted simultaneously before calling `block_simplex`, - * so if you examine the complex in `block_simplex`, you may hit a few simplices that have not been vetted by - * `block_simplex` yet. + * so if you examine the complex in `block_simplex`, you may hit a few simplices of the same dimension that have not + * been vetted by `block_simplex` yet, or have already been rejected but not yet removed. */ template< typename Blocker > void expansion_with_blockers(int max_dim, Blocker block_simplex) { -- cgit v1.2.3 From de09c3d3a8c86b1538f66c674f6f9819abec16cc Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 11 Sep 2017 20:08:29 +0000 Subject: Doc review: bad doc review fix git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2660 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: a024a1570e282c5ebd1c675d687372ee3dab0ed0 --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 5cb13053..730b552f 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1302,7 +1302,7 @@ class Simplex_tree { public: /** \brief Remove a maximal simplex. * @param[in] sh Simplex handle on the maximal simplex to remove. - * @return true if simplex was deleted, false otherwise. + * @return true if the leaf's branch has no other leaves (branch's children has been re-assigned), false otherwise. * \pre Please check the simplex has no coface before removing it. * \exception std::invalid_argument In debug mode, if sh has children. * \post Be aware that removing is shifting data in a flat_map (initialize_filtration to be done). -- cgit v1.2.3 From 04fe614e8a859257b57aadfdb5aa14fc3d78babb Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 12 Sep 2017 08:30:31 +0000 Subject: Euclidean witness requires CGAL 4.6.0 Subsampling requires CGAL 4.8.1 All modules requiring CGAL requires also Eigen3 git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cythonization_improvement@2662 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: df4c03882b8c5eb91f12939b460b3c9b85cbb870 --- src/cython/CMakeLists.txt | 96 +++++++++++++++++------------------------------ 1 file changed, 35 insertions(+), 61 deletions(-) diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index 7cf31a03..db23d42b 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -73,47 +73,18 @@ if(CYTHON_FOUND) set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DCGAL_EIGEN3_ENABLED', ") endif (EIGEN3_FOUND) - if (NOT CGAL_VERSION VERSION_LESS 4.8.1) - # If CGAL_VERSION >= 4.8.1, include subsampling + if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) set(GUDHI_CYTHON_SUBSAMPLING "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/subsampling.pyx'") set(GUDHI_CYTHON_TANGENTIAL_COMPLEX "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/tangential_complex.pyx'") set(GUDHI_CYTHON_BOTTLENECK_DISTANCE "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/bottleneck_distance.pyx'") - else (NOT CGAL_VERSION VERSION_LESS 4.8.1) - # Remove subsampling unitary tests - file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/test/test_subsampling.py) - file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/doc/subsampling_ref.rst") - file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/doc/subsampling_sum.rst") - file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/doc/subsampling_user.rst") - # Remove tangential complex and bottleneck unitary tests - file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/test/test_tangential_complex.py) - file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/test/test_bottleneck_distance.py) - file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/doc/bottleneck_distance_ref.rst") - file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/doc/bottleneck_distance_sum.rst") - file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/doc/bottleneck_distance_user.rst") - file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/doc/tangential_complex_ref.rst") - file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/doc/tangential_complex_sum.rst") - file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/doc/tangential_complex_user.rst") - endif (NOT CGAL_VERSION VERSION_LESS 4.8.1) - if (NOT CGAL_VERSION VERSION_LESS 4.7.0) - # If CGAL_VERSION >= 4.7.0, include alpha + endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) + if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0) set(GUDHI_CYTHON_ALPHA_COMPLEX "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/alpha_complex.pyx'") - else (NOT CGAL_VERSION VERSION_LESS 4.7.0) - # Remove alpha complex unitary tests - file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/test/test_alpha_complex.py) - file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/doc/alpha_complex_ref.rst") - file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/doc/alpha_complex_sum.rst") - file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/doc/alpha_complex_user.rst") - endif (NOT CGAL_VERSION VERSION_LESS 4.7.0) - if (NOT CGAL_VERSION VERSION_LESS 4.6.0) - # If CGAL_VERSION >= 4.6.0, include euclidean versions of witness complex + endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0) + if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.6.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") - else (NOT CGAL_VERSION VERSION_LESS 4.6.0) - # Remove euclidean witness complex unitary tests - file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/test/test_euclidean_witness_complex.py) - file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/doc/euclidean_witness_complex_ref.rst") - file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/doc/euclidean_strong_witness_complex_ref.rst") - endif (NOT CGAL_VERSION VERSION_LESS 4.6.0) + endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.6.0) if(CGAL_FOUND) # Add CGAL compilation args @@ -185,7 +156,7 @@ if(CYTHON_FOUND) PATTERN "*.pyd") # Test examples - if (NOT CGAL_VERSION VERSION_LESS 4.8.1) + if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) # Bottleneck add_test(NAME alpha_rips_persistence_bottleneck_distance_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} @@ -213,26 +184,14 @@ if(CYTHON_FOUND) WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_tangential_complex.py) - # Euclidean witness - add_test(NAME euclidean_strong_witness_complex_diagram_persistence_from_off_file_example_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" - ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py" - --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -a 1.0 -n 20 -d 2) - - add_test(NAME euclidean_witness_complex_diagram_persistence_from_off_file_example_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" - ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py" - --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -a 1.0 -n 20 -d 2) - - add_test(NAME test_euclidean_witness_complex_py_test + # Subsampling + add_test(NAME test_subsampling_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_euclidean_witness_complex.py) + COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_subsampling.py) - endif (NOT CGAL_VERSION VERSION_LESS 4.8.1) + endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) - if (NOT CGAL_VERSION VERSION_LESS 4.7.0) + if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0) # Alpha add_test(NAME alpha_complex_from_points_example_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} @@ -249,7 +208,27 @@ if(CYTHON_FOUND) WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_alpha_complex.py) - endif (NOT CGAL_VERSION VERSION_LESS 4.7.0) + endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0) + + if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.6.0) + # Euclidean witness + add_test(NAME euclidean_strong_witness_complex_diagram_persistence_from_off_file_example_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" + ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py" + --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -a 1.0 -n 20 -d 2) + + add_test(NAME euclidean_witness_complex_diagram_persistence_from_off_file_example_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" + ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py" + --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -a 1.0 -n 20 -d 2) + + add_test(NAME test_euclidean_witness_complex_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_euclidean_witness_complex.py) + + endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.6.0) # Cubical add_test(NAME periodic_cubical_complex_barcode_persistence_from_perseus_file_example_py_test @@ -315,13 +294,8 @@ if(CYTHON_FOUND) WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_reader_utils.py) - # Subsampling - add_test(NAME test_subsampling_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_subsampling.py) - # Documentation generation is available through sphinx - requires all modules - if(SPHINX_PATH AND NOT CGAL_VERSION VERSION_LESS 4.8.1) + if(SPHINX_PATH AND NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) # set sphinx-build in make files configure_file(doc/python3-sphinx-build.in "${CMAKE_CURRENT_BINARY_DIR}/doc/python3-sphinx-build" @ONLY) @@ -337,5 +311,5 @@ if(CYTHON_FOUND) COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" ${SPHINX_PATH} -b doctest ${CMAKE_CURRENT_SOURCE_DIR}/doc "${CMAKE_CURRENT_BINARY_DIR}/sphinx") - endif(SPHINX_PATH AND NOT CGAL_VERSION VERSION_LESS 4.8.1) + endif(SPHINX_PATH AND NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) endif(CYTHON_FOUND) -- cgit v1.2.3 From 5470c3565cfb4b9e3827a42bfdc3fbec461638a5 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 12 Sep 2017 10:05:46 +0000 Subject: Fix in Python3 if sphinx is not installed git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cythonization_improvement@2663 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 0005d7fe2e7e8513a276543295c02351456595cc --- src/cmake/modules/GUDHI_third_party_libraries.cmake | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cmake/modules/GUDHI_third_party_libraries.cmake b/src/cmake/modules/GUDHI_third_party_libraries.cmake index dbf2106a..4cf2f445 100644 --- a/src/cmake/modules/GUDHI_third_party_libraries.cmake +++ b/src/cmake/modules/GUDHI_third_party_libraries.cmake @@ -122,8 +122,12 @@ if(PYTHONINTERP_FOUND AND CYTHON_FOUND) # Documentation generation is available through sphinx find_program( SPHINX_PATH sphinx-build ) elseif(PYTHON_VERSION_MAJOR EQUAL 3) - # No sphinx-build in Pyton3, just hack it - set(SPHINX_PATH "${CMAKE_CURRENT_BINARY_DIR}/${GUDHI_CYTHON_PATH}/doc/python3-sphinx-build") + execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from sphinx import main" + RESULT_VARIABLE SPHINX_MODULE_IS_INSTALLED) + if(SPHINX_MODULE_IS_INSTALLED) + # No sphinx-build in Pyton3, just hack it + set(SPHINX_PATH "${CMAKE_CURRENT_BINARY_DIR}/${GUDHI_CYTHON_PATH}/doc/python3-sphinx-build") + endif(SPHINX_MODULE_IS_INSTALLED) else() message(FATAL_ERROR "ERROR: Try to compile the Cython interface. Python version ${PYTHON_VERSION_STRING} is not valid.") endif(PYTHON_VERSION_MAJOR EQUAL 2) -- cgit v1.2.3 From 3dd4db9ad872eecae58e6edf3c16915ca1ec7ccc Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 12 Sep 2017 11:26:30 +0000 Subject: Add debug traces git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cythonization_improvement@2664 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: e4c572d98f4628e7f9b36fd9925ba7ce68e3cf81 --- src/cmake/modules/GUDHI_third_party_libraries.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cmake/modules/GUDHI_third_party_libraries.cmake b/src/cmake/modules/GUDHI_third_party_libraries.cmake index 4cf2f445..799d28b6 100644 --- a/src/cmake/modules/GUDHI_third_party_libraries.cmake +++ b/src/cmake/modules/GUDHI_third_party_libraries.cmake @@ -124,6 +124,7 @@ if(PYTHONINTERP_FOUND AND CYTHON_FOUND) elseif(PYTHON_VERSION_MAJOR EQUAL 3) execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from sphinx import main" RESULT_VARIABLE SPHINX_MODULE_IS_INSTALLED) + message(" --- SPHINX_MODULE_IS_INSTALLED --- ${SPHINX_MODULE_IS_INSTALLED}") if(SPHINX_MODULE_IS_INSTALLED) # No sphinx-build in Pyton3, just hack it set(SPHINX_PATH "${CMAKE_CURRENT_BINARY_DIR}/${GUDHI_CYTHON_PATH}/doc/python3-sphinx-build") -- cgit v1.2.3 From 90f4783f287e266d3d8787d0d18b84d27f8b96b6 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 12 Sep 2017 12:45:20 +0000 Subject: Modification rollback git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cythonization_improvement@2665 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 2f977f8b93c6104d2b7c8f16c13da974b36f1535 --- src/cmake/modules/GUDHI_third_party_libraries.cmake | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/cmake/modules/GUDHI_third_party_libraries.cmake b/src/cmake/modules/GUDHI_third_party_libraries.cmake index 799d28b6..dbf2106a 100644 --- a/src/cmake/modules/GUDHI_third_party_libraries.cmake +++ b/src/cmake/modules/GUDHI_third_party_libraries.cmake @@ -122,13 +122,8 @@ if(PYTHONINTERP_FOUND AND CYTHON_FOUND) # Documentation generation is available through sphinx find_program( SPHINX_PATH sphinx-build ) elseif(PYTHON_VERSION_MAJOR EQUAL 3) - execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from sphinx import main" - RESULT_VARIABLE SPHINX_MODULE_IS_INSTALLED) - message(" --- SPHINX_MODULE_IS_INSTALLED --- ${SPHINX_MODULE_IS_INSTALLED}") - if(SPHINX_MODULE_IS_INSTALLED) - # No sphinx-build in Pyton3, just hack it - set(SPHINX_PATH "${CMAKE_CURRENT_BINARY_DIR}/${GUDHI_CYTHON_PATH}/doc/python3-sphinx-build") - endif(SPHINX_MODULE_IS_INSTALLED) + # No sphinx-build in Pyton3, just hack it + set(SPHINX_PATH "${CMAKE_CURRENT_BINARY_DIR}/${GUDHI_CYTHON_PATH}/doc/python3-sphinx-build") else() message(FATAL_ERROR "ERROR: Try to compile the Cython interface. Python version ${PYTHON_VERSION_STRING} is not valid.") endif(PYTHON_VERSION_MAJOR EQUAL 2) -- cgit v1.2.3 From 9a3df180af4976242fb45d7dcd49c3632e65f04c Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 12 Sep 2017 20:36:58 +0000 Subject: Bottleneck does not require Eigen3 (C++ and Python) Doc issue about examples requiring Eigen3 git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cythonization_improvement@2666 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 5e127d4e8137a44ee3bd688c32653acfb4a55007 --- src/Bottleneck_distance/benchmark/CMakeLists.txt | 4 ++-- src/Bottleneck_distance/example/CMakeLists.txt | 26 ++++++++++++++++-------- src/Bottleneck_distance/test/CMakeLists.txt | 4 ++-- src/common/doc/main_page.h | 20 ++++++++++++++++-- src/cython/CMakeLists.txt | 26 ++++++++++++++---------- 5 files changed, 54 insertions(+), 26 deletions(-) diff --git a/src/Bottleneck_distance/benchmark/CMakeLists.txt b/src/Bottleneck_distance/benchmark/CMakeLists.txt index 170081ce..20a4e47b 100644 --- a/src/Bottleneck_distance/benchmark/CMakeLists.txt +++ b/src/Bottleneck_distance/benchmark/CMakeLists.txt @@ -1,9 +1,9 @@ cmake_minimum_required(VERSION 2.6) project(Bottleneck_distance_benchmark) -if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) +if (NOT CGAL_VERSION VERSION_LESS 4.8.1) add_executable ( bottleneck_chrono bottleneck_chrono.cpp ) if (TBB_FOUND) target_link_libraries(bottleneck_chrono ${TBB_LIBRARIES}) endif(TBB_FOUND) -endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) +endif(NOT CGAL_VERSION VERSION_LESS 4.8.1) diff --git a/src/Bottleneck_distance/example/CMakeLists.txt b/src/Bottleneck_distance/example/CMakeLists.txt index dc1da31c..eac617db 100644 --- a/src/Bottleneck_distance/example/CMakeLists.txt +++ b/src/Bottleneck_distance/example/CMakeLists.txt @@ -1,30 +1,38 @@ cmake_minimum_required(VERSION 2.6) project(Bottleneck_distance_examples) -if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) +if (NOT CGAL_VERSION VERSION_LESS 4.8.1) add_executable (bottleneck_read_file_example bottleneck_read_file_example.cpp) add_executable (bottleneck_basic_example bottleneck_basic_example.cpp) - add_executable (alpha_rips_persistence_bottleneck_distance alpha_rips_persistence_bottleneck_distance.cpp) - target_link_libraries(alpha_rips_persistence_bottleneck_distance ${Boost_PROGRAM_OPTIONS_LIBRARY}) if (TBB_FOUND) target_link_libraries(bottleneck_read_file_example ${TBB_LIBRARIES}) target_link_libraries(bottleneck_basic_example ${TBB_LIBRARIES}) - target_link_libraries(alpha_rips_persistence_bottleneck_distance ${TBB_LIBRARIES}) endif(TBB_FOUND) add_test(NAME Bottleneck_distance_example_basic COMMAND $) - add_test(NAME Bottleneck_distance_example_alpha_rips_persistence_bottleneck - COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "-r" "0.15" "-m" "0.12" "-d" "3" "-p" "3") - add_test(NAME Bottleneck_read_file_example COMMAND $ "${CMAKE_SOURCE_DIR}/data/persistence_diagram/first.pers" "${CMAKE_SOURCE_DIR}/data/persistence_diagram/second.pers") install(TARGETS bottleneck_read_file_example DESTINATION bin) install(TARGETS bottleneck_basic_example DESTINATION bin) - install(TARGETS alpha_rips_persistence_bottleneck_distance DESTINATION bin) +endif (NOT CGAL_VERSION VERSION_LESS 4.8.1) + +# Eigen3 and CGAL > 4.7.0 is required for alpha complex +# CGAL > 4.8.1 is required for bottleneck distance => +if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) + add_executable (alpha_rips_persistence_bottleneck_distance alpha_rips_persistence_bottleneck_distance.cpp) + target_link_libraries(alpha_rips_persistence_bottleneck_distance ${Boost_PROGRAM_OPTIONS_LIBRARY}) + + add_test(NAME Bottleneck_distance_example_alpha_rips_persistence_bottleneck + COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "-r" "0.15" "-m" "0.12" "-d" "3" "-p" "3") + + install(TARGETS alpha_rips_persistence_bottleneck_distance DESTINATION bin) + if (TBB_FOUND) + target_link_libraries(alpha_rips_persistence_bottleneck_distance ${TBB_LIBRARIES}) + endif(TBB_FOUND) endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) diff --git a/src/Bottleneck_distance/test/CMakeLists.txt b/src/Bottleneck_distance/test/CMakeLists.txt index a165d472..2676b82c 100644 --- a/src/Bottleneck_distance/test/CMakeLists.txt +++ b/src/Bottleneck_distance/test/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 2.6) project(Bottleneck_distance_tests) -if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) +if (NOT CGAL_VERSION VERSION_LESS 4.8.1) include(GUDHI_test_coverage) add_executable ( Bottleneck_distance_test_unit bottleneck_unit_test.cpp ) @@ -12,4 +12,4 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) gudhi_add_coverage_test(Bottleneck_distance_test_unit) -endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) +endif (NOT CGAL_VERSION VERSION_LESS 4.8.1) diff --git a/src/common/doc/main_page.h b/src/common/doc/main_page.h index bd4615f5..1a7994a5 100644 --- a/src/common/doc/main_page.h +++ b/src/common/doc/main_page.h @@ -160,7 +160,7 @@ Author: François Godi
Introduced in: GUDHI 2.0.0
Copyright: GPL v3
- Requires: \ref cgal ≥ 4.8.1 and \ref eigen3 + Requires: \ref cgal ≥ 4.8.1
Bottleneck distance measures the similarity between two persistence diagrams. @@ -329,13 +329,29 @@ make doxygen * Alpha_complex/Alpha_complex_from_off.cpp * \li * Alpha_complex/Alpha_complex_from_points.cpp + * \li + * Bottleneck_distance/alpha_rips_persistence_bottleneck_distance.cpp.cpp * \li * Persistent_cohomology/alpha_complex_persistence.cpp * \li * Persistent_cohomology/periodic_alpha_complex_3d_persistence.cpp * \li * Persistent_cohomology/custom_persistence_sort.cpp - * + * \li + * Spatial_searching/example_spatial_searching.cpp + * \li + * Subsampling/example_choose_n_farthest_points.cpp + * \li + * Subsampling/example_custom_kernel.cpp + * \li + * Subsampling/example_pick_n_random_points.cpp + * \li + * Subsampling/example_sparsify_point_set.cpp + * \li + * Tangential_complex/example_basic.cpp + * \li + * Tangential_complex/example_with_perturb.cpp + * * \subsection tbb Threading Building Blocks * Intel® TBB lets you easily write parallel * C++ programs that take full advantage of multicore performance, that are portable and composable, and that have diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index db23d42b..baeeb203 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -73,10 +73,12 @@ if(CYTHON_FOUND) set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DCGAL_EIGEN3_ENABLED', ") endif (EIGEN3_FOUND) + if (NOT CGAL_VERSION VERSION_LESS 4.8.1) + set(GUDHI_CYTHON_BOTTLENECK_DISTANCE "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/bottleneck_distance.pyx'") + endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) set(GUDHI_CYTHON_SUBSAMPLING "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/subsampling.pyx'") set(GUDHI_CYTHON_TANGENTIAL_COMPLEX "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/tangential_complex.pyx'") - set(GUDHI_CYTHON_BOTTLENECK_DISTANCE "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/bottleneck_distance.pyx'") endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0) set(GUDHI_CYTHON_ALPHA_COMPLEX "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/alpha_complex.pyx'") @@ -157,22 +159,13 @@ if(CYTHON_FOUND) # Test examples if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) - # Bottleneck + # Bottleneck and Alpha add_test(NAME alpha_rips_persistence_bottleneck_distance_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/alpha_rips_persistence_bottleneck_distance.py" -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -t 0.15 -d 3) - add_test(NAME bottleneck_basic_example_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" - ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/bottleneck_basic_example.py") - - add_test(NAME test_bottleneck_distance_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_bottleneck_distance.py) - # Tangential add_test(NAME tangential_complex_plain_homology_from_off_file_example_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} @@ -190,6 +183,17 @@ if(CYTHON_FOUND) COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_subsampling.py) endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) + if (NOT CGAL_VERSION VERSION_LESS 4.8.1) + # Bottleneck + add_test(NAME bottleneck_basic_example_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" + ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/bottleneck_basic_example.py") + + add_test(NAME test_bottleneck_distance_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_bottleneck_distance.py) + endif (NOT CGAL_VERSION VERSION_LESS 4.8.1) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0) # Alpha -- cgit v1.2.3 From 8a22b7c6111b41e91766cdd53c0116b845e068b5 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 12 Sep 2017 21:47:19 +0000 Subject: Fix sphinx build for python3 on Ubuntu git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cythonization_improvement@2667 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: c720b8be2919344e06f3d71cefdd7693439f63f0 --- src/cmake/modules/GUDHI_third_party_libraries.cmake | 2 +- src/cython/CMakeLists.txt | 9 +++------ src/cython/doc/python3-sphinx-build.in | 11 ----------- src/cython/doc/python3-sphinx-build.py | 11 +++++++++++ 4 files changed, 15 insertions(+), 18 deletions(-) delete mode 100755 src/cython/doc/python3-sphinx-build.in create mode 100755 src/cython/doc/python3-sphinx-build.py diff --git a/src/cmake/modules/GUDHI_third_party_libraries.cmake b/src/cmake/modules/GUDHI_third_party_libraries.cmake index dbf2106a..f2bbafdc 100644 --- a/src/cmake/modules/GUDHI_third_party_libraries.cmake +++ b/src/cmake/modules/GUDHI_third_party_libraries.cmake @@ -123,7 +123,7 @@ if(PYTHONINTERP_FOUND AND CYTHON_FOUND) find_program( SPHINX_PATH sphinx-build ) elseif(PYTHON_VERSION_MAJOR EQUAL 3) # No sphinx-build in Pyton3, just hack it - set(SPHINX_PATH "${CMAKE_CURRENT_BINARY_DIR}/${GUDHI_CYTHON_PATH}/doc/python3-sphinx-build") + set(SPHINX_PATH "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/${GUDHI_CYTHON_PATH}/doc/python3-sphinx-build.py") else() message(FATAL_ERROR "ERROR: Try to compile the Cython interface. Python version ${PYTHON_VERSION_STRING} is not valid.") endif(PYTHON_VERSION_MAJOR EQUAL 2) diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index baeeb203..d1761f47 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -75,7 +75,7 @@ if(CYTHON_FOUND) if (NOT CGAL_VERSION VERSION_LESS 4.8.1) set(GUDHI_CYTHON_BOTTLENECK_DISTANCE "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/bottleneck_distance.pyx'") - endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) + endif (NOT CGAL_VERSION VERSION_LESS 4.8.1) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) set(GUDHI_CYTHON_SUBSAMPLING "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/subsampling.pyx'") set(GUDHI_CYTHON_TANGENTIAL_COMPLEX "include '${CMAKE_CURRENT_SOURCE_DIR}/cython/tangential_complex.pyx'") @@ -300,20 +300,17 @@ if(CYTHON_FOUND) # Documentation generation is available through sphinx - requires all modules if(SPHINX_PATH AND NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) - # set sphinx-build in make files - configure_file(doc/python3-sphinx-build.in "${CMAKE_CURRENT_BINARY_DIR}/doc/python3-sphinx-build" @ONLY) - # sphinx target requires gudhi.so, because conf.py reads gudhi version from it add_custom_target(sphinx WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doc COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" - ${SPHINX_PATH} -b html . "${CMAKE_CURRENT_BINARY_DIR}/sphinx" + ${SPHINX_PATH} -b html ${CMAKE_CURRENT_SOURCE_DIR}/doc sphinx DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/gudhi.so") add_test(NAME sphinx_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" - ${SPHINX_PATH} -b doctest ${CMAKE_CURRENT_SOURCE_DIR}/doc "${CMAKE_CURRENT_BINARY_DIR}/sphinx") + ${SPHINX_PATH} -b doctest ${CMAKE_CURRENT_SOURCE_DIR}/doc doctest) endif(SPHINX_PATH AND NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) endif(CYTHON_FOUND) diff --git a/src/cython/doc/python3-sphinx-build.in b/src/cython/doc/python3-sphinx-build.in deleted file mode 100755 index c97965f5..00000000 --- a/src/cython/doc/python3-sphinx-build.in +++ /dev/null @@ -1,11 +0,0 @@ -#!@PYTHON_EXECUTABLE@ - -""" -Emulate sphinx-build for python3 -""" - -from sys import exit, argv -from sphinx import main - -if __name__ == '__main__': - exit(main(argv)) diff --git a/src/cython/doc/python3-sphinx-build.py b/src/cython/doc/python3-sphinx-build.py new file mode 100755 index 00000000..44b94169 --- /dev/null +++ b/src/cython/doc/python3-sphinx-build.py @@ -0,0 +1,11 @@ +#!/usr/bin/python3 + +""" +Emulate sphinx-build for python3 +""" + +from sys import exit, argv +from sphinx import main + +if __name__ == '__main__': + exit(main(argv)) -- cgit v1.2.3 -- cgit v1.2.3 From 624126c4af0a0b7d50a347968a24789ca69adbfe Mon Sep 17 00:00:00 2001 From: cjamin Date: Wed, 13 Sep 2017 13:42:16 +0000 Subject: radius search => near search git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/call_it_near_search@2669 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: e77c8b7de12df9cf5d0a6ef8d79e4b14a28237b3 --- src/Spatial_searching/doc/Intro_spatial_searching.h | 2 +- src/Spatial_searching/example/example_spatial_searching.cpp | 6 +++--- src/Spatial_searching/include/gudhi/Kd_tree_search.h | 2 +- src/Spatial_searching/test/test_Kd_tree_search.cpp | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Spatial_searching/doc/Intro_spatial_searching.h b/src/Spatial_searching/doc/Intro_spatial_searching.h index 9a3c1b65..22652ac4 100644 --- a/src/Spatial_searching/doc/Intro_spatial_searching.h +++ b/src/Spatial_searching/doc/Intro_spatial_searching.h @@ -46,7 +46,7 @@ namespace spatial_searching { * * \section spatial_searching_examples Example * - * This example generates 500 random points, then performs radius search, and queries for nearest and farthest points using different methods. + * This example generates 500 random points, then performs near search, and queries for nearest and farthest points using different methods. * * \include Spatial_searching/example_spatial_searching.cpp * diff --git a/src/Spatial_searching/example/example_spatial_searching.cpp b/src/Spatial_searching/example/example_spatial_searching.cpp index 9e6a8f32..201b589e 100644 --- a/src/Spatial_searching/example/example_spatial_searching.cpp +++ b/src/Spatial_searching/example/example_spatial_searching.cpp @@ -48,10 +48,10 @@ int main(void) { for (auto ifs_iterator = ifn_range.begin(); ifs_iterator->first != 0; ++ifs_iterator) std::cout << ifs_iterator->first << " (sq. dist. = " << ifs_iterator->second << ")\n"; - // Radius search - std::cout << "Radius search:\n"; + // Near search + std::cout << "Near search:\n"; std::vector rs_result; - points_ds.radius_search(points[45], 0.5, std::back_inserter(rs_result)); + points_ds.near_search(points[45], 0.5, std::back_inserter(rs_result)); K k; for (auto const& p_idx : rs_result) std::cout << p_idx << " (sq. dist. = " << k.squared_distance_d_object()(points[p_idx], points[45]) << ")\n"; diff --git a/src/Spatial_searching/include/gudhi/Kd_tree_search.h b/src/Spatial_searching/include/gudhi/Kd_tree_search.h index f13a98f7..a4385c84 100644 --- a/src/Spatial_searching/include/gudhi/Kd_tree_search.h +++ b/src/Spatial_searching/include/gudhi/Kd_tree_search.h @@ -264,7 +264,7 @@ class Kd_tree_search { /// Note: `it` is used this way: `*it++ = each_point`. /// @param[in] eps Approximation factor. template - void radius_search( + void near_search( Point const& p, FT radius, OutputIterator it, diff --git a/src/Spatial_searching/test/test_Kd_tree_search.cpp b/src/Spatial_searching/test/test_Kd_tree_search.cpp index f79114bc..663a103a 100644 --- a/src/Spatial_searching/test/test_Kd_tree_search.cpp +++ b/src/Spatial_searching/test/test_Kd_tree_search.cpp @@ -110,10 +110,10 @@ BOOST_AUTO_TEST_CASE(test_Kd_tree_search) { // Same result for KFN and IFN? BOOST_CHECK(kfn_result == ifn_result); - // Test radius search + // Test near search Point rs_q(rd.get_double(-1., 1), rd.get_double(-1., 1), rd.get_double(-1., 1), rd.get_double(-1., 1)); std::vector rs_result; - points_ds.radius_search(rs_q, 0.5, std::back_inserter(rs_result)); + points_ds.near_search(rs_q, 0.5, std::back_inserter(rs_result)); K k; for (auto const& p_idx : rs_result) BOOST_CHECK(k.squared_distance_d_object()(points[p_idx], rs_q) <= 0.5); -- cgit v1.2.3 From bc62d9afbb151279a9da1e082a53788d3fd0d242 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 18 Sep 2017 09:37:20 +0000 Subject: Add warning for developper version that sphinx is configured for user version Removes GudhUI ERROR mesages (just warnings git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cythonization_improvement@2677 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 0111272d9f6d6dc10e370360b2242eff4828611b --- src/GudhUI/CMakeLists.txt | 34 +++------------------------------- src/cython/CMakeLists.txt | 13 ++++++++++--- 2 files changed, 13 insertions(+), 34 deletions(-) diff --git a/src/GudhUI/CMakeLists.txt b/src/GudhUI/CMakeLists.txt index 57861946..374195d0 100644 --- a/src/GudhUI/CMakeLists.txt +++ b/src/GudhUI/CMakeLists.txt @@ -5,28 +5,6 @@ find_package(Qt5 COMPONENTS Widgets Xml OpenGL) find_package(QGLViewer) find_package(OpenGL) -if (CGAL_VERSION VERSION_EQUAL 4.8.0) - message(ERROR " GudhUI does not compile with CGAL 4.8.0. 4.8.1, 4.8.2 and 4.9 are OK.") -endif() - -if (NOT CGAL_FOUND) - message(ERROR " GudhUI requires CGAL and will not be compiled.") -endif() - -if (NOT Qt5_FOUND) - message(ERROR " GudhUI requires Qt5 and will not be compiled.") -endif() - -if (NOT OPENGL_FOUND) - message(ERROR " GudhUI requires OpenGL and will not be compiled.") -endif() - -if (NOT QGLVIEWER_FOUND) - message(ERROR " GudhUI requires QGLViewer and will not be compiled.") -endif() - - - if ( CGAL_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND AND NOT CGAL_VERSION VERSION_EQUAL 4.8.0) set(CMAKE_AUTOMOC ON) @@ -37,8 +15,6 @@ if ( CGAL_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND AND NOT CGAL_ SET(Boost_USE_MULTITHREAD OFF) include_directories (${QGLVIEWER_INCLUDE_DIR}) - ##################################################################### - add_executable ( GudhUI gui/gudhui.cpp gui/MainWindow.cpp @@ -52,14 +28,10 @@ if ( CGAL_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND AND NOT CGAL_ target_link_libraries( GudhUI Qt5::Widgets Qt5::Xml Qt5::OpenGL ) target_link_libraries( GudhUI ${QGLVIEWER_LIBRARIES} ) target_link_libraries( GudhUI ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ) -if (TBB_FOUND) - target_link_libraries( GudhUI ${TBB_LIBRARIES}) -endif() + if (TBB_FOUND) + target_link_libraries( GudhUI ${TBB_LIBRARIES}) + endif() install(TARGETS GudhUI DESTINATION bin) -############################################################################### - -else() - message(STATUS "NOTICE: GudhUI requires CGAL, the QGLViewer, OpenGL and Qt5, and will not be compiled.") endif() diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index d1761f47..ed0aace1 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -300,17 +300,24 @@ if(CYTHON_FOUND) # Documentation generation is available through sphinx - requires all modules if(SPHINX_PATH AND NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) + set (GUDHI_SPHINX_MESSAGE "Generating API documentation with Sphinx in ${CMAKE_CURRENT_BINARY_DIR}/sphinx/") + # User warning - Sphinx is a static pages generator, and configured to work fine with user_version + # Images and biblio warnings because not found on developper version + if (GUDHI_CYTHON_PATH STREQUAL "src/cython") + set (GUDHI_SPHINX_MESSAGE "${GUDHI_SPHINX_MESSAGE} \n WARNING : Sphinx is configured for user version, you run it on developper version. Images and biblio will miss") + endif() # sphinx target requires gudhi.so, because conf.py reads gudhi version from it add_custom_target(sphinx WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doc COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" - ${SPHINX_PATH} -b html ${CMAKE_CURRENT_SOURCE_DIR}/doc sphinx - DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/gudhi.so") + ${SPHINX_PATH} -b html ${CMAKE_CURRENT_SOURCE_DIR}/doc ${CMAKE_CURRENT_BINARY_DIR}/sphinx + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/gudhi.so" + COMMENT "${GUDHI_SPHINX_MESSAGE}" VERBATIM) add_test(NAME sphinx_py_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" - ${SPHINX_PATH} -b doctest ${CMAKE_CURRENT_SOURCE_DIR}/doc doctest) + ${SPHINX_PATH} -b doctest ${CMAKE_CURRENT_SOURCE_DIR}/doc ${CMAKE_CURRENT_BINARY_DIR}/doctest) endif(SPHINX_PATH AND NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) endif(CYTHON_FOUND) -- cgit v1.2.3 From 7f7aac2010f5cda05dfd1057827d8deaea186cf5 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 18 Sep 2017 12:58:10 +0000 Subject: Add a function to launch py.test as required for no cache files in sources git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cythonization_improvement@2678 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 92ca1aabcbe276198fa29ea75f763fb0aa3c504f --- src/cython/CMakeLists.txt | 50 +++++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index ed0aace1..ec8589f0 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -15,6 +15,16 @@ function( add_gudhi_cython_lib THE_LIB ) endif(EXISTS ${THE_LIB}) endfunction( add_gudhi_cython_lib ) +# THE_TEST is the python test file name (without .py extension) containing tests functions +function( add_gudhi_py_test THE_TEST ) + # use ${PYTHON_EXECUTABLE} -B, otherwise a __pycache__ directory is created in sources by python + # use py.test no cache provider, otherwise a .cache file is created in sources by py.test + add_test(NAME ${THE_TEST}_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PYTHON_EXECUTABLE} -B -m pytest -p no:cacheprovider ${CMAKE_CURRENT_SOURCE_DIR}/test/${THE_TEST}.py) +endfunction( add_gudhi_py_test ) + + if(CYTHON_FOUND) message("++ ${PYTHON_EXECUTABLE} v.${PYTHON_VERSION_STRING} - Cython is ${CYTHON_EXECUTABLE} - Sphinx is ${SPHINX_PATH}") @@ -173,14 +183,10 @@ if(CYTHON_FOUND) ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/tangential_complex_plain_homology_from_off_file_example.py" --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off) - add_test(NAME test_tangential_complex_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_tangential_complex.py) + add_gudhi_py_test(test_tangential_complex) # Subsampling - add_test(NAME test_subsampling_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_subsampling.py) + add_gudhi_py_test(test_subsampling) endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) if (NOT CGAL_VERSION VERSION_LESS 4.8.1) @@ -190,9 +196,7 @@ if(CYTHON_FOUND) COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/bottleneck_basic_example.py") - add_test(NAME test_bottleneck_distance_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_bottleneck_distance.py) + add_gudhi_py_test(test_bottleneck_distance) endif (NOT CGAL_VERSION VERSION_LESS 4.8.1) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0) @@ -208,9 +212,7 @@ if(CYTHON_FOUND) ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/alpha_complex_diagram_persistence_from_off_file_example.py" --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -a 0.6) - add_test(NAME test_alpha_complex_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_alpha_complex.py) + add_gudhi_py_test(test_alpha_complex) endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0) @@ -228,9 +230,7 @@ if(CYTHON_FOUND) ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py" --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -a 1.0 -n 20 -d 2) - add_test(NAME test_euclidean_witness_complex_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_euclidean_witness_complex.py) + add_gudhi_py_test(test_euclidean_witness_complex) endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.6.0) @@ -247,9 +247,7 @@ if(CYTHON_FOUND) ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/random_cubical_complex_persistence_example.py" 10 10 10) - add_test(NAME test_cubical_complex_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_cubical_complex.py) + add_gudhi_py_test(test_cubical_complex) # Rips add_test(NAME rips_complex_diagram_persistence_from_distance_matrix_file_example_py_test @@ -269,9 +267,7 @@ if(CYTHON_FOUND) COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example/rips_complex_from_points_example.py) - add_test(NAME test_rips_complex_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_rips_complex.py) + add_gudhi_py_test(test_rips_complex) # Simplex tree add_test(NAME simplex_tree_example_py_test @@ -279,9 +275,7 @@ if(CYTHON_FOUND) COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example/simplex_tree_example.py) - add_test(NAME test_simplex_tree_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_simplex_tree.py) + add_gudhi_py_test(test_simplex_tree) # Witness add_test(NAME witness_complex_from_nearest_landmark_table_py_test @@ -289,14 +283,10 @@ if(CYTHON_FOUND) COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example/witness_complex_from_nearest_landmark_table.py) - add_test(NAME test_witness_complex_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_witness_complex.py) + add_gudhi_py_test(test_witness_complex) # Reader utils - add_test(NAME test_reader_utils_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/test/test_reader_utils.py) + add_gudhi_py_test(test_reader_utils) # Documentation generation is available through sphinx - requires all modules if(SPHINX_PATH AND NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) -- cgit v1.2.3 -- cgit v1.2.3 -- cgit v1.2.3 From 18c1daaba21430c54647f4823eec9c7ed52c2878 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 19 Sep 2017 12:09:27 +0000 Subject: Fix memory leak git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/python_memory_leak_fix@2686 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: a8fd65accb5be293e9d3f5fe411225745cb76b0b --- src/cython/include/Rips_complex_interface.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cython/include/Rips_complex_interface.h b/src/cython/include/Rips_complex_interface.h index d06ee4bd..02985727 100644 --- a/src/cython/include/Rips_complex_interface.h +++ b/src/cython/include/Rips_complex_interface.h @@ -71,6 +71,10 @@ class Rips_complex_interface { } } + ~Rips_complex_interface() { + delete rips_complex_; + } + void create_simplex_tree(Simplex_tree_interface<>* simplex_tree, int dim_max) { rips_complex_->create_complex(*simplex_tree, dim_max); simplex_tree->initialize_filtration(); -- cgit v1.2.3 From c9f8ebc4d43d4a861aab1dabc2d31f2f6ed640d2 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 20 Sep 2017 10:45:50 +0000 Subject: Merge modifications for simplex_tree automatic dimension set git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_automatic_dimension_set@2689 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: c18c6316d51f476a795b59c8b870db1aaf0b4591 --- src/Alpha_complex/include/gudhi/Alpha_complex.h | 2 - src/Alpha_complex/test/Alpha_complex_unit_test.cpp | 4 +- .../example/alpha_complex_3d_persistence.cpp | 1 - .../example/exact_alpha_complex_3d_persistence.cpp | 1 - .../periodic_alpha_complex_3d_persistence.cpp | 1 - .../persistence_from_simple_simplex_tree.cpp | 1 - .../example/plain_homology.cpp | 2 - .../example/rips_persistence_step_by_step.cpp | 5 +- .../weighted_alpha_complex_3d_persistence.cpp | 1 - .../test/betti_numbers_unit_test.cpp | 4 - .../test/persistent_cohomology_unit_test.cpp | 2 - src/Simplex_tree/include/gudhi/Simplex_tree.h | 47 ++- src/Simplex_tree/test/CMakeLists.txt | 14 +- src/Simplex_tree/test/README | 2 +- .../test/simplex_tree_remove_unit_test.cpp | 346 +++++++++++++++++++++ src/Simplex_tree/test/simplex_tree_unit_test.cpp | 289 +---------------- .../include/gudhi/Strong_witness_complex.h | 1 - .../include/gudhi/Witness_complex.h | 1 - src/cython/include/Tangential_complex_interface.h | 2 - src/cython/test/test_simplex_tree.py | 11 +- 20 files changed, 421 insertions(+), 316 deletions(-) create mode 100644 src/Simplex_tree/test/simplex_tree_remove_unit_test.cpp diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex.h b/src/Alpha_complex/include/gudhi/Alpha_complex.h index 1ff95c3d..5f7d7622 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex.h @@ -268,8 +268,6 @@ class Alpha_complex { return false; // ----- >> } - complex.set_dimension(triangulation_->maximal_dimension()); - // -------------------------------------------------------------------------------------------- // Simplex_tree construction from loop on triangulation finite full cells list if (triangulation_->number_of_vertices() > 0) { diff --git a/src/Alpha_complex/test/Alpha_complex_unit_test.cpp b/src/Alpha_complex/test/Alpha_complex_unit_test.cpp index 7380547f..166373fe 100644 --- a/src/Alpha_complex/test/Alpha_complex_unit_test.cpp +++ b/src/Alpha_complex/test/Alpha_complex_unit_test.cpp @@ -159,7 +159,7 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_from_points) { BOOST_CHECK(simplex_tree.num_simplices() == 15); std::cout << "simplex_tree.dimension()=" << simplex_tree.dimension() << std::endl; - BOOST_CHECK(simplex_tree.dimension() == 4); + BOOST_CHECK(simplex_tree.dimension() == 3); std::cout << "simplex_tree.num_vertices()=" << simplex_tree.num_vertices() << std::endl; BOOST_CHECK(simplex_tree.num_vertices() == 4); @@ -232,7 +232,7 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_from_points) { BOOST_CHECK(simplex_tree.num_simplices() == 10); std::cout << "simplex_tree.dimension()=" << simplex_tree.dimension() << std::endl; - BOOST_CHECK(simplex_tree.dimension() == 4); + BOOST_CHECK(simplex_tree.dimension() == 1); std::cout << "simplex_tree.num_vertices()=" << simplex_tree.num_vertices() << std::endl; BOOST_CHECK(simplex_tree.num_vertices() == 4); diff --git a/src/Persistent_cohomology/example/alpha_complex_3d_persistence.cpp b/src/Persistent_cohomology/example/alpha_complex_3d_persistence.cpp index fd227b82..40eb3576 100644 --- a/src/Persistent_cohomology/example/alpha_complex_3d_persistence.cpp +++ b/src/Persistent_cohomology/example/alpha_complex_3d_persistence.cpp @@ -203,7 +203,6 @@ int main(int argc, char * const argv[]) { std::cout << "This shall not happen" << std::endl; } simplex_tree.set_filtration(filtration_max); - simplex_tree.set_dimension(dim_max); #ifdef DEBUG_TRACES std::cout << "vertices \t\t" << count_vertices << std::endl; diff --git a/src/Persistent_cohomology/example/exact_alpha_complex_3d_persistence.cpp b/src/Persistent_cohomology/example/exact_alpha_complex_3d_persistence.cpp index 8a335075..9881debf 100644 --- a/src/Persistent_cohomology/example/exact_alpha_complex_3d_persistence.cpp +++ b/src/Persistent_cohomology/example/exact_alpha_complex_3d_persistence.cpp @@ -205,7 +205,6 @@ int main(int argc, char * const argv[]) { std::cout << "This shall not happen" << std::endl; } simplex_tree.set_filtration(filtration_max); - simplex_tree.set_dimension(dim_max); #ifdef DEBUG_TRACES std::cout << "vertices \t\t" << count_vertices << std::endl; diff --git a/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp b/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp index 8928cfc2..71faebd7 100644 --- a/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp +++ b/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp @@ -222,7 +222,6 @@ int main(int argc, char * const argv[]) { std::cout << "This shall not happen" << std::endl; } simplex_tree.set_filtration(filtration_max); - simplex_tree.set_dimension(dim_max); #ifdef DEBUG_TRACES std::cout << "vertices \t\t" << count_vertices << std::endl; diff --git a/src/Persistent_cohomology/example/persistence_from_simple_simplex_tree.cpp b/src/Persistent_cohomology/example/persistence_from_simple_simplex_tree.cpp index 7ca9410a..7809d5ff 100644 --- a/src/Persistent_cohomology/example/persistence_from_simple_simplex_tree.cpp +++ b/src/Persistent_cohomology/example/persistence_from_simple_simplex_tree.cpp @@ -142,7 +142,6 @@ int main(int argc, char * const argv[]) { /* An edge [11,6] */ /* An edge [10,12,2] */ - st.set_dimension(2); st.set_filtration(0.4); std::cout << "The complex contains " << st.num_simplices() << " simplices - " << st.num_vertices() << " vertices " diff --git a/src/Persistent_cohomology/example/plain_homology.cpp b/src/Persistent_cohomology/example/plain_homology.cpp index 50f692f2..a5ae09c8 100644 --- a/src/Persistent_cohomology/example/plain_homology.cpp +++ b/src/Persistent_cohomology/example/plain_homology.cpp @@ -64,8 +64,6 @@ int main() { st.insert_simplex_and_subfaces(edge03); st.insert_simplex(edge13); st.insert_simplex(vertex4); - // FIXME: Remove this line - st.set_dimension(2); // Sort the simplices in the order of the filtration st.initialize_filtration(); diff --git a/src/Persistent_cohomology/example/rips_persistence_step_by_step.cpp b/src/Persistent_cohomology/example/rips_persistence_step_by_step.cpp index 554eeba6..75580aac 100644 --- a/src/Persistent_cohomology/example/rips_persistence_step_by_step.cpp +++ b/src/Persistent_cohomology/example/rips_persistence_step_by_step.cpp @@ -88,6 +88,9 @@ int main(int argc, char * argv[]) { Simplex_tree st; // insert the proximity graph in the simplex tree st.insert_graph(prox_graph); + std::cout << "The complex contains " << st.num_simplices() << " simplices \n"; + std::cout << " and has dimension " << st.dimension() << " \n"; +/* // expand the graph until dimension dim_max st.expansion(dim_max); @@ -112,7 +115,7 @@ int main(int argc, char * argv[]) { pcoh.output_diagram(out); out.close(); } - +*/ return 0; } diff --git a/src/Persistent_cohomology/example/weighted_alpha_complex_3d_persistence.cpp b/src/Persistent_cohomology/example/weighted_alpha_complex_3d_persistence.cpp index 34b90933..968db753 100644 --- a/src/Persistent_cohomology/example/weighted_alpha_complex_3d_persistence.cpp +++ b/src/Persistent_cohomology/example/weighted_alpha_complex_3d_persistence.cpp @@ -223,7 +223,6 @@ int main(int argc, char * const argv[]) { std::cout << "This shall not happen" << std::endl; } simplex_tree.set_filtration(filtration_max); - simplex_tree.set_dimension(dim_max); #ifdef DEBUG_TRACES std::cout << "vertices \t\t" << count_vertices << std::endl; diff --git a/src/Persistent_cohomology/test/betti_numbers_unit_test.cpp b/src/Persistent_cohomology/test/betti_numbers_unit_test.cpp index da418034..0a08d200 100644 --- a/src/Persistent_cohomology/test/betti_numbers_unit_test.cpp +++ b/src/Persistent_cohomology/test/betti_numbers_unit_test.cpp @@ -62,8 +62,6 @@ BOOST_AUTO_TEST_CASE( plain_homology_betti_numbers ) st.insert_simplex_and_subfaces(edge04); st.insert_simplex(edge14); st.insert_simplex(vertex5); - // FIXME: Remove this line - st.set_dimension(3); // Sort the simplices in the order of the filtration st.initialize_filtration(); @@ -170,8 +168,6 @@ BOOST_AUTO_TEST_CASE( betti_numbers ) st.insert_simplex_and_subfaces(edge04, 2.0); st.insert_simplex(edge14, 2.0); st.insert_simplex(vertex5, 1.0); - // FIXME: Remove this line - st.set_dimension(3); // Sort the simplices in the order of the filtration st.initialize_filtration(); diff --git a/src/Persistent_cohomology/test/persistent_cohomology_unit_test.cpp b/src/Persistent_cohomology/test/persistent_cohomology_unit_test.cpp index f8174020..887aa25f 100644 --- a/src/Persistent_cohomology/test/persistent_cohomology_unit_test.cpp +++ b/src/Persistent_cohomology/test/persistent_cohomology_unit_test.cpp @@ -197,8 +197,6 @@ BOOST_AUTO_TEST_CASE( persistence_constructor_exception ) // To make number of simplices = 255 const short simplex_0[] = {0, 1, 2, 3, 4, 5, 6, 7}; st.insert_simplex_and_subfaces(simplex_0); - // FIXME: Remove this line - st.set_dimension(8); // Sort the simplices in the order of the filtration st.initialize_filtration(); diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 317bce23..478ed80f 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -601,7 +601,11 @@ class Simplex_tree { // if filtration value unchanged return std::pair(null_simplex(), false); } - // otherwise the insertion has succeeded + // otherwise the insertion has succeeded - size is a size_type + if (static_cast(simplex.size()) - 1 > dimension_) { + // Update dimension if needed + dimension_ = static_cast(simplex.size()) - 1; + } return res_insert; } @@ -1159,7 +1163,11 @@ class Simplex_tree { * complex has changed , please call `initialize_filtration()` to recompute it. */ bool prune_above_filtration(Filtration_value filtration) { - return rec_prune_above_filtration(root(), filtration); + bool modified = rec_prune_above_filtration(root(), filtration); + if (modified) { + auto_dimension_set(dimension()); + } + return modified; } private: @@ -1187,6 +1195,33 @@ class Simplex_tree { return modified; } + private: + /** \brief Resets the Simplex_tree dimension. + * @param[in] old_dimension The former dimension value until the loop stopped when it is reached. + * @return The dimension modification information. + * \pre Please check the simplex has not a too low dimension value. + * This cannot happen if set_dimension has not been performed. + */ + bool auto_dimension_set(int old_dimension) { + int new_dimension = -1; + for (Simplex_handle sh : skeleton_simplex_range(old_dimension)) { +#ifdef DEBUG_TRACES + for (auto vertex : simplex_vertex_range(sh)) { + std::cout << " " << vertex; + } + std::cout << std::endl; +#endif // DEBUG_TRACES + + int sh_dimension = dimension(sh); + if (sh_dimension >= old_dimension) + return false; + new_dimension = std::max(new_dimension, sh_dimension); + } + set_dimension(new_dimension); + return true; + } + + public: /** \brief Remove a maximal simplex. * @param[in] sh Simplex handle on the maximal simplex to remove. @@ -1207,9 +1242,17 @@ class Simplex_tree { // Special case when child is the root of the simplex tree, just remove it from members child->erase(sh); } else { + // Keep information before remove action + int sh_dim = dimension(sh); + // Sibling is emptied : must be deleted, and its parent must point on his own Sibling child->oncles()->members().at(child->parent()).assign_children(child->oncles()); delete child; + + // No need to reset dimension in case maximal simplex is not the maximal dimension one + if (sh_dim >= dimension()) { + auto_dimension_set(sh_dim); + } } } diff --git a/src/Simplex_tree/test/CMakeLists.txt b/src/Simplex_tree/test/CMakeLists.txt index 81999de6..1c169ff7 100644 --- a/src/Simplex_tree/test/CMakeLists.txt +++ b/src/Simplex_tree/test/CMakeLists.txt @@ -3,13 +3,21 @@ project(Simplex_tree_tests) include(GUDHI_test_coverage) +# Do not forget to copy test files in current binary dir +file(COPY "simplex_tree_for_unit_test.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) + add_executable ( Simplex_tree_test_unit simplex_tree_unit_test.cpp ) target_link_libraries(Simplex_tree_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Simplex_tree_test_unit ${TBB_LIBRARIES}) endif() -# Do not forget to copy test files in current binary dir -file(COPY "simplex_tree_for_unit_test.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) - gudhi_add_coverage_test(Simplex_tree_test_unit) + +add_executable ( Simplex_tree_remove_test_unit simplex_tree_remove_unit_test.cpp ) +target_link_libraries(Simplex_tree_remove_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +if (TBB_FOUND) + target_link_libraries(Simplex_tree_remove_test_unit ${TBB_LIBRARIES}) +endif() + +gudhi_add_coverage_test(Simplex_tree_remove_test_unit) diff --git a/src/Simplex_tree/test/README b/src/Simplex_tree/test/README index 21c3d871..df2ab89a 100644 --- a/src/Simplex_tree/test/README +++ b/src/Simplex_tree/test/README @@ -9,6 +9,6 @@ make To launch with details: *********************** -./SimplexTreeUT --report_level=detailed --log_level=all +./Simplex_tree_test_unit --report_level=detailed --log_level=all ==> echo $? returns 0 in case of success (non-zero otherwise) diff --git a/src/Simplex_tree/test/simplex_tree_remove_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_remove_unit_test.cpp new file mode 100644 index 00000000..ad71fed3 --- /dev/null +++ b/src/Simplex_tree/test/simplex_tree_remove_unit_test.cpp @@ -0,0 +1,346 @@ +#include + +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MODULE "simplex_tree_remove" +#include +#include + +// ^ +// /!\ Nothing else from Simplex_tree shall be included to test includes are well defined. +#include "gudhi/Simplex_tree.h" + +using namespace Gudhi; + +struct MyOptions : Simplex_tree_options_full_featured { + // Not doing persistence, so we don't need those + static const bool store_key = false; + static const bool store_filtration = false; + // I have few vertices + typedef short Vertex_handle; +}; + +using Mini_stree = Simplex_tree; +using Stree = Simplex_tree<>; + +BOOST_AUTO_TEST_CASE(remove_maximal_simplex) { + std::cout << "********************************************************************" << std::endl; + std::cout << "REMOVE MAXIMAL SIMPLEX" << std::endl; + + Mini_stree st; + + st.insert_simplex_and_subfaces({0, 1, 6, 7}); + st.insert_simplex_and_subfaces({3, 4, 5}); + + // Constructs a copy at this state for further test purpose + Mini_stree st_pruned = st; + + st.insert_simplex_and_subfaces({3, 0}); + st.insert_simplex_and_subfaces({2, 1, 0}); + + // Constructs a copy at this state for further test purpose + Mini_stree st_complete = st; + // st_complete and st: + // 1 6 + // o---o + // /X\7/ + // o---o---o---o + // 2 0 3\X/4 + // o + // 5 + // st_pruned: + // 1 6 + // o---o + // \7/ + // o o---o + // 0 3\X/4 + // o + // 5 + +#ifdef GUDHI_DEBUG + std::cout << "Check exception throw in debug mode" << std::endl; + // throw excpt because sh has children + BOOST_CHECK_THROW (st.remove_maximal_simplex(st.find({0, 1, 6})), std::invalid_argument); + BOOST_CHECK_THROW (st.remove_maximal_simplex(st.find({3})), std::invalid_argument); + BOOST_CHECK(st == st_complete); +#endif + std::cout << "st.remove_maximal_simplex({0, 2})" << std::endl; + st.remove_maximal_simplex(st.find({0, 2})); + std::cout << "st.remove_maximal_simplex({0, 1, 2})" << std::endl; + st.remove_maximal_simplex(st.find({0, 1, 2})); + std::cout << "st.remove_maximal_simplex({1, 2})" << std::endl; + st.remove_maximal_simplex(st.find({1, 2})); + std::cout << "st.remove_maximal_simplex({2})" << std::endl; + st.remove_maximal_simplex(st.find({2})); + std::cout << "st.remove_maximal_simplex({3})" << std::endl; + st.remove_maximal_simplex(st.find({0, 3})); + + BOOST_CHECK(st == st_pruned); + // Remove all, but as the simplex tree is not storing filtration, there is no modification + st.prune_above_filtration(0.0); + BOOST_CHECK(st == st_pruned); + + Mini_stree st_wo_seven; + + st_wo_seven.insert_simplex_and_subfaces({0, 1, 6}); + st_wo_seven.insert_simplex_and_subfaces({3, 4, 5}); + // st_wo_seven: + // 1 6 + // o---o + // \X/ + // o o---o + // 0 3\X/4 + // o + // 5 + + // Remove all 7 to test the both remove_maximal_simplex cases (when _members is empty or not) + std::cout << "st.remove_maximal_simplex({0, 1, 6, 7})" << std::endl; + st.remove_maximal_simplex(st.find({0, 1, 6, 7})); + std::cout << "st.remove_maximal_simplex({0, 1, 7})" << std::endl; + st.remove_maximal_simplex(st.find({0, 1, 7})); + std::cout << "st.remove_maximal_simplex({0, 6, 7})" << std::endl; + st.remove_maximal_simplex(st.find({0, 6, 7})); + std::cout << "st.remove_maximal_simplex({0, 7})" << std::endl; + st.remove_maximal_simplex(st.find({0, 7})); + std::cout << "st.remove_maximal_simplex({1, 6, 7})" << std::endl; + st.remove_maximal_simplex(st.find({1, 6, 7})); + std::cout << "st.remove_maximal_simplex({1, 7})" << std::endl; + st.remove_maximal_simplex(st.find({1, 7})); + std::cout << "st.remove_maximal_simplex({6, 7})" << std::endl; + st.remove_maximal_simplex(st.find({6, 7})); + std::cout << "st.remove_maximal_simplex({7})" << std::endl; + st.remove_maximal_simplex(st.find({7})); + + std::cout << "st.dimension()=" << st.dimension() << " | st_wo_seven.dimension()=" << st_wo_seven.dimension() << std::endl; + BOOST_CHECK(st == st_wo_seven); +} + +BOOST_AUTO_TEST_CASE(auto_dimension_set) { + std::cout << "********************************************************************" << std::endl; + std::cout << "DIMENSION ON REMOVE MAXIMAL SIMPLEX" << std::endl; + + Mini_stree st; + + st.insert_simplex_and_subfaces({0, 1, 2}); + st.insert_simplex_and_subfaces({0, 1, 3}); + st.insert_simplex_and_subfaces({1, 2, 3, 4}); + st.insert_simplex_and_subfaces({1, 2, 3, 5}); + st.insert_simplex_and_subfaces({6, 7, 8, 9}); + st.insert_simplex_and_subfaces({6, 7, 8, 10}); + + BOOST_CHECK(st.dimension() == 3); + + std::cout << "st.remove_maximal_simplex({6, 7, 8, 10})" << std::endl; + st.remove_maximal_simplex(st.find({6, 7, 8, 10})); + BOOST_CHECK(st.dimension() == 3); + + std::cout << "st.remove_maximal_simplex({6, 7, 8, 9})" << std::endl; + st.remove_maximal_simplex(st.find({6, 7, 8, 9})); + BOOST_CHECK(st.dimension() == 3); + + std::cout << "st.remove_maximal_simplex({1, 2, 3, 4})" << std::endl; + st.remove_maximal_simplex(st.find({1, 2, 3, 4})); + BOOST_CHECK(st.dimension() == 3); + + std::cout << "st.remove_maximal_simplex({1, 2, 3, 5})" << std::endl; + st.remove_maximal_simplex(st.find({1, 2, 3, 5})); + BOOST_CHECK(st.dimension() == 2); + + std::cout << "st.insert_simplex_and_subfaces({1, 2, 3, 5})" << std::endl; + st.insert_simplex_and_subfaces({1, 2, 3, 5}); + BOOST_CHECK(st.dimension() == 3); + + std::cout << "st.insert_simplex_and_subfaces({1, 2, 3, 4})" << std::endl; + st.insert_simplex_and_subfaces({1, 2, 3, 4}); + BOOST_CHECK(st.dimension() == 3); + + std::cout << "st.remove_maximal_simplex({1, 2, 3, 5})" << std::endl; + st.remove_maximal_simplex(st.find({1, 2, 3, 5})); + BOOST_CHECK(st.dimension() == 3); + + std::cout << "st.remove_maximal_simplex({1, 2, 3, 4})" << std::endl; + st.remove_maximal_simplex(st.find({1, 2, 3, 4})); + BOOST_CHECK(st.dimension() == 2); + + std::cout << "st.insert_simplex_and_subfaces({0, 1, 3, 4})" << std::endl; + st.insert_simplex_and_subfaces({0, 1, 3, 4}); + BOOST_CHECK(st.dimension() == 3); + + std::cout << "st.remove_maximal_simplex({0, 1, 3, 4})" << std::endl; + st.remove_maximal_simplex(st.find({0, 1, 3, 4})); + BOOST_CHECK(st.dimension() == 2); + + std::cout << "st.insert_simplex_and_subfaces({0, 1, 2, 3, 4, 5, 6})" << std::endl; + st.insert_simplex_and_subfaces({0, 1, 2, 3, 4, 5, 6}); + BOOST_CHECK(st.dimension() == 6); + + std::cout << "st.remove_maximal_simplex({0, 1, 2, 3, 4, 5, 6})" << std::endl; + st.remove_maximal_simplex(st.find({0, 1, 2, 3, 4, 5, 6})); + BOOST_CHECK(st.dimension() == 5); + +} + +BOOST_AUTO_TEST_CASE(prune_above_filtration) { + std::cout << "********************************************************************" << std::endl; + std::cout << "PRUNE ABOVE FILTRATION" << std::endl; + + Stree st; + + st.insert_simplex_and_subfaces({0, 1, 6, 7}, 1.0); + st.insert_simplex_and_subfaces({3, 4, 5}, 2.0); + + // Constructs a copy at this state for further test purpose + Stree st_pruned = st; + st_pruned.initialize_filtration(); // reset + + st.insert_simplex_and_subfaces({3, 0}, 3.0); + st.insert_simplex_and_subfaces({2, 1, 0}, 4.0); + + // Constructs a copy at this state for further test purpose + Stree st_complete = st; + // st_complete and st: + // 1 6 + // o---o + // /X\7/ + // o---o---o---o + // 2 0 3\X/4 + // o + // 5 + // st_pruned: + // 1 6 + // o---o + // \7/ + // o o---o + // 0 3\X/4 + // o + // 5 + + bool simplex_is_changed = false; + // Check the no action cases + // greater than initial filtration value + simplex_is_changed = st.prune_above_filtration(10.0); + if (simplex_is_changed) + st.initialize_filtration(); + BOOST_CHECK(st == st_complete); + BOOST_CHECK(!simplex_is_changed); + // equal to initial filtration value + simplex_is_changed = st.prune_above_filtration(6.0); + if (simplex_is_changed) + st.initialize_filtration(); + BOOST_CHECK(st == st_complete); + BOOST_CHECK(!simplex_is_changed); + // lower than initial filtration value, but still greater than the maximum filtration value + simplex_is_changed = st.prune_above_filtration(5.0); + if (simplex_is_changed) + st.initialize_filtration(); + BOOST_CHECK(st == st_complete); + BOOST_CHECK(!simplex_is_changed); + + // Display the Simplex_tree + std::cout << "The complex contains " << st.num_simplices() << " simplices"; + std::cout << " - dimension " << st.dimension() << std::endl; + std::cout << "Iterator on Simplices in the filtration, with [filtration value]:" << std::endl; + for (auto f_simplex : st.filtration_simplex_range()) { + std::cout << " " << "[" << st.filtration(f_simplex) << "] "; + for (auto vertex : st.simplex_vertex_range(f_simplex)) { + std::cout << (int) vertex << " "; + } + std::cout << std::endl; + } + + // Check the pruned cases + simplex_is_changed = st.prune_above_filtration(2.5); + if (simplex_is_changed) + st.initialize_filtration(); + BOOST_CHECK(st == st_pruned); + BOOST_CHECK(simplex_is_changed); + + // Display the Simplex_tree + std::cout << "The complex pruned at 2.5 contains " << st.num_simplices() << " simplices"; + std::cout << " - dimension " << st.dimension() << std::endl; + + simplex_is_changed = st.prune_above_filtration(2.0); + if (simplex_is_changed) + st.initialize_filtration(); + + std::cout << "The complex pruned at 2.0 contains " << st.num_simplices() << " simplices"; + std::cout << " - dimension " << st.dimension() << std::endl; + + BOOST_CHECK(st == st_pruned); + BOOST_CHECK(!simplex_is_changed); + + Stree st_empty; + simplex_is_changed = st.prune_above_filtration(0.0); + if (simplex_is_changed) + st.initialize_filtration(); + + // Display the Simplex_tree + std::cout << "The complex pruned at 0.0 contains " << st.num_simplices() << " simplices"; + std::cout << " - dimension " << st.dimension() << std::endl; + + BOOST_CHECK(st == st_empty); + BOOST_CHECK(simplex_is_changed); + + // Test case to the limit + simplex_is_changed = st.prune_above_filtration(-1.0); + if (simplex_is_changed) + st.initialize_filtration(); + BOOST_CHECK(st == st_empty); + BOOST_CHECK(!simplex_is_changed); +} + +BOOST_AUTO_TEST_CASE(mini_prune_above_filtration) { + std::cout << "********************************************************************" << std::endl; + std::cout << "MINI PRUNE ABOVE FILTRATION" << std::endl; + + Mini_stree st; + + st.insert_simplex_and_subfaces({0, 1, 6, 7}); + st.insert_simplex_and_subfaces({3, 4, 5}); + st.insert_simplex_and_subfaces({3, 0}); + st.insert_simplex_and_subfaces({2, 1, 0}); + + // st: + // 1 6 + // o---o + // /X\7/ + // o---o---o---o + // 2 0 3\X/4 + // o + // 5 + + st.initialize_filtration(); + + // Display the Simplex_tree + std::cout << "The complex contains " << st.num_simplices() << " simplices" << std::endl; + BOOST_CHECK(st.num_simplices() == 27); + + // Test case to the limit - With these options, there is no filtration, which means filtration is 0 + bool simplex_is_changed = st.prune_above_filtration(1.0); + if (simplex_is_changed) + st.initialize_filtration(); + // Display the Simplex_tree + std::cout << "The complex pruned at 1.0 contains " << st.num_simplices() << " simplices" << std::endl; + BOOST_CHECK(!simplex_is_changed); + BOOST_CHECK(st.num_simplices() == 27); + + simplex_is_changed = st.prune_above_filtration(0.0); + if (simplex_is_changed) + st.initialize_filtration(); + // Display the Simplex_tree + std::cout << "The complex pruned at 0.0 contains " << st.num_simplices() << " simplices" << std::endl; + BOOST_CHECK(!simplex_is_changed); + BOOST_CHECK(st.num_simplices() == 27); + + // Test case to the limit + simplex_is_changed = st.prune_above_filtration(-1.0); + if (simplex_is_changed) + st.initialize_filtration(); + // Display the Simplex_tree + std::cout << "The complex pruned at -1.0 contains " << st.num_simplices() << " simplices" << std::endl; + BOOST_CHECK(simplex_is_changed); + BOOST_CHECK(st.num_simplices() == 0); + + // Display the Simplex_tree + std::cout << "The complex contains " << st.num_simplices() << " simplices" << std::endl; + +} diff --git a/src/Simplex_tree/test/simplex_tree_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_unit_test.cpp index b06d7ec9..7323aa6c 100644 --- a/src/Simplex_tree/test/simplex_tree_unit_test.cpp +++ b/src/Simplex_tree/test/simplex_tree_unit_test.cpp @@ -148,16 +148,9 @@ void test_simplex_tree_insert_returns_true(const typePairSimplexBool& returnValu // Global variables double max_fil = 0.0; -int dim_max = -1; template void set_and_test_simplex_tree_dim_fil(typeST& simplexTree, int vectorSize, const Filtration_value& fil) { - if (vectorSize > dim_max + 1) { - dim_max = vectorSize - 1; - simplexTree.set_dimension(dim_max); - std::cout << " set_and_test_simplex_tree_dim_fil - dim_max=" << dim_max - << std::endl; - } if (fil > max_fil) { max_fil = fil; simplexTree.set_filtration(max_fil); @@ -165,7 +158,7 @@ void set_and_test_simplex_tree_dim_fil(typeST& simplexTree, int vectorSize, cons << std::endl; } - BOOST_CHECK(simplexTree.dimension() == dim_max); + BOOST_CHECK(simplexTree.dimension() >= vectorSize - 1); BOOST_CHECK(AreAlmostTheSame(simplexTree.filtration(), max_fil)); // Another way to count simplices: @@ -189,7 +182,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_insertion, typeST, list_of_tested_var const Filtration_value THIRD_FILTRATION_VALUE = 0.3; const Filtration_value FOURTH_FILTRATION_VALUE = 0.4; // reset since we run the test several times - dim_max = -1; max_fil = 0.0; // TEST OF INSERTION @@ -308,8 +300,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_insertion, typeST, list_of_tested_var // Simplex_handle = boost::container::flat_map< typeST::Vertex_handle, Node >::iterator typename typeST::Simplex_handle shReturned = returnValue.first; BOOST_CHECK(shReturned == typename typeST::Simplex_handle(nullptr)); + std::cout << "st.num_vertices()=" << st.num_vertices() << std::endl; BOOST_CHECK(st.num_vertices() == (size_t) 4); // Not incremented !! - BOOST_CHECK(st.dimension() == dim_max); BOOST_CHECK(AreAlmostTheSame(st.filtration(), max_fil)); // ++ ELEVENTH @@ -324,7 +316,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_insertion, typeST, list_of_tested_var shReturned = returnValue.first; BOOST_CHECK(shReturned == typename typeST::Simplex_handle(nullptr)); BOOST_CHECK(st.num_vertices() == (size_t) 4); // Not incremented !! - BOOST_CHECK(st.dimension() == dim_max); + std::cout << " - INSERT (2,1,0) (already inserted)" << std::endl; + BOOST_CHECK(st.dimension() == 2); BOOST_CHECK(AreAlmostTheSame(st.filtration(), max_fil)); /* Inserted simplex: */ @@ -630,9 +623,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(coface_on_simplex_tree, typeST, list_of_tested_var /* o */ /* 5 */ - // FIXME - st.set_dimension(3); - std::vector simplex_result; std::vector result; std::cout << "First test - Star of (3):" << std::endl; @@ -729,9 +719,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(copy_move_on_simplex_tree, typeST, list_of_tested_ /* o */ /* 5 */ - // FIXME - st.set_dimension(3); - std::cout << "Printing st - address = " << &st << std::endl; // Copy constructor @@ -882,271 +869,3 @@ BOOST_AUTO_TEST_CASE(make_filtration_non_decreasing) { BOOST_CHECK(st == st_other_copy); } - -struct MyOptions : Simplex_tree_options_full_featured { - // Not doing persistence, so we don't need those - static const bool store_key = false; - static const bool store_filtration = false; - // I have few vertices - typedef short Vertex_handle; -}; - -BOOST_AUTO_TEST_CASE(remove_maximal_simplex) { - std::cout << "********************************************************************" << std::endl; - std::cout << "REMOVE MAXIMAL SIMPLEX" << std::endl; - - - typedef Simplex_tree miniST; - miniST st; - - // FIXME - st.set_dimension(3); - - st.insert_simplex_and_subfaces({0, 1, 6, 7}); - st.insert_simplex_and_subfaces({3, 4, 5}); - - // Constructs a copy at this state for further test purpose - miniST st_pruned = st; - - st.insert_simplex_and_subfaces({3, 0}); - st.insert_simplex_and_subfaces({2, 1, 0}); - - // Constructs a copy at this state for further test purpose - miniST st_complete = st; - // st_complete and st: - // 1 6 - // o---o - // /X\7/ - // o---o---o---o - // 2 0 3\X/4 - // o - // 5 - // st_pruned: - // 1 6 - // o---o - // \7/ - // o o---o - // 0 3\X/4 - // o - // 5 - -#ifdef GUDHI_DEBUG - std::cout << "Check exception throw in debug mode" << std::endl; - // throw excpt because sh has children - BOOST_CHECK_THROW (st.remove_maximal_simplex(st.find({0, 1, 6})), std::invalid_argument); - BOOST_CHECK_THROW (st.remove_maximal_simplex(st.find({3})), std::invalid_argument); - BOOST_CHECK(st == st_complete); -#endif - - st.remove_maximal_simplex(st.find({0, 2})); - st.remove_maximal_simplex(st.find({0, 1, 2})); - st.remove_maximal_simplex(st.find({1, 2})); - st.remove_maximal_simplex(st.find({2})); - st.remove_maximal_simplex(st.find({0, 3})); - - BOOST_CHECK(st == st_pruned); - // Remove all, but as the simplex tree is not storing filtration, there is no modification - st.prune_above_filtration(0.0); - BOOST_CHECK(st == st_pruned); - - miniST st_wo_seven; - // FIXME - st_wo_seven.set_dimension(3); - - st_wo_seven.insert_simplex_and_subfaces({0, 1, 6}); - st_wo_seven.insert_simplex_and_subfaces({3, 4, 5}); - // st_wo_seven: - // 1 6 - // o---o - // \X/ - // o o---o - // 0 3\X/4 - // o - // 5 - - // Remove all 7 to test the both remove_maximal_simplex cases (when _members is empty or not) - st.remove_maximal_simplex(st.find({0, 1, 6, 7})); - st.remove_maximal_simplex(st.find({0, 1, 7})); - st.remove_maximal_simplex(st.find({0, 6, 7})); - st.remove_maximal_simplex(st.find({0, 7})); - st.remove_maximal_simplex(st.find({1, 6, 7})); - st.remove_maximal_simplex(st.find({1, 7})); - st.remove_maximal_simplex(st.find({6, 7})); - st.remove_maximal_simplex(st.find({7})); - - BOOST_CHECK(st == st_wo_seven); -} - -BOOST_AUTO_TEST_CASE(prune_above_filtration) { - std::cout << "********************************************************************" << std::endl; - std::cout << "PRUNE ABOVE FILTRATION" << std::endl; - typedef Simplex_tree<> typeST; - typeST st; - - // FIXME - st.set_dimension(3); - - st.insert_simplex_and_subfaces({0, 1, 6, 7}, 1.0); - st.insert_simplex_and_subfaces({3, 4, 5}, 2.0); - - // Constructs a copy at this state for further test purpose - typeST st_pruned = st; - st_pruned.initialize_filtration(); // reset - - st.insert_simplex_and_subfaces({3, 0}, 3.0); - st.insert_simplex_and_subfaces({2, 1, 0}, 4.0); - - // Constructs a copy at this state for further test purpose - typeST st_complete = st; - // st_complete and st: - // 1 6 - // o---o - // /X\7/ - // o---o---o---o - // 2 0 3\X/4 - // o - // 5 - // st_pruned: - // 1 6 - // o---o - // \7/ - // o o---o - // 0 3\X/4 - // o - // 5 - - bool simplex_is_changed = false; - // Check the no action cases - // greater than initial filtration value - simplex_is_changed = st.prune_above_filtration(10.0); - if (simplex_is_changed) - st.initialize_filtration(); - BOOST_CHECK(st == st_complete); - BOOST_CHECK(!simplex_is_changed); - // equal to initial filtration value - simplex_is_changed = st.prune_above_filtration(6.0); - if (simplex_is_changed) - st.initialize_filtration(); - BOOST_CHECK(st == st_complete); - BOOST_CHECK(!simplex_is_changed); - // lower than initial filtration value, but still greater than the maximum filtration value - simplex_is_changed = st.prune_above_filtration(5.0); - if (simplex_is_changed) - st.initialize_filtration(); - BOOST_CHECK(st == st_complete); - BOOST_CHECK(!simplex_is_changed); - - // Display the Simplex_tree - std::cout << "The complex contains " << st.num_simplices() << " simplices"; - std::cout << " - dimension " << st.dimension() << std::endl; - std::cout << "Iterator on Simplices in the filtration, with [filtration value]:" << std::endl; - for (auto f_simplex : st.filtration_simplex_range()) { - std::cout << " " << "[" << st.filtration(f_simplex) << "] "; - for (auto vertex : st.simplex_vertex_range(f_simplex)) { - std::cout << (int) vertex << " "; - } - std::cout << std::endl; - } - - // Check the pruned cases - simplex_is_changed = st.prune_above_filtration(2.5); - if (simplex_is_changed) - st.initialize_filtration(); - BOOST_CHECK(st == st_pruned); - BOOST_CHECK(simplex_is_changed); - - // Display the Simplex_tree - std::cout << "The complex pruned at 2.5 contains " << st.num_simplices() << " simplices"; - std::cout << " - dimension " << st.dimension() << std::endl; - - simplex_is_changed = st.prune_above_filtration(2.0); - if (simplex_is_changed) - st.initialize_filtration(); - - std::cout << "The complex pruned at 2.0 contains " << st.num_simplices() << " simplices"; - std::cout << " - dimension " << st.dimension() << std::endl; - - BOOST_CHECK(st == st_pruned); - BOOST_CHECK(!simplex_is_changed); - - typeST st_empty; - // FIXME - st_empty.set_dimension(3); - simplex_is_changed = st.prune_above_filtration(0.0); - if (simplex_is_changed) - st.initialize_filtration(); - - // Display the Simplex_tree - std::cout << "The complex pruned at 0.0 contains " << st.num_simplices() << " simplices"; - std::cout << " - dimension " << st.dimension() << std::endl; - - BOOST_CHECK(st == st_empty); - BOOST_CHECK(simplex_is_changed); - - // Test case to the limit - simplex_is_changed = st.prune_above_filtration(-1.0); - if (simplex_is_changed) - st.initialize_filtration(); - BOOST_CHECK(st == st_empty); - BOOST_CHECK(!simplex_is_changed); -} - -BOOST_AUTO_TEST_CASE(mini_prune_above_filtration) { - std::cout << "********************************************************************" << std::endl; - std::cout << "MINI PRUNE ABOVE FILTRATION" << std::endl; - typedef Simplex_tree typeST; - typeST st; - - // FIXME - st.set_dimension(3); - - st.insert_simplex_and_subfaces({0, 1, 6, 7}); - st.insert_simplex_and_subfaces({3, 4, 5}); - st.insert_simplex_and_subfaces({3, 0}); - st.insert_simplex_and_subfaces({2, 1, 0}); - - // st: - // 1 6 - // o---o - // /X\7/ - // o---o---o---o - // 2 0 3\X/4 - // o - // 5 - - st.initialize_filtration(); - - // Display the Simplex_tree - std::cout << "The complex contains " << st.num_simplices() << " simplices" << std::endl; - BOOST_CHECK(st.num_simplices() == 27); - - // Test case to the limit - With these options, there is no filtration, which means filtration is 0 - bool simplex_is_changed = st.prune_above_filtration(1.0); - if (simplex_is_changed) - st.initialize_filtration(); - // Display the Simplex_tree - std::cout << "The complex pruned at 1.0 contains " << st.num_simplices() << " simplices" << std::endl; - BOOST_CHECK(!simplex_is_changed); - BOOST_CHECK(st.num_simplices() == 27); - - simplex_is_changed = st.prune_above_filtration(0.0); - if (simplex_is_changed) - st.initialize_filtration(); - // Display the Simplex_tree - std::cout << "The complex pruned at 0.0 contains " << st.num_simplices() << " simplices" << std::endl; - BOOST_CHECK(!simplex_is_changed); - BOOST_CHECK(st.num_simplices() == 27); - - // Test case to the limit - simplex_is_changed = st.prune_above_filtration(-1.0); - if (simplex_is_changed) - st.initialize_filtration(); - // Display the Simplex_tree - std::cout << "The complex pruned at -1.0 contains " << st.num_simplices() << " simplices" << std::endl; - BOOST_CHECK(simplex_is_changed); - BOOST_CHECK(st.num_simplices() == 0); - - // Display the Simplex_tree - std::cout << "The complex contains " << st.num_simplices() << " simplices" << std::endl; - -} \ No newline at end of file diff --git a/src/Witness_complex/include/gudhi/Strong_witness_complex.h b/src/Witness_complex/include/gudhi/Strong_witness_complex.h index 6f4bcf60..c18335d3 100644 --- a/src/Witness_complex/include/gudhi/Strong_witness_complex.h +++ b/src/Witness_complex/include/gudhi/Strong_witness_complex.h @@ -127,7 +127,6 @@ class Strong_witness_complex { if ((Landmark_id)simplex.size() - 1 > complex_dim) complex_dim = simplex.size() - 1; } - complex.set_dimension(complex_dim); return true; } diff --git a/src/Witness_complex/include/gudhi/Witness_complex.h b/src/Witness_complex/include/gudhi/Witness_complex.h index bcfe8484..53c38520 100644 --- a/src/Witness_complex/include/gudhi/Witness_complex.h +++ b/src/Witness_complex/include/gudhi/Witness_complex.h @@ -130,7 +130,6 @@ class Witness_complex { } k++; } - complex.set_dimension(k-1); return true; } diff --git a/src/cython/include/Tangential_complex_interface.h b/src/cython/include/Tangential_complex_interface.h index 5e9dc0e4..ecf014b3 100644 --- a/src/cython/include/Tangential_complex_interface.h +++ b/src/cython/include/Tangential_complex_interface.h @@ -106,8 +106,6 @@ class Tangential_complex_interface { void create_simplex_tree(Simplex_tree<>* simplex_tree) { int max_dim = tangential_complex_->create_complex>(*simplex_tree); - // FIXME - simplex_tree->set_dimension(max_dim); simplex_tree->initialize_filtration(); } diff --git a/src/cython/test/test_simplex_tree.py b/src/cython/test/test_simplex_tree.py index 3ae537e3..a6d6a9f3 100755 --- a/src/cython/test/test_simplex_tree.py +++ b/src/cython/test/test_simplex_tree.py @@ -34,9 +34,13 @@ def test_insertion(): # insert test assert st.insert([0, 1]) == True + + assert st.dimension() == 1 + assert st.insert([0, 1, 2], filtration=4.0) == True - # FIXME: Remove this line - st.set_dimension(2) + + assert st.dimension() == 2 + assert st.num_simplices() == 7 assert st.num_vertices() == 3 @@ -87,8 +91,9 @@ def test_insertion(): assert st.find([2]) == True st.initialize_filtration() - assert st.persistence() == [(1, (4.0, float('inf'))), (0, (0.0, float('inf')))] + assert st.persistence(persistence_dim_max = True) == [(1, (4.0, float('inf'))), (0, (0.0, float('inf')))] assert st.__is_persistence_defined() == True + assert st.betti_numbers() == [1, 1] assert st.persistent_betti_numbers(-0.1, 10000.0) == [0, 0] assert st.persistent_betti_numbers(0.0, 10000.0) == [1, 0] -- cgit v1.2.3 From 664b4dcbeb549e89128802b2402d60cb6d28268d Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 20 Sep 2017 13:49:41 +0000 Subject: Add tests limits git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_automatic_dimension_set@2690 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: fc3e0cb28170f49a598d50fc7e32ac2d9d191447 --- .../test/simplex_tree_remove_unit_test.cpp | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/Simplex_tree/test/simplex_tree_remove_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_remove_unit_test.cpp index ad71fed3..df89008e 100644 --- a/src/Simplex_tree/test/simplex_tree_remove_unit_test.cpp +++ b/src/Simplex_tree/test/simplex_tree_remove_unit_test.cpp @@ -169,6 +169,56 @@ BOOST_AUTO_TEST_CASE(auto_dimension_set) { st.remove_maximal_simplex(st.find({0, 1, 3, 4})); BOOST_CHECK(st.dimension() == 2); + std::cout << "st.insert_simplex_and_subfaces({1, 2, 3, 5})" << std::endl; + st.insert_simplex_and_subfaces({1, 2, 3, 5}); + BOOST_CHECK(st.dimension() == 3); + + std::cout << "st.insert_simplex_and_subfaces({1, 2, 3, 4})" << std::endl; + st.insert_simplex_and_subfaces({1, 2, 3, 4}); + BOOST_CHECK(st.dimension() == 3); + + // Check you can override the dimension + // This is a limit test case - shall not happen + st.set_dimension(1); + BOOST_CHECK(st.dimension() == 1); + + // Here no siblings is erased - automatic dimension is not launched. + std::cout << "st.remove_maximal_simplex({1, 2, 3, 4})" << std::endl; + st.remove_maximal_simplex(st.find({1, 2, 3, 4})); + BOOST_CHECK(st.dimension() == 1); + + // Here sibling is erased - automatic dimension is launched. + std::cout << "st.remove_maximal_simplex({1, 2, 3, 5})" << std::endl; + st.remove_maximal_simplex(st.find({1, 2, 3, 5})); + BOOST_CHECK(st.dimension() == 2); + + std::cout << "st.insert_simplex_and_subfaces({1, 2, 3, 5})" << std::endl; + st.insert_simplex_and_subfaces({1, 2, 3, 5}); + BOOST_CHECK(st.dimension() == 3); + + std::cout << "st.insert_simplex_and_subfaces({1, 2, 3, 4})" << std::endl; + st.insert_simplex_and_subfaces({1, 2, 3, 4}); + BOOST_CHECK(st.dimension() == 3); + + // Check you can override the dimension + // This is a limit test case - shall not happen + st.set_dimension(6); + BOOST_CHECK(st.dimension() == 6); + + // Here no siblings is erased - automatic dimension is not launched. + std::cout << "st.remove_maximal_simplex({1, 2, 3, 5})" << std::endl; + st.remove_maximal_simplex(st.find({1, 2, 3, 5})); + BOOST_CHECK(st.dimension() == 6); + + // Here sibling is erased - automatic dimension is launched but dim is always than te one set. + std::cout << "st.remove_maximal_simplex({1, 2, 3, 4})" << std::endl; + st.remove_maximal_simplex(st.find({1, 2, 3, 4})); + BOOST_CHECK(st.dimension() == 6); + + // Reset with the correct value + st.set_dimension(2); + BOOST_CHECK(st.dimension() == 2); + std::cout << "st.insert_simplex_and_subfaces({0, 1, 2, 3, 4, 5, 6})" << std::endl; st.insert_simplex_and_subfaces({0, 1, 2, 3, 4, 5, 6}); BOOST_CHECK(st.dimension() == 6); -- cgit v1.2.3 From e2f26211caaef3c3a564e5858d513b25804eb35e Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 20 Sep 2017 18:39:29 +0000 Subject: Separate and improve simplex tree iostream operators to test automatic dimension set on iostream operators git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_automatic_dimension_set@2693 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: dafd077f3ed20eafaccdb27d56e02b3d9e5c44a7 --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 10 +-- src/Simplex_tree/test/CMakeLists.txt | 8 +++ .../simplex_tree_iostream_operator_unit_test.cpp | 83 ++++++++++++++++++++++ .../test/simplex_tree_remove_unit_test.cpp | 1 - src/Simplex_tree/test/simplex_tree_unit_test.cpp | 35 --------- 5 files changed, 93 insertions(+), 44 deletions(-) create mode 100644 src/Simplex_tree/test/simplex_tree_iostream_operator_unit_test.cpp diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 478ed80f..76e594d3 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -763,7 +763,8 @@ class Simplex_tree { /** Set an upper bound for the filtration values. */ void set_filtration(Filtration_value fil) { - threshold_ = fil; + if (Options::store_filtration) + threshold_ = fil; } /** Set a dimension for the simplicial complex. */ @@ -1288,14 +1289,8 @@ std::istream& operator>>(std::istream & is, Simplex_tree & st) { std::vector simplex; typename ST::Filtration_value fil; typename ST::Filtration_value max_fil = 0; - int max_dim = -1; while (read_simplex(is, simplex, fil)) { // read all simplices in the file as a list of vertices - // Warning : simplex_size needs to be casted in int - Can be 0 - int dim = static_cast (simplex.size() - 1); - if (max_dim < dim) { - max_dim = dim; - } if (max_fil < fil) { max_fil = fil; } @@ -1303,7 +1298,6 @@ std::istream& operator>>(std::istream & is, Simplex_tree & st) { st.insert_simplex(simplex, fil); simplex.clear(); } - st.set_dimension(max_dim); st.set_filtration(max_fil); return is; diff --git a/src/Simplex_tree/test/CMakeLists.txt b/src/Simplex_tree/test/CMakeLists.txt index 1c169ff7..8684ad2a 100644 --- a/src/Simplex_tree/test/CMakeLists.txt +++ b/src/Simplex_tree/test/CMakeLists.txt @@ -21,3 +21,11 @@ if (TBB_FOUND) endif() gudhi_add_coverage_test(Simplex_tree_remove_test_unit) + +add_executable ( Simplex_tree_iostream_operator_test_unit simplex_tree_iostream_operator_unit_test.cpp ) +target_link_libraries(Simplex_tree_iostream_operator_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +if (TBB_FOUND) + target_link_libraries(Simplex_tree_iostream_operator_test_unit ${TBB_LIBRARIES}) +endif() + +gudhi_add_coverage_test(Simplex_tree_iostream_operator_test_unit) diff --git a/src/Simplex_tree/test/simplex_tree_iostream_operator_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_iostream_operator_unit_test.cpp new file mode 100644 index 00000000..402c31e2 --- /dev/null +++ b/src/Simplex_tree/test/simplex_tree_iostream_operator_unit_test.cpp @@ -0,0 +1,83 @@ +#include + +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MODULE "simplex_tree_iostream_operator" +#include +#include + +// ^ +// /!\ Nothing else from Simplex_tree shall be included to test includes are well defined. +#include "gudhi/Simplex_tree.h" + +using namespace Gudhi; + +struct MyOptions : Simplex_tree_options_full_featured { + // Not doing persistence, so we don't need those + static const bool store_key = false; + static const bool store_filtration = false; + // I have few vertices + typedef short Vertex_handle; +}; + +typedef boost::mpl::list, + Simplex_tree, + Simplex_tree + > list_of_tested_variants; + +BOOST_AUTO_TEST_CASE_TEMPLATE(iostream_operator, Stree_type, list_of_tested_variants) { + std::cout << "********************************************************************" << std::endl; + std::cout << "SIMPLEX TREE IOSTREAM OPERATOR" << std::endl; + + Stree_type st; + + st.insert_simplex_and_subfaces({0, 1, 6, 7}, 4.0); + st.insert_simplex_and_subfaces({3, 4, 5}, 3.0); + st.insert_simplex_and_subfaces({3, 0}, 2.0); + st.insert_simplex_and_subfaces({2, 1, 0}, 3.0); + // FIXME + st.set_filtration(4.0); + + st.initialize_filtration(); + // Display the Simplex_tree + std::cout << "The ORIGINAL complex contains " << st.num_simplices() << " simplices" << std::endl; + std::cout << " - dimension " << st.dimension() << " - filtration " << st.filtration() << std::endl; + std::cout << std::endl << std::endl << "Iterator on Simplices in the filtration, with [filtration value]:" << std::endl; + for (auto f_simplex : st.filtration_simplex_range()) { + std::cout << " " << "[" << st.filtration(f_simplex) << "] "; + for (auto vertex : st.simplex_vertex_range(f_simplex)) { + std::cout << (int) vertex << " "; + } + std::cout << std::endl; + } + + // st: + // 1 6 + // o---o + // /X\7/ + // o---o---o---o + // 2 0 3\X/4 + // o + // 5 + std::string iostream_file("simplex_tree_for_iostream_operator_unit_test.txt"); + std::ofstream simplex_tree_ostream(iostream_file.c_str()); + simplex_tree_ostream << st; + simplex_tree_ostream.close(); + + Stree_type read_st; + std::ifstream simplex_tree_istream(iostream_file.c_str()); + simplex_tree_istream >> read_st; + + // Display the Simplex_tree + std::cout << "The READ complex contains " << read_st.num_simplices() << " simplices" << std::endl; + std::cout << " - dimension " << read_st.dimension() << " - filtration " << read_st.filtration() << std::endl; + std::cout << std::endl << std::endl << "Iterator on Simplices in the filtration, with [filtration value]:" << std::endl; + for (auto f_simplex : read_st.filtration_simplex_range()) { + std::cout << " " << "[" << read_st.filtration(f_simplex) << "] "; + for (auto vertex : read_st.simplex_vertex_range(f_simplex)) { + std::cout << (int) vertex << " "; + } + std::cout << std::endl; + } + + BOOST_CHECK(st == read_st); +} diff --git a/src/Simplex_tree/test/simplex_tree_remove_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_remove_unit_test.cpp index df89008e..1e6cea52 100644 --- a/src/Simplex_tree/test/simplex_tree_remove_unit_test.cpp +++ b/src/Simplex_tree/test/simplex_tree_remove_unit_test.cpp @@ -3,7 +3,6 @@ #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MODULE "simplex_tree_remove" #include -#include // ^ // /!\ Nothing else from Simplex_tree shall be included to test includes are well defined. diff --git a/src/Simplex_tree/test/simplex_tree_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_unit_test.cpp index 7323aa6c..f67ff010 100644 --- a/src/Simplex_tree/test/simplex_tree_unit_test.cpp +++ b/src/Simplex_tree/test/simplex_tree_unit_test.cpp @@ -86,41 +86,6 @@ bool AreAlmostTheSame(float a, float b) { return std::fabs(a - b) < std::numeric_limits::epsilon(); } -BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_from_file, typeST, list_of_tested_variants) { - // TEST OF INSERTION - std::cout << "********************************************************************" << std::endl; - std::cout << "TEST OF SIMPLEX TREE FROM A FILE" << std::endl; - typeST st; - - std::string inputFile("simplex_tree_for_unit_test.txt"); - std::ifstream simplex_tree_stream(inputFile.c_str()); - simplex_tree_stream >> st; - - // Display the Simplex_tree - std::cout << "The complex contains " << st.num_simplices() << " simplices" << std::endl; - std::cout << " - dimension " << st.dimension() << " - filtration " << st.filtration() << std::endl; - - // Check - BOOST_CHECK(st.num_simplices() == 143353); - BOOST_CHECK(st.dimension() == 3); - BOOST_CHECK(AreAlmostTheSame(st.filtration(), 0.4)); - - int previous_size = 0; - for (auto f_simplex : st.filtration_simplex_range()) { - // Size of simplex - int size = 0; - for (auto vertex : st.simplex_vertex_range(f_simplex)) { - // Remove warning - (void) vertex; - size++; - } - BOOST_CHECK(AreAlmostTheSame(st.filtration(f_simplex), (0.1 * size))); // Specific test: filtration = 0.1 * simplex_size - BOOST_CHECK(previous_size <= size); // Check list is sorted (because of sorted filtrations in simplex_tree.txt) - previous_size = size; - } - simplex_tree_stream.close(); -} - template void test_simplex_tree_contains(typeST& simplexTree, typeSimplex& simplex, int pos) { auto f_simplex = simplexTree.filtration_simplex_range().begin() + pos; -- cgit v1.2.3 From c762ffb234a86d6acce63546bfacbf419ca62bbc Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 20 Sep 2017 20:33:19 +0000 Subject: Roll back simplex tree set_filtration modification (assign_filtration asserts in debug) and modify test git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_automatic_dimension_set@2694 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: d08cc4b4f310784975b81d10b7ebd78063c42378 --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 1 - .../simplex_tree_iostream_operator_unit_test.cpp | 60 +++++++++++++++++++++- 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 76e594d3..dc684594 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -763,7 +763,6 @@ class Simplex_tree { /** Set an upper bound for the filtration values. */ void set_filtration(Filtration_value fil) { - if (Options::store_filtration) threshold_ = fil; } diff --git a/src/Simplex_tree/test/simplex_tree_iostream_operator_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_iostream_operator_unit_test.cpp index 402c31e2..fed764d9 100644 --- a/src/Simplex_tree/test/simplex_tree_iostream_operator_unit_test.cpp +++ b/src/Simplex_tree/test/simplex_tree_iostream_operator_unit_test.cpp @@ -20,8 +20,7 @@ struct MyOptions : Simplex_tree_options_full_featured { }; typedef boost::mpl::list, - Simplex_tree, - Simplex_tree + Simplex_tree > list_of_tested_variants; BOOST_AUTO_TEST_CASE_TEMPLATE(iostream_operator, Stree_type, list_of_tested_variants) { @@ -81,3 +80,60 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(iostream_operator, Stree_type, list_of_tested_vari BOOST_CHECK(st == read_st); } + + +BOOST_AUTO_TEST_CASE(mini_iostream_operator) { + std::cout << "********************************************************************" << std::endl; + std::cout << "MINI SIMPLEX TREE IOSTREAM OPERATOR" << std::endl; + + Simplex_tree st; + + st.insert_simplex_and_subfaces({0, 1, 6, 7}); + st.insert_simplex_and_subfaces({3, 4, 5}); + st.insert_simplex_and_subfaces({3, 0}); + st.insert_simplex_and_subfaces({2, 1, 0}); + + st.initialize_filtration(); + // Display the Simplex_tree + std::cout << "The ORIGINAL complex contains " << st.num_simplices() << " simplices" << std::endl; + std::cout << " - dimension " << st.dimension() << " - filtration " << st.filtration() << std::endl; + std::cout << std::endl << std::endl << "Iterator on Simplices in the filtration, with [filtration value]:" << std::endl; + for (auto f_simplex : st.filtration_simplex_range()) { + std::cout << " " << "[" << st.filtration(f_simplex) << "] "; + for (auto vertex : st.simplex_vertex_range(f_simplex)) { + std::cout << (int) vertex << " "; + } + std::cout << std::endl; + } + + // st: + // 1 6 + // o---o + // /X\7/ + // o---o---o---o + // 2 0 3\X/4 + // o + // 5 + std::string iostream_file("simplex_tree_for_iostream_operator_unit_test.txt"); + std::ofstream simplex_tree_ostream(iostream_file.c_str()); + simplex_tree_ostream << st; + simplex_tree_ostream.close(); + + Simplex_tree read_st; + std::ifstream simplex_tree_istream(iostream_file.c_str()); + simplex_tree_istream >> read_st; + + // Display the Simplex_tree + std::cout << "The READ complex contains " << read_st.num_simplices() << " simplices" << std::endl; + std::cout << " - dimension " << read_st.dimension() << " - filtration " << read_st.filtration() << std::endl; + std::cout << std::endl << std::endl << "Iterator on Simplices in the filtration, with [filtration value]:" << std::endl; + for (auto f_simplex : read_st.filtration_simplex_range()) { + std::cout << " " << "[" << read_st.filtration(f_simplex) << "] "; + for (auto vertex : read_st.simplex_vertex_range(f_simplex)) { + std::cout << (int) vertex << " "; + } + std::cout << std::endl; + } + + BOOST_CHECK(st == read_st); +} -- cgit v1.2.3 From 409874ad0812c863a924bd4482d76c718620c0b9 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 21 Sep 2017 06:22:19 +0000 Subject: Add some comments for readability git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_automatic_dimension_set@2697 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 986cc3b862ceca993a6fdd8cdee6da2c1ed4cc14 --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index dc684594..5d1885b8 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1204,6 +1204,7 @@ class Simplex_tree { */ bool auto_dimension_set(int old_dimension) { int new_dimension = -1; + // Browse the tree from te left to the right as higher dimension cells are more likely on the left part of the tree for (Simplex_handle sh : skeleton_simplex_range(old_dimension)) { #ifdef DEBUG_TRACES for (auto vertex : simplex_vertex_range(sh)) { @@ -1214,6 +1215,7 @@ class Simplex_tree { int sh_dimension = dimension(sh); if (sh_dimension >= old_dimension) + // Stop browsing as soon as the dimension is reached, no need to go furter return false; new_dimension = std::max(new_dimension, sh_dimension); } -- cgit v1.2.3 From 346ba542c13db7e49e6d81412144ed21ac46bd83 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 21 Sep 2017 06:41:40 +0000 Subject: Remove set_dimension from examples git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_automatic_dimension_set@2698 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: cde0919e6bb53ad8ace21f1c6894708468449276 --- src/Simplex_tree/example/mini_simplex_tree.cpp | 2 -- src/Simplex_tree/example/simple_simplex_tree.cpp | 1 - src/cython/example/simplex_tree_example.py | 2 -- 3 files changed, 5 deletions(-) diff --git a/src/Simplex_tree/example/mini_simplex_tree.cpp b/src/Simplex_tree/example/mini_simplex_tree.cpp index ad99df23..19e45361 100644 --- a/src/Simplex_tree/example/mini_simplex_tree.cpp +++ b/src/Simplex_tree/example/mini_simplex_tree.cpp @@ -52,8 +52,6 @@ int main() { auto edge03 = {0, 3}; st.insert_simplex_and_subfaces(triangle012); st.insert_simplex_and_subfaces(edge03); - // FIXME: Remove this line - st.set_dimension(2); auto edge02 = {0, 2}; ST::Simplex_handle e = st.find(edge02); diff --git a/src/Simplex_tree/example/simple_simplex_tree.cpp b/src/Simplex_tree/example/simple_simplex_tree.cpp index 60f9a35e..26d663fb 100644 --- a/src/Simplex_tree/example/simple_simplex_tree.cpp +++ b/src/Simplex_tree/example/simple_simplex_tree.cpp @@ -186,7 +186,6 @@ int main(int argc, char * const argv[]) { // ++ GENERAL VARIABLE SET simplexTree.set_filtration(FOURTH_FILTRATION_VALUE); // Max filtration value - simplexTree.set_dimension(2); // Max dimension = 2 -> (2,1,0) std::cout << "********************************************************************\n"; // Display the Simplex_tree - Can not be done in the middle of 2 inserts diff --git a/src/cython/example/simplex_tree_example.py b/src/cython/example/simplex_tree_example.py index 3af20fcf..7e4b0b6c 100755 --- a/src/cython/example/simplex_tree_example.py +++ b/src/cython/example/simplex_tree_example.py @@ -48,8 +48,6 @@ if st.insert([0, 1, 2], filtration=4.0): else: print("Not inserted...") -# FIXME: Remove this line -st.set_dimension(3) print("dimension=", st.dimension()) st.set_filtration(4.0) -- cgit v1.2.3 From 21b1120bfa2047eca025ae759dce2d05f6c86c43 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 22 Sep 2017 05:37:51 +0000 Subject: Remove automatic_dimension_set call from remove and prune functions Make it public to be available Modify tests accordingly git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_automatic_dimension_set@2703 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 2ff42d5327ae76b121390a913c4e548d6f59ea99 --- src/Alpha_complex/test/Alpha_complex_unit_test.cpp | 2 +- src/Simplex_tree/include/gudhi/Simplex_tree.h | 36 ++++------ .../test/simplex_tree_remove_unit_test.cpp | 78 ++++++++++++++-------- 3 files changed, 64 insertions(+), 52 deletions(-) diff --git a/src/Alpha_complex/test/Alpha_complex_unit_test.cpp b/src/Alpha_complex/test/Alpha_complex_unit_test.cpp index 166373fe..e60089c4 100644 --- a/src/Alpha_complex/test/Alpha_complex_unit_test.cpp +++ b/src/Alpha_complex/test/Alpha_complex_unit_test.cpp @@ -232,7 +232,7 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_from_points) { BOOST_CHECK(simplex_tree.num_simplices() == 10); std::cout << "simplex_tree.dimension()=" << simplex_tree.dimension() << std::endl; - BOOST_CHECK(simplex_tree.dimension() == 1); + BOOST_CHECK(simplex_tree.dimension() == 3); std::cout << "simplex_tree.num_vertices()=" << simplex_tree.num_vertices() << std::endl; BOOST_CHECK(simplex_tree.num_vertices() == 4); diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 5d1885b8..fd6cd72a 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1161,13 +1161,11 @@ class Simplex_tree { * \post Some simplex tree functions require the filtration to be valid. `prune_above_filtration()` * function is not launching `initialize_filtration()` but returns the filtration modification information. If the * complex has changed , please call `initialize_filtration()` to recompute it. + * \post Be aware that `prune_above_filtration()` may change the simplex tree dimension (`automatic_dimension_set()` + * to be done). */ bool prune_above_filtration(Filtration_value filtration) { - bool modified = rec_prune_above_filtration(root(), filtration); - if (modified) { - auto_dimension_set(dimension()); - } - return modified; + return rec_prune_above_filtration(root(), filtration); } private: @@ -1195,17 +1193,16 @@ class Simplex_tree { return modified; } - private: - /** \brief Resets the Simplex_tree dimension. - * @param[in] old_dimension The former dimension value until the loop stopped when it is reached. + public: + /** \brief Deep search simplex tree dimension reset. * @return The dimension modification information. - * \pre Please check the simplex has not a too low dimension value. - * This cannot happen if set_dimension has not been performed. + * \pre Be sure the simplex tree has not a too low dimension value as the deep search stops when the former dimension + * has been reached (cf. `dimension()` and `set_dimension()` methods). */ - bool auto_dimension_set(int old_dimension) { + bool automatic_dimension_set() { int new_dimension = -1; // Browse the tree from te left to the right as higher dimension cells are more likely on the left part of the tree - for (Simplex_handle sh : skeleton_simplex_range(old_dimension)) { + for (Simplex_handle sh : skeleton_simplex_range(dimension_)) { #ifdef DEBUG_TRACES for (auto vertex : simplex_vertex_range(sh)) { std::cout << " " << vertex; @@ -1214,12 +1211,12 @@ class Simplex_tree { #endif // DEBUG_TRACES int sh_dimension = dimension(sh); - if (sh_dimension >= old_dimension) + if (sh_dimension >= dimension_) // Stop browsing as soon as the dimension is reached, no need to go furter return false; new_dimension = std::max(new_dimension, sh_dimension); } - set_dimension(new_dimension); + dimension_ = new_dimension; return true; } @@ -1229,7 +1226,8 @@ class Simplex_tree { * @param[in] sh Simplex handle on the maximal simplex to remove. * \pre Please check the simplex has no coface before removing it. * \exception std::invalid_argument In debug mode, if sh has children. - * \post Be aware that removing is shifting data in a flat_map (initialize_filtration to be done). + * \post Be aware that removing is shifting data in a flat_map (`initialize_filtration()` to be done). + * \post Be aware that removing may change the simplex tree dimension (`automatic_dimension_set()` to be done). */ void remove_maximal_simplex(Simplex_handle sh) { // Guarantee the simplex has no children @@ -1244,17 +1242,9 @@ class Simplex_tree { // Special case when child is the root of the simplex tree, just remove it from members child->erase(sh); } else { - // Keep information before remove action - int sh_dim = dimension(sh); - // Sibling is emptied : must be deleted, and its parent must point on his own Sibling child->oncles()->members().at(child->parent()).assign_children(child->oncles()); delete child; - - // No need to reset dimension in case maximal simplex is not the maximal dimension one - if (sh_dim >= dimension()) { - auto_dimension_set(sh_dim); - } } } diff --git a/src/Simplex_tree/test/simplex_tree_remove_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_remove_unit_test.cpp index 1e6cea52..87c77801 100644 --- a/src/Simplex_tree/test/simplex_tree_remove_unit_test.cpp +++ b/src/Simplex_tree/test/simplex_tree_remove_unit_test.cpp @@ -108,7 +108,12 @@ BOOST_AUTO_TEST_CASE(remove_maximal_simplex) { st.remove_maximal_simplex(st.find({6, 7})); std::cout << "st.remove_maximal_simplex({7})" << std::endl; st.remove_maximal_simplex(st.find({7})); - + + std::cout << "st.dimension()=" << st.dimension() << std::endl; + BOOST_CHECK(st.dimension() == 3); + + st.automatic_dimension_set(); + std::cout << "st.dimension()=" << st.dimension() << " | st_wo_seven.dimension()=" << st_wo_seven.dimension() << std::endl; BOOST_CHECK(st == st_wo_seven); } @@ -130,100 +135,112 @@ BOOST_AUTO_TEST_CASE(auto_dimension_set) { std::cout << "st.remove_maximal_simplex({6, 7, 8, 10})" << std::endl; st.remove_maximal_simplex(st.find({6, 7, 8, 10})); + std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == 3); std::cout << "st.remove_maximal_simplex({6, 7, 8, 9})" << std::endl; st.remove_maximal_simplex(st.find({6, 7, 8, 9})); + std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == 3); std::cout << "st.remove_maximal_simplex({1, 2, 3, 4})" << std::endl; st.remove_maximal_simplex(st.find({1, 2, 3, 4})); + std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == 3); std::cout << "st.remove_maximal_simplex({1, 2, 3, 5})" << std::endl; st.remove_maximal_simplex(st.find({1, 2, 3, 5})); + std::cout << "st.dimension()=" << st.dimension() << std::endl; + BOOST_CHECK(st.dimension() == 3); + st.automatic_dimension_set(); + std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == 2); std::cout << "st.insert_simplex_and_subfaces({1, 2, 3, 5})" << std::endl; st.insert_simplex_and_subfaces({1, 2, 3, 5}); + std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == 3); std::cout << "st.insert_simplex_and_subfaces({1, 2, 3, 4})" << std::endl; st.insert_simplex_and_subfaces({1, 2, 3, 4}); + std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == 3); std::cout << "st.remove_maximal_simplex({1, 2, 3, 5})" << std::endl; st.remove_maximal_simplex(st.find({1, 2, 3, 5})); + std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == 3); std::cout << "st.remove_maximal_simplex({1, 2, 3, 4})" << std::endl; st.remove_maximal_simplex(st.find({1, 2, 3, 4})); + std::cout << "st.dimension()=" << st.dimension() << std::endl; + BOOST_CHECK(st.dimension() == 3); + st.automatic_dimension_set(); + std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == 2); std::cout << "st.insert_simplex_and_subfaces({0, 1, 3, 4})" << std::endl; st.insert_simplex_and_subfaces({0, 1, 3, 4}); + std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == 3); std::cout << "st.remove_maximal_simplex({0, 1, 3, 4})" << std::endl; st.remove_maximal_simplex(st.find({0, 1, 3, 4})); + std::cout << "st.dimension()=" << st.dimension() << std::endl; + BOOST_CHECK(st.dimension() == 3); + st.automatic_dimension_set(); + std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == 2); std::cout << "st.insert_simplex_and_subfaces({1, 2, 3, 5})" << std::endl; st.insert_simplex_and_subfaces({1, 2, 3, 5}); + std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == 3); std::cout << "st.insert_simplex_and_subfaces({1, 2, 3, 4})" << std::endl; st.insert_simplex_and_subfaces({1, 2, 3, 4}); + std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == 3); + // Check you can override the dimension // This is a limit test case - shall not happen st.set_dimension(1); + std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == 1); - - // Here no siblings is erased - automatic dimension is not launched. - std::cout << "st.remove_maximal_simplex({1, 2, 3, 4})" << std::endl; - st.remove_maximal_simplex(st.find({1, 2, 3, 4})); + st.automatic_dimension_set(); + std::cout << "st.dimension()=" << st.dimension() << std::endl; + // check automatic_dimension_set() is not giving the rigt answer because dimension is too low BOOST_CHECK(st.dimension() == 1); - // Here sibling is erased - automatic dimension is launched. - std::cout << "st.remove_maximal_simplex({1, 2, 3, 5})" << std::endl; - st.remove_maximal_simplex(st.find({1, 2, 3, 5})); - BOOST_CHECK(st.dimension() == 2); - - std::cout << "st.insert_simplex_and_subfaces({1, 2, 3, 5})" << std::endl; - st.insert_simplex_and_subfaces({1, 2, 3, 5}); - BOOST_CHECK(st.dimension() == 3); - - std::cout << "st.insert_simplex_and_subfaces({1, 2, 3, 4})" << std::endl; - st.insert_simplex_and_subfaces({1, 2, 3, 4}); - BOOST_CHECK(st.dimension() == 3); // Check you can override the dimension // This is a limit test case - shall not happen st.set_dimension(6); + std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == 6); + st.automatic_dimension_set(); + std::cout << "st.dimension()=" << st.dimension() << std::endl; + // check automatic_dimension_set() resets the correct dimension + BOOST_CHECK(st.dimension() == 3); - // Here no siblings is erased - automatic dimension is not launched. - std::cout << "st.remove_maximal_simplex({1, 2, 3, 5})" << std::endl; - st.remove_maximal_simplex(st.find({1, 2, 3, 5})); - BOOST_CHECK(st.dimension() == 6); - - // Here sibling is erased - automatic dimension is launched but dim is always than te one set. - std::cout << "st.remove_maximal_simplex({1, 2, 3, 4})" << std::endl; - st.remove_maximal_simplex(st.find({1, 2, 3, 4})); - BOOST_CHECK(st.dimension() == 6); // Reset with the correct value - st.set_dimension(2); - BOOST_CHECK(st.dimension() == 2); + st.set_dimension(3); + std::cout << "st.dimension()=" << st.dimension() << std::endl; + BOOST_CHECK(st.dimension() == 3); std::cout << "st.insert_simplex_and_subfaces({0, 1, 2, 3, 4, 5, 6})" << std::endl; st.insert_simplex_and_subfaces({0, 1, 2, 3, 4, 5, 6}); + std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == 6); std::cout << "st.remove_maximal_simplex({0, 1, 2, 3, 4, 5, 6})" << std::endl; st.remove_maximal_simplex(st.find({0, 1, 2, 3, 4, 5, 6})); + std::cout << "st.dimension()=" << st.dimension() << std::endl; + BOOST_CHECK(st.dimension() == 6); + st.automatic_dimension_set(); + std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == 5); } @@ -325,6 +342,11 @@ BOOST_AUTO_TEST_CASE(prune_above_filtration) { // Display the Simplex_tree std::cout << "The complex pruned at 0.0 contains " << st.num_simplices() << " simplices"; std::cout << " - dimension " << st.dimension() << std::endl; + BOOST_CHECK(st.dimension() == 3); + + st.automatic_dimension_set(); + std::cout << "dimension=" << st.dimension() << std::endl; + BOOST_CHECK(st.dimension() == -1); BOOST_CHECK(st == st_empty); BOOST_CHECK(simplex_is_changed); -- cgit v1.2.3 -- cgit v1.2.3 From 3534c24fd805f8cf0ed8f1d5faea183513966b9f Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 22 Sep 2017 06:59:33 +0000 Subject: Remove global filtration attribute of te simplex tree (including getter and setter) git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_remove_useless_global_filtration@2705 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: a6c179ae47e61d1ca12d1f54c4ae1fc0e3c1fde2 --- src/Hasse_complex/include/gudhi/Hasse_complex.h | 10 +--------- .../example/alpha_complex_3d_persistence.cpp | 2 -- .../example/exact_alpha_complex_3d_persistence.cpp | 2 -- .../periodic_alpha_complex_3d_persistence.cpp | 2 -- .../example/persistence_from_file.cpp | 3 +-- .../persistence_from_simple_simplex_tree.cpp | 3 +-- .../weighted_alpha_complex_3d_persistence.cpp | 2 -- .../test/persistent_cohomology_unit_test.cpp | 3 +-- ...persistent_cohomology_unit_test_multi_field.cpp | 3 +-- src/Simplex_tree/example/simple_simplex_tree.cpp | 3 +-- src/Simplex_tree/include/gudhi/Simplex_tree.h | 22 ---------------------- src/Simplex_tree/test/simplex_tree_unit_test.cpp | 22 ++++------------------ src/cython/cython/simplex_tree.pyx | 10 ---------- src/cython/example/simplex_tree_example.py | 1 - src/cython/test/test_simplex_tree.py | 1 - 15 files changed, 10 insertions(+), 79 deletions(-) diff --git a/src/Hasse_complex/include/gudhi/Hasse_complex.h b/src/Hasse_complex/include/gudhi/Hasse_complex.h index 8b06b771..834201a5 100644 --- a/src/Hasse_complex/include/gudhi/Hasse_complex.h +++ b/src/Hasse_complex/include/gudhi/Hasse_complex.h @@ -104,7 +104,6 @@ class Hasse_complex { Hasse_complex(Complex_ds & cpx) : complex_(cpx.num_simplices()) , vertices_() - , threshold_(cpx.filtration()) , num_vertices_() , dim_max_(cpx.dimension()) { int size = complex_.size(); @@ -125,7 +124,6 @@ class Hasse_complex { Hasse_complex() : complex_() , vertices_() - , threshold_(0) , num_vertices_(0) , dim_max_(-1) { } @@ -157,15 +155,11 @@ class Hasse_complex { Filtration_value filtration(Simplex_handle sh) { if (sh == null_simplex()) { - return filtration(); + return INFINITY; } return complex_[sh].filtration_; } - Filtration_value filtration() { - return threshold_; - } - int dimension(Simplex_handle sh) { if (complex_[sh].boundary_.empty()) return 0; return complex_[sh].boundary_.size() - 1; @@ -206,7 +200,6 @@ class Hasse_complex { std::vector< Hasse_simp, Gudhi::no_init_allocator > complex_; std::vector vertices_; - Filtration_value threshold_; size_t num_vertices_; int dim_max_; }; @@ -245,7 +238,6 @@ std::istream& operator>>(std::istream & is } hcpx.dim_max_ = max_dim; - hcpx.threshold_ = max_fil; return is; } diff --git a/src/Persistent_cohomology/example/alpha_complex_3d_persistence.cpp b/src/Persistent_cohomology/example/alpha_complex_3d_persistence.cpp index fd227b82..53e50a69 100644 --- a/src/Persistent_cohomology/example/alpha_complex_3d_persistence.cpp +++ b/src/Persistent_cohomology/example/alpha_complex_3d_persistence.cpp @@ -202,7 +202,6 @@ int main(int argc, char * const argv[]) { else std::cout << "This shall not happen" << std::endl; } - simplex_tree.set_filtration(filtration_max); simplex_tree.set_dimension(dim_max); #ifdef DEBUG_TRACES @@ -216,7 +215,6 @@ int main(int argc, char * const argv[]) { std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " "; std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl; std::cout << " Dimension = " << simplex_tree.dimension() << " "; - std::cout << " filtration = " << simplex_tree.filtration() << std::endl << std::endl; #endif // DEBUG_TRACES #ifdef DEBUG_TRACES diff --git a/src/Persistent_cohomology/example/exact_alpha_complex_3d_persistence.cpp b/src/Persistent_cohomology/example/exact_alpha_complex_3d_persistence.cpp index 8a335075..acb34bcb 100644 --- a/src/Persistent_cohomology/example/exact_alpha_complex_3d_persistence.cpp +++ b/src/Persistent_cohomology/example/exact_alpha_complex_3d_persistence.cpp @@ -204,7 +204,6 @@ int main(int argc, char * const argv[]) { else std::cout << "This shall not happen" << std::endl; } - simplex_tree.set_filtration(filtration_max); simplex_tree.set_dimension(dim_max); #ifdef DEBUG_TRACES @@ -218,7 +217,6 @@ int main(int argc, char * const argv[]) { std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " "; std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl; std::cout << " Dimension = " << simplex_tree.dimension() << " "; - std::cout << " filtration = " << simplex_tree.filtration() << std::endl << std::endl; #endif // DEBUG_TRACES #ifdef DEBUG_TRACES diff --git a/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp b/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp index 8928cfc2..f731d349 100644 --- a/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp +++ b/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp @@ -221,7 +221,6 @@ int main(int argc, char * const argv[]) { else std::cout << "This shall not happen" << std::endl; } - simplex_tree.set_filtration(filtration_max); simplex_tree.set_dimension(dim_max); #ifdef DEBUG_TRACES @@ -235,7 +234,6 @@ int main(int argc, char * const argv[]) { std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " "; std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl; std::cout << " Dimension = " << simplex_tree.dimension() << " "; - std::cout << " filtration = " << simplex_tree.filtration() << std::endl << std::endl; #endif // DEBUG_TRACES #ifdef DEBUG_TRACES diff --git a/src/Persistent_cohomology/example/persistence_from_file.cpp b/src/Persistent_cohomology/example/persistence_from_file.cpp index 67235467..eafa3fd5 100644 --- a/src/Persistent_cohomology/example/persistence_from_file.cpp +++ b/src/Persistent_cohomology/example/persistence_from_file.cpp @@ -61,8 +61,7 @@ int main(int argc, char * argv[]) { simplex_tree_stream >> simplex_tree; std::cout << "The complex contains " << simplex_tree.num_simplices() << " simplices" << std::endl; - std::cout << " - dimension " << simplex_tree.dimension() << " - filtration " << simplex_tree.filtration() - << std::endl; + std::cout << " - dimension " << simplex_tree.dimension() << std::endl; /* std::cout << std::endl << std::endl << "Iterator on Simplices in the filtration, with [filtration value]:" << std::endl; diff --git a/src/Persistent_cohomology/example/persistence_from_simple_simplex_tree.cpp b/src/Persistent_cohomology/example/persistence_from_simple_simplex_tree.cpp index 7ca9410a..8214d66a 100644 --- a/src/Persistent_cohomology/example/persistence_from_simple_simplex_tree.cpp +++ b/src/Persistent_cohomology/example/persistence_from_simple_simplex_tree.cpp @@ -143,11 +143,10 @@ int main(int argc, char * const argv[]) { /* An edge [10,12,2] */ st.set_dimension(2); - st.set_filtration(0.4); std::cout << "The complex contains " << st.num_simplices() << " simplices - " << st.num_vertices() << " vertices " << std::endl; - std::cout << " - dimension " << st.dimension() << " - filtration " << st.filtration() << std::endl; + std::cout << " - dimension " << st.dimension() << std::endl; std::cout << std::endl << std::endl << "Iterator on Simplices in the filtration, with [filtration value]:" << std::endl; std::cout << "**************************************************************" << std::endl; diff --git a/src/Persistent_cohomology/example/weighted_alpha_complex_3d_persistence.cpp b/src/Persistent_cohomology/example/weighted_alpha_complex_3d_persistence.cpp index 34b90933..9728f22d 100644 --- a/src/Persistent_cohomology/example/weighted_alpha_complex_3d_persistence.cpp +++ b/src/Persistent_cohomology/example/weighted_alpha_complex_3d_persistence.cpp @@ -222,7 +222,6 @@ int main(int argc, char * const argv[]) { else std::cout << "This shall not happen" << std::endl; } - simplex_tree.set_filtration(filtration_max); simplex_tree.set_dimension(dim_max); #ifdef DEBUG_TRACES @@ -236,7 +235,6 @@ int main(int argc, char * const argv[]) { std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " "; std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl; std::cout << " Dimension = " << simplex_tree.dimension() << " "; - std::cout << " filtration = " << simplex_tree.filtration() << std::endl << std::endl; #endif // DEBUG_TRACES #ifdef DEBUG_TRACES diff --git a/src/Persistent_cohomology/test/persistent_cohomology_unit_test.cpp b/src/Persistent_cohomology/test/persistent_cohomology_unit_test.cpp index f8174020..f53987b6 100644 --- a/src/Persistent_cohomology/test/persistent_cohomology_unit_test.cpp +++ b/src/Persistent_cohomology/test/persistent_cohomology_unit_test.cpp @@ -31,12 +31,11 @@ std::string test_rips_persistence(int coefficient, int min_persistence) { // Display the Simplex_tree std::cout << "The complex contains " << st.num_simplices() << " simplices" << " - dimension= " << st.dimension() - << " - filtration= " << st.filtration() << std::endl; + << std::endl; // Check BOOST_CHECK(st.num_simplices() == 98); BOOST_CHECK(st.dimension() == 3); - BOOST_CHECK(st.filtration() == 1.89); // Sort the simplices in the order of the filtration st.initialize_filtration(); diff --git a/src/Persistent_cohomology/test/persistent_cohomology_unit_test_multi_field.cpp b/src/Persistent_cohomology/test/persistent_cohomology_unit_test_multi_field.cpp index 3537cfa4..9e767943 100644 --- a/src/Persistent_cohomology/test/persistent_cohomology_unit_test_multi_field.cpp +++ b/src/Persistent_cohomology/test/persistent_cohomology_unit_test_multi_field.cpp @@ -31,12 +31,11 @@ std::string test_rips_persistence(int min_coefficient, int max_coefficient, doub // Display the Simplex_tree std::cout << "The complex contains " << st.num_simplices() << " simplices" << " - dimension= " << st.dimension() - << " - filtration= " << st.filtration() << std::endl; + << std::endl; // Check BOOST_CHECK(st.num_simplices() == 58); BOOST_CHECK(st.dimension() == 3); - BOOST_CHECK(st.filtration() == 0.4); // Sort the simplices in the order of the filtration st.initialize_filtration(); diff --git a/src/Simplex_tree/example/simple_simplex_tree.cpp b/src/Simplex_tree/example/simple_simplex_tree.cpp index 60f9a35e..d8318f03 100644 --- a/src/Simplex_tree/example/simple_simplex_tree.cpp +++ b/src/Simplex_tree/example/simple_simplex_tree.cpp @@ -185,13 +185,12 @@ int main(int argc, char * const argv[]) { } // ++ GENERAL VARIABLE SET - simplexTree.set_filtration(FOURTH_FILTRATION_VALUE); // Max filtration value simplexTree.set_dimension(2); // Max dimension = 2 -> (2,1,0) std::cout << "********************************************************************\n"; // Display the Simplex_tree - Can not be done in the middle of 2 inserts std::cout << "* The complex contains " << simplexTree.num_simplices() << " simplices\n"; - std::cout << " - dimension " << simplexTree.dimension() << " - filtration " << simplexTree.filtration() << "\n"; + std::cout << " - dimension " << simplexTree.dimension() << "\n"; std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; for (auto f_simplex : simplexTree.filtration_simplex_range()) { std::cout << " " << "[" << simplexTree.filtration(f_simplex) << "] "; diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 317bce23..8c91cc67 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -289,7 +289,6 @@ class Simplex_tree { /** \brief Constructs an empty simplex tree. */ Simplex_tree() : null_vertex_(-1), - threshold_(0), root_(nullptr, null_vertex_), filtration_vect_(), dimension_(-1) { } @@ -297,7 +296,6 @@ class Simplex_tree { /** \brief User-defined copy constructor reproduces the whole tree structure. */ Simplex_tree(const Simplex_tree& simplex_source) : null_vertex_(simplex_source.null_vertex_), - threshold_(simplex_source.threshold_), root_(nullptr, null_vertex_ , simplex_source.root_.members_), filtration_vect_(), dimension_(simplex_source.dimension_) { @@ -323,12 +321,10 @@ class Simplex_tree { /** \brief User-defined move constructor moves the whole tree structure. */ Simplex_tree(Simplex_tree && old) : null_vertex_(std::move(old.null_vertex_)), - threshold_(std::move(old.threshold_)), root_(std::move(old.root_)), filtration_vect_(std::move(old.filtration_vect_)), dimension_(std::move(old.dimension_)) { old.dimension_ = -1; - old.threshold_ = 0; old.root_ = Siblings(nullptr, null_vertex_); } @@ -356,7 +352,6 @@ class Simplex_tree { /** \brief Checks if two simplex trees are equal. */ bool operator==(Simplex_tree& st2) { if ((null_vertex_ != st2.null_vertex_) || - (threshold_ != st2.threshold_) || (dimension_ != st2.dimension_)) return false; return rec_equal(&root_, &st2.root_); @@ -427,11 +422,6 @@ class Simplex_tree { sh->second.assign_filtration(fv); } - /** \brief Returns an upper bound of the filtration values of the simplices. */ - Filtration_value filtration() const { - return threshold_; - } - /** \brief Returns a Simplex_handle different from all Simplex_handles * associated to the simplices in the simplicial complex. * @@ -757,11 +747,6 @@ class Simplex_tree { return &root_; } - /** Set an upper bound for the filtration values. */ - void set_filtration(Filtration_value fil) { - threshold_ = fil; - } - /** Set a dimension for the simplicial complex. */ void set_dimension(int dimension) { dimension_ = dimension; @@ -1215,8 +1200,6 @@ class Simplex_tree { private: Vertex_handle null_vertex_; - /** \brief Upper bound on the filtration values of the simplices.*/ - Filtration_value threshold_; /** \brief Total number of simplices in the complex, without the empty simplex.*/ /** \brief Set of simplex tree Nodes representing the vertices.*/ Siblings root_; @@ -1244,7 +1227,6 @@ std::istream& operator>>(std::istream & is, Simplex_tree & st) { typedef Simplex_tree ST; std::vector simplex; typename ST::Filtration_value fil; - typename ST::Filtration_value max_fil = 0; int max_dim = -1; while (read_simplex(is, simplex, fil)) { // read all simplices in the file as a list of vertices @@ -1253,15 +1235,11 @@ std::istream& operator>>(std::istream & is, Simplex_tree & st) { if (max_dim < dim) { max_dim = dim; } - if (max_fil < fil) { - max_fil = fil; - } // insert every simplex in the simplex tree st.insert_simplex(simplex, fil); simplex.clear(); } st.set_dimension(max_dim); - st.set_filtration(max_fil); return is; } diff --git a/src/Simplex_tree/test/simplex_tree_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_unit_test.cpp index b06d7ec9..17ddc605 100644 --- a/src/Simplex_tree/test/simplex_tree_unit_test.cpp +++ b/src/Simplex_tree/test/simplex_tree_unit_test.cpp @@ -26,7 +26,6 @@ void test_empty_simplex_tree(typeST& tst) { typedef typename typeST::Vertex_handle Vertex_handle; const Vertex_handle DEFAULT_VERTEX_VALUE = Vertex_handle(- 1); BOOST_CHECK(tst.null_vertex() == DEFAULT_VERTEX_VALUE); - BOOST_CHECK(tst.filtration() == 0.0); BOOST_CHECK(tst.num_vertices() == (size_t) 0); BOOST_CHECK(tst.num_simplices() == (size_t) 0); typename typeST::Siblings* STRoot = tst.root(); @@ -98,12 +97,11 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_from_file, typeST, list_of_tested_var // Display the Simplex_tree std::cout << "The complex contains " << st.num_simplices() << " simplices" << std::endl; - std::cout << " - dimension " << st.dimension() << " - filtration " << st.filtration() << std::endl; + std::cout << " - dimension " << st.dimension() << std::endl; // Check BOOST_CHECK(st.num_simplices() == 143353); BOOST_CHECK(st.dimension() == 3); - BOOST_CHECK(AreAlmostTheSame(st.filtration(), 0.4)); int previous_size = 0; for (auto f_simplex : st.filtration_simplex_range()) { @@ -147,7 +145,6 @@ void test_simplex_tree_insert_returns_true(const typePairSimplexBool& returnValu } // Global variables -double max_fil = 0.0; int dim_max = -1; template @@ -158,15 +155,8 @@ void set_and_test_simplex_tree_dim_fil(typeST& simplexTree, int vectorSize, cons std::cout << " set_and_test_simplex_tree_dim_fil - dim_max=" << dim_max << std::endl; } - if (fil > max_fil) { - max_fil = fil; - simplexTree.set_filtration(max_fil); - std::cout << " set_and_test_simplex_tree_dim_fil - max_fil=" << max_fil - << std::endl; - } BOOST_CHECK(simplexTree.dimension() == dim_max); - BOOST_CHECK(AreAlmostTheSame(simplexTree.filtration(), max_fil)); // Another way to count simplices: size_t num_simp = 0; @@ -190,7 +180,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_insertion, typeST, list_of_tested_var const Filtration_value FOURTH_FILTRATION_VALUE = 0.4; // reset since we run the test several times dim_max = -1; - max_fil = 0.0; // TEST OF INSERTION std::cout << "********************************************************************" << std::endl; @@ -310,7 +299,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_insertion, typeST, list_of_tested_var BOOST_CHECK(shReturned == typename typeST::Simplex_handle(nullptr)); BOOST_CHECK(st.num_vertices() == (size_t) 4); // Not incremented !! BOOST_CHECK(st.dimension() == dim_max); - BOOST_CHECK(AreAlmostTheSame(st.filtration(), max_fil)); // ++ ELEVENTH std::cout << " - INSERT (2,1,0) (already inserted)" << std::endl; @@ -325,7 +313,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_insertion, typeST, list_of_tested_var BOOST_CHECK(shReturned == typename typeST::Simplex_handle(nullptr)); BOOST_CHECK(st.num_vertices() == (size_t) 4); // Not incremented !! BOOST_CHECK(st.dimension() == dim_max); - BOOST_CHECK(AreAlmostTheSame(st.filtration(), max_fil)); /* Inserted simplex: */ /* 1 */ @@ -365,7 +352,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_insertion, typeST, list_of_tested_var // Display the Simplex_tree - Can not be done in the middle of 2 inserts std::cout << "The complex contains " << st.num_simplices() << " simplices" << std::endl; - std::cout << " - dimension " << st.dimension() << " - filtration " << st.filtration() << std::endl; + std::cout << " - dimension " << st.dimension() << std::endl; std::cout << std::endl << std::endl << "Iterator on Simplices in the filtration, with [filtration value]:" << std::endl; for (auto f_simplex : st.filtration_simplex_range()) { std::cout << " " << "[" << st.filtration(f_simplex) << "] "; @@ -575,7 +562,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(NSimplexAndSubfaces_tree_insertion, typeST, list_o // Display the Simplex_tree - Can not be done in the middle of 2 inserts std::cout << "The complex contains " << st.num_simplices() << " simplices" << std::endl; - std::cout << " - dimension " << st.dimension() << " - filtration " << st.filtration() << std::endl; + std::cout << " - dimension " << st.dimension() << std::endl; std::cout << std::endl << std::endl << "Iterator on Simplices in the filtration, with [filtration value]:" << std::endl; for (auto f_simplex : st.filtration_simplex_range()) { std::cout << " " << "[" << st.filtration(f_simplex) << "] "; @@ -756,7 +743,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(copy_move_on_simplex_tree, typeST, list_of_tested_ typeST st_empty; // Check st has been emptied by the move BOOST_CHECK(st == st_empty); - BOOST_CHECK(st.filtration() == 0); BOOST_CHECK(st.dimension() == -1); BOOST_CHECK(st.num_simplices() == 0); BOOST_CHECK(st.num_vertices() == (size_t)0); @@ -1149,4 +1135,4 @@ BOOST_AUTO_TEST_CASE(mini_prune_above_filtration) { // Display the Simplex_tree std::cout << "The complex contains " << st.num_simplices() << " simplices" << std::endl; -} \ No newline at end of file +} diff --git a/src/cython/cython/simplex_tree.pyx b/src/cython/cython/simplex_tree.pyx index 47aa5311..45487158 100644 --- a/src/cython/cython/simplex_tree.pyx +++ b/src/cython/cython/simplex_tree.pyx @@ -36,9 +36,7 @@ cdef extern from "Simplex_tree_interface.h" namespace "Gudhi": cdef cppclass Simplex_tree_interface_full_featured "Gudhi::Simplex_tree_interface": Simplex_tree() - double filtration() double simplex_filtration(vector[int] simplex) - void set_filtration(double filtration) void initialize_filtration() int num_vertices() int num_simplices() @@ -115,14 +113,6 @@ cdef class SimplexTree: """ return self.thisptr.simplex_filtration(simplex) - def set_filtration(self, filtration): - """This function sets the main simplicial complex filtration value. - - :param filtration: The filtration value. - :type filtration: float. - """ - self.thisptr.set_filtration( filtration) - def initialize_filtration(self): """This function initializes and sorts the simplicial complex filtration vector. diff --git a/src/cython/example/simplex_tree_example.py b/src/cython/example/simplex_tree_example.py index 3af20fcf..831d9da8 100755 --- a/src/cython/example/simplex_tree_example.py +++ b/src/cython/example/simplex_tree_example.py @@ -52,7 +52,6 @@ else: st.set_dimension(3) print("dimension=", st.dimension()) -st.set_filtration(4.0) st.initialize_filtration() print("filtration=", st.get_filtration()) print("filtration[1, 2]=", st.filtration([1, 2])) diff --git a/src/cython/test/test_simplex_tree.py b/src/cython/test/test_simplex_tree.py index 3ae537e3..4d452d7d 100755 --- a/src/cython/test/test_simplex_tree.py +++ b/src/cython/test/test_simplex_tree.py @@ -53,7 +53,6 @@ def test_insertion(): assert st.find([2, 3]) == False # filtration test - st.set_filtration(5.0) st.initialize_filtration() assert st.filtration([0, 1, 2]) == 4.0 assert st.filtration([0, 2]) == 4.0 -- cgit v1.2.3 -- cgit v1.2.3 From d965a53c39266dd37cd9058837b80469347fc5d3 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 25 Sep 2017 08:47:06 +0000 Subject: Fix weighted alpha complex 3d git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/weighted_alpha_complex_fix@2709 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 3e7d1f73038d193b566e790a3095b6f802c48b48 --- .../example/weighted_alpha_complex_3d_persistence.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Persistent_cohomology/example/weighted_alpha_complex_3d_persistence.cpp b/src/Persistent_cohomology/example/weighted_alpha_complex_3d_persistence.cpp index 34b90933..ce45d16d 100644 --- a/src/Persistent_cohomology/example/weighted_alpha_complex_3d_persistence.cpp +++ b/src/Persistent_cohomology/example/weighted_alpha_complex_3d_persistence.cpp @@ -115,6 +115,7 @@ int main(int argc, char * const argv[]) { if (weights_ifstr.good()) { double weight = 0.0; std::size_t index = 0; + wp.reserve(lp.size()); // Attempt read the weight in a double format, return false if it fails while ((weights_ifstr >> weight) && (index < lp.size())) { wp.push_back(Weighted_point_3(lp[index], weight)); @@ -130,7 +131,7 @@ int main(int argc, char * const argv[]) { } // alpha shape construction from points. CGAL has a strange behavior in REGULARIZED mode. - Alpha_shape_3 as(lp.begin(), lp.end(), 0, Alpha_shape_3::GENERAL); + Alpha_shape_3 as(wp.begin(), wp.end(), 0, Alpha_shape_3::GENERAL); #ifdef DEBUG_TRACES std::cout << "Alpha shape computed in GENERAL mode" << std::endl; #endif // DEBUG_TRACES -- cgit v1.2.3 From 6965bcc31dfc44ba82524637b4184f8dfdd86e9c Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 25 Sep 2017 15:44:28 +0000 Subject: Do not advertise nor use the exact bottleneck distance version git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@2711 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: e441b042d15bfbe727789803ca17b17711a48d9c --- .../example/bottleneck_read_file_example.cpp | 12 ++++++------ src/cython/doc/bottleneck_distance_user.rst | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp b/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp index 1408681a..24d73c57 100644 --- a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp +++ b/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp @@ -25,21 +25,21 @@ #include #include #include // for pair -#include -#include #include +#include // for numeric_limits int main(int argc, char** argv) { if (argc < 3) { - std::cout << "To run this program please provide as an input two files with persistence diagrams. Each file " << - "should contain a birth-death pair per line. Third, optional parameter is an error bound on a bottleneck" << - " distance (set by default to zero). The program will now terminate \n"; + std::cout << "To run this program please provide as an input two files with persistence diagrams. Each file" << + " should contain a birth-death pair per line. Third, optional parameter is an error bound on a bottleneck" << + " distance (set by default to the smallest positive double value). If you set the error bound to 0, be" << + " aware this version is exact but expensive. The program will now terminate \n"; return -1; } std::vector> diag1 = Gudhi::read_persistence_intervals_in_dimension(argv[1]); std::vector> diag2 = Gudhi::read_persistence_intervals_in_dimension(argv[2]); - double tolerance = 0.; + double tolerance = std::numeric_limits::min(); if (argc == 4) { tolerance = atof(argv[3]); } diff --git a/src/cython/doc/bottleneck_distance_user.rst b/src/cython/doc/bottleneck_distance_user.rst index 0066992f..7692dce2 100644 --- a/src/cython/doc/bottleneck_distance_user.rst +++ b/src/cython/doc/bottleneck_distance_user.rst @@ -25,7 +25,7 @@ This example computes the bottleneck distance from 2 persistence diagrams: message = "Bottleneck distance approximation=" + '%.2f' % gudhi.bottleneck_distance(diag1, diag2, 0.1) print(message) - message = "Bottleneck distance exact value=" + '%.2f' % gudhi.bottleneck_distance(diag1, diag2, 0) + message = "Bottleneck distance value=" + '%.2f' % gudhi.bottleneck_distance(diag1, diag2) print(message) The output is: @@ -33,4 +33,4 @@ The output is: .. testoutput:: Bottleneck distance approximation=0.81 - Bottleneck distance exact value=0.75 + Bottleneck distance value=0.75 -- cgit v1.2.3 From 822765550b4f944bef11e6fe7de56fb72fb00640 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 26 Sep 2017 08:27:39 +0000 Subject: Gudhi 2.0.1-rc2 version git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@2715 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 76499766ca670017df0c963c3b5a49c343eb1a47 --- CMakeGUDHIVersion.txt | 2 +- src/Doxyfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeGUDHIVersion.txt b/CMakeGUDHIVersion.txt index d5620218..87daf28e 100644 --- a/CMakeGUDHIVersion.txt +++ b/CMakeGUDHIVersion.txt @@ -1,6 +1,6 @@ set (GUDHI_MAJOR_VERSION 2) set (GUDHI_MINOR_VERSION 0) -set (GUDHI_PATCH_VERSION 1-rc1) +set (GUDHI_PATCH_VERSION 1-rc2) set(GUDHI_VERSION ${GUDHI_MAJOR_VERSION}.${GUDHI_MINOR_VERSION}.${GUDHI_PATCH_VERSION}) message(STATUS "GUDHI version : ${GUDHI_VERSION}") diff --git a/src/Doxyfile b/src/Doxyfile index 6c01aefc..7f5975eb 100644 --- a/src/Doxyfile +++ b/src/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "GUDHI" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = "2.0.1-rc1" +PROJECT_NUMBER = "2.0.1-rc2" # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a -- cgit v1.2.3 From 697884f4193c32723922aa5edfef37d09d198fac Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 26 Sep 2017 19:57:06 +0000 Subject: Doc review : Simplex tree remove maximal simplex is an implementatino detail that is not needed by the developper git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2717 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: d096485bf30e50c804cf349f040f57764770136f --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 730b552f..fe1e87b4 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1302,10 +1302,11 @@ class Simplex_tree { public: /** \brief Remove a maximal simplex. * @param[in] sh Simplex handle on the maximal simplex to remove. - * @return true if the leaf's branch has no other leaves (branch's children has been re-assigned), false otherwise. + * @return a boolean value that is an implementation detail, and that the user is supposed to ignore * \pre Please check the simplex has no coface before removing it. * \exception std::invalid_argument In debug mode, if sh has children. * \post Be aware that removing is shifting data in a flat_map (initialize_filtration to be done). + * \internal @return true if the leaf's branch has no other leaves (branch's children has been re-assigned), false otherwise. */ bool remove_maximal_simplex(Simplex_handle sh) { // Guarantee the simplex has no children -- cgit v1.2.3 From 914398be0187ab7d21ef1100533ed7a3c7983c76 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 27 Sep 2017 20:10:05 +0000 Subject: Replace INFINITY with std::numeric_limits::infinity() git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_remove_useless_global_filtration@2719 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: b24d3381da60cd634142e3024d5f5ed53294f8e8 --- src/Hasse_complex/include/gudhi/Hasse_complex.h | 3 ++- src/Simplex_tree/include/gudhi/Simplex_tree.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Hasse_complex/include/gudhi/Hasse_complex.h b/src/Hasse_complex/include/gudhi/Hasse_complex.h index 834201a5..e67f7609 100644 --- a/src/Hasse_complex/include/gudhi/Hasse_complex.h +++ b/src/Hasse_complex/include/gudhi/Hasse_complex.h @@ -30,6 +30,7 @@ #include #include // for pair #include +#include // for infinity value #ifdef GUDHI_USE_TBB #include @@ -155,7 +156,7 @@ class Hasse_complex { Filtration_value filtration(Simplex_handle sh) { if (sh == null_simplex()) { - return INFINITY; + return std::numeric_limits::infinity(); } return complex_[sh].filtration_; } diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 8c91cc67..37b3ea97 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -402,14 +402,14 @@ class Simplex_tree { /** \brief Returns the filtration value of a simplex. * - * Called on the null_simplex, returns INFINITY. + * Called on the null_simplex, it returns infinity. * If SimplexTreeOptions::store_filtration is false, returns 0. */ static Filtration_value filtration(Simplex_handle sh) { if (sh != null_simplex()) { return sh->second.filtration(); } else { - return INFINITY; + return std::numeric_limits::infinity(); } } -- cgit v1.2.3 From 526625e6faa7b01430b481d5c21d7d7dfe16e290 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 27 Sep 2017 20:25:21 +0000 Subject: Fix some cpplints git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_remove_useless_global_filtration@2721 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 76b127e54d9511b70294ab48336ca6dbd6fdb1d6 --- ...Bitmap_cubical_complex_periodic_boundary_conditions.cpp | 1 + src/Bottleneck_distance/include/gudhi/Neighbors_finder.h | 8 ++++---- src/Spatial_searching/include/gudhi/Kd_tree_search.h | 14 ++++++-------- src/common/utilities/off_file_from_shape_generator.cpp | 2 +- src/cython/include/Reader_utils_interface.h | 2 ++ 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/Bitmap_cubical_complex/example/Bitmap_cubical_complex_periodic_boundary_conditions.cpp b/src/Bitmap_cubical_complex/example/Bitmap_cubical_complex_periodic_boundary_conditions.cpp index f8754345..122160a2 100644 --- a/src/Bitmap_cubical_complex/example/Bitmap_cubical_complex_periodic_boundary_conditions.cpp +++ b/src/Bitmap_cubical_complex/example/Bitmap_cubical_complex_periodic_boundary_conditions.cpp @@ -30,6 +30,7 @@ #include #include #include +#include int main(int argc, char** argv) { std::cout << "This program computes persistent homology, by using " << diff --git a/src/Bottleneck_distance/include/gudhi/Neighbors_finder.h b/src/Bottleneck_distance/include/gudhi/Neighbors_finder.h index bdc47578..a6b9b021 100644 --- a/src/Bottleneck_distance/include/gudhi/Neighbors_finder.h +++ b/src/Bottleneck_distance/include/gudhi/Neighbors_finder.h @@ -44,16 +44,16 @@ struct Square_query { typedef Internal_point Point_d; typedef double FT; bool contains(Point_d p) const { - return std::abs(p.x()-c.x())<=size && std::abs(p.y()-c.y())<=size; + return std::abs(p.x()-c.x()) <= size && std::abs(p.y()-c.y()) <= size; } - bool inner_range_intersects(CGAL::Kd_tree_rectangle const&r) const { + bool inner_range_intersects(CGAL::Kd_tree_rectangle const&r) const { return r.max_coord(0) >= c.x() - size && r.min_coord(0) <= c.x() + size && r.max_coord(1) >= c.y() - size && r.min_coord(1) <= c.y() + size; } - bool outer_range_contains(CGAL::Kd_tree_rectangle const&r) const { + bool outer_range_contains(CGAL::Kd_tree_rectangle const&r) const { return r.min_coord(0) >= c.x() - size && r.max_coord(0) <= c.x() + size && @@ -146,7 +146,7 @@ inline int Neighbors_finder::pull_near(int u_point_index) { // Is the query point near to a V point in the plane ? Internal_point u_point = g.get_u_point(u_point_index); auto neighbor = kd_t.search_any_point(Square_query{u_point, r}); - if(!neighbor) + if (!neighbor) return null_point_index(); tmp = neighbor->point_index; auto point = g.get_v_point(tmp); diff --git a/src/Spatial_searching/include/gudhi/Kd_tree_search.h b/src/Spatial_searching/include/gudhi/Kd_tree_search.h index a4385c84..af04736b 100644 --- a/src/Spatial_searching/include/gudhi/Kd_tree_search.h +++ b/src/Spatial_searching/include/gudhi/Kd_tree_search.h @@ -193,7 +193,7 @@ class Kd_tree_search { /// \brief Search incrementally for the nearest neighbors from a query point. /// @param[in] p The query point. /// @param[in] eps Approximation factor. - /// @return A range (whose `value_type` is `std::size_t`) containing the + /// @return A range (whose `value_type` is `std::size_t`) containing the /// neighbors sorted by their distance to p. /// All the neighbors are not computed by this function, but they will be /// computed incrementally when the iterator on the range is incremented. @@ -239,7 +239,7 @@ class Kd_tree_search { /// \brief Search incrementally for the farthest neighbors from a query point. /// @param[in] p The query point. /// @param[in] eps Approximation factor. - /// @return A range (whose `value_type` is `std::size_t`) + /// @return A range (whose `value_type` is `std::size_t`) /// containing the neighbors sorted by their distance to p. /// All the neighbors are not computed by this function, but they will be /// computed incrementally when the iterator on the range is incremented. @@ -264,12 +264,10 @@ class Kd_tree_search { /// Note: `it` is used this way: `*it++ = each_point`. /// @param[in] eps Approximation factor. template - void near_search( - Point const& p, - FT radius, - OutputIterator it, - FT eps = FT(0)) const { - + void near_search(Point const& p, + FT radius, + OutputIterator it, + FT eps = FT(0)) const { m_tree.search(it, Fuzzy_sphere(p, radius, eps, m_tree.traits())); } diff --git a/src/common/utilities/off_file_from_shape_generator.cpp b/src/common/utilities/off_file_from_shape_generator.cpp index 0f310a13..afcd558c 100644 --- a/src/common/utilities/off_file_from_shape_generator.cpp +++ b/src/common/utilities/off_file_from_shape_generator.cpp @@ -77,7 +77,7 @@ int main(int argc, char **argv) { usage(argv[0]); } - enum class Data_shape { sphere, cube, curve, torus, klein, undefined } ; + enum class Data_shape { sphere, cube, curve, torus, klein, undefined}; Data_shape shape = Data_shape::undefined; if (memcmp(argv[2], "sphere", sizeof("sphere")) == 0) { diff --git a/src/cython/include/Reader_utils_interface.h b/src/cython/include/Reader_utils_interface.h index b87b6cca..8ec34f61 100644 --- a/src/cython/include/Reader_utils_interface.h +++ b/src/cython/include/Reader_utils_interface.h @@ -28,6 +28,8 @@ #include #include #include +#include +#include // for pair<> namespace Gudhi { -- cgit v1.2.3 From 768c70aa382a7b0b561ea842720f5963a412b88e Mon Sep 17 00:00:00 2001 From: cjamin Date: Fri, 29 Sep 2017 08:40:52 +0000 Subject: Rename a few functions in Kd_tree_search git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@2730 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: f009977d25c76cc0f6116093a448fab258c8626b --- .../doc/Intro_spatial_searching.h | 2 +- .../example/example_spatial_searching.cpp | 22 +++++++------- .../include/gudhi/Kd_tree_search.h | 34 +++++++++++----------- src/Spatial_searching/test/test_Kd_tree_search.cpp | 24 +++++++-------- src/Subsampling/include/gudhi/sparsify_point_set.h | 2 +- .../include/gudhi/Tangential_complex.h | 16 +++++----- .../gudhi/Euclidean_strong_witness_complex.h | 2 +- .../include/gudhi/Euclidean_witness_complex.h | 2 +- .../test/test_euclidean_simple_witness_complex.cpp | 2 +- 9 files changed, 52 insertions(+), 54 deletions(-) diff --git a/src/Spatial_searching/doc/Intro_spatial_searching.h b/src/Spatial_searching/doc/Intro_spatial_searching.h index 22652ac4..1ee5e92e 100644 --- a/src/Spatial_searching/doc/Intro_spatial_searching.h +++ b/src/Spatial_searching/doc/Intro_spatial_searching.h @@ -46,7 +46,7 @@ namespace spatial_searching { * * \section spatial_searching_examples Example * - * This example generates 500 random points, then performs near search, and queries for nearest and farthest points using different methods. + * This example generates 500 random points, then performs all-near-neighbors searches, and queries for nearest and furthest neighbors using different methods. * * \include Spatial_searching/example_spatial_searching.cpp * diff --git a/src/Spatial_searching/example/example_spatial_searching.cpp b/src/Spatial_searching/example/example_spatial_searching.cpp index 201b589e..034ad24a 100644 --- a/src/Spatial_searching/example/example_spatial_searching.cpp +++ b/src/Spatial_searching/example/example_spatial_searching.cpp @@ -24,34 +24,34 @@ int main(void) { // 10-nearest neighbor query std::cout << "10 nearest neighbors from points[20]:\n"; - auto knn_range = points_ds.query_k_nearest_neighbors(points[20], 10, true); + auto knn_range = points_ds.k_nearest_neighbors(points[20], 10, true); for (auto const& nghb : knn_range) std::cout << nghb.first << " (sq. dist. = " << nghb.second << ")\n"; // Incremental nearest neighbor query std::cout << "Incremental nearest neighbors:\n"; - auto inn_range = points_ds.query_incremental_nearest_neighbors(points[45]); + auto inn_range = points_ds.incremental_nearest_neighbors(points[45]); // Get the neighbors in distance order until we hit the first point for (auto ins_iterator = inn_range.begin(); ins_iterator->first != 0; ++ins_iterator) std::cout << ins_iterator->first << " (sq. dist. = " << ins_iterator->second << ")\n"; - // 10-farthest neighbor query - std::cout << "10 farthest neighbors from points[20]:\n"; - auto kfn_range = points_ds.query_k_farthest_neighbors(points[20], 10, true); + // 10-furthest neighbor query + std::cout << "10 furthest neighbors from points[20]:\n"; + auto kfn_range = points_ds.k_furthest_neighbors(points[20], 10, true); for (auto const& nghb : kfn_range) std::cout << nghb.first << " (sq. dist. = " << nghb.second << ")\n"; - // Incremental farthest neighbor query - std::cout << "Incremental farthest neighbors:\n"; - auto ifn_range = points_ds.query_incremental_farthest_neighbors(points[45]); + // Incremental furthest neighbor query + std::cout << "Incremental furthest neighbors:\n"; + auto ifn_range = points_ds.incremental_furthest_neighbors(points[45]); // Get the neighbors in distance reverse order until we hit the first point for (auto ifs_iterator = ifn_range.begin(); ifs_iterator->first != 0; ++ifs_iterator) std::cout << ifs_iterator->first << " (sq. dist. = " << ifs_iterator->second << ")\n"; - // Near search - std::cout << "Near search:\n"; + // All-near-neighbors search + std::cout << "All-near-neighbors search:\n"; std::vector rs_result; - points_ds.near_search(points[45], 0.5, std::back_inserter(rs_result)); + points_ds.all_near_neighbors(points[45], 0.5, std::back_inserter(rs_result)); K k; for (auto const& p_idx : rs_result) std::cout << p_idx << " (sq. dist. = " << k.squared_distance_d_object()(points[p_idx], points[45]) << ")\n"; diff --git a/src/Spatial_searching/include/gudhi/Kd_tree_search.h b/src/Spatial_searching/include/gudhi/Kd_tree_search.h index af04736b..ef428002 100644 --- a/src/Spatial_searching/include/gudhi/Kd_tree_search.h +++ b/src/Spatial_searching/include/gudhi/Kd_tree_search.h @@ -42,19 +42,19 @@ namespace spatial_searching { /** * \class Kd_tree_search Kd_tree_search.h gudhi/Kd_tree_search.h - * \brief Spatial tree data structure to perform (approximate) nearest and farthest neighbor search. + * \brief Spatial tree data structure to perform (approximate) nearest and furthest neighbor search. * * \ingroup spatial_searching * * \details * The class Kd_tree_search is a tree-based data structure, based on * CGAL dD spatial searching data structures. - * It provides a simplified API to perform (approximate) nearest and farthest neighbor searches. Contrary to CGAL default behavior, the tree + * It provides a simplified API to perform (approximate) nearest and furthest neighbor searches. Contrary to CGAL default behavior, the tree * does not store the points themselves, but stores indices. * - * There are two types of queries: the k-nearest or k-farthest neighbor query, where k is fixed and the k nearest - * or farthest points are computed right away, - * and the incremental nearest or farthest neighbor query, where no number of neighbors is provided during the call, as the + * There are two types of queries: the k-nearest or k-furthest neighbor query, where k is fixed and the k nearest + * or furthest points are computed right away, + * and the incremental nearest or furthest neighbor query, where no number of neighbors is provided during the call, as the * neighbors will be computed incrementally when the iterator on the range is incremented. * * \tparam Search_traits must be a model of the K_neighbor_search; typedef typename K_neighbor_search::Tree Tree; typedef typename K_neighbor_search::Distance Distance; - /// \brief The range returned by a k-nearest or k-farthest neighbor search. + /// \brief The range returned by a k-nearest or k-furthest neighbor search. /// Its value type is `std::pair` where `first` is the index /// of a point P and `second` is the squared distance between P and the query point. typedef K_neighbor_search KNS_range; @@ -104,7 +104,7 @@ class Kd_tree_search { typedef CGAL::Orthogonal_incremental_neighbor_search< STraits, Distance, CGAL::Sliding_midpoint, Tree> Incremental_neighbor_search; - /// \brief The range returned by an incremental nearest or farthest neighbor search. + /// \brief The range returned by an incremental nearest or furthest neighbor search. /// Its value type is `std::pair` where `first` is the index /// of a point P and `second` is the squared distance between P and the query point. typedef Incremental_neighbor_search INS_range; @@ -171,7 +171,7 @@ class Kd_tree_search { /// @param[in] sorted Indicates if the computed sequence of k-nearest neighbors needs to be sorted. /// @param[in] eps Approximation factor. /// @return A range (whose `value_type` is `std::size_t`) containing the k-nearest neighbors. - KNS_range query_k_nearest_neighbors( + KNS_range k_nearest_neighbors( Point const& p, unsigned int k, bool sorted = true, @@ -197,7 +197,7 @@ class Kd_tree_search { /// neighbors sorted by their distance to p. /// All the neighbors are not computed by this function, but they will be /// computed incrementally when the iterator on the range is incremented. - INS_range query_incremental_nearest_neighbors(Point const& p, FT eps = FT(0)) const { + INS_range incremental_nearest_neighbors(Point const& p, FT eps = FT(0)) const { // Initialize the search structure, and search all N points // Note that we need to pass the Distance explicitly since it needs to // know the property map @@ -211,13 +211,13 @@ class Kd_tree_search { return search; } - /// \brief Search for the k-farthest points from a query point. + /// \brief Search for the k-furthest points from a query point. /// @param[in] p The query point. - /// @param[in] k Number of farthest points to search. - /// @param[in] sorted Indicates if the computed sequence of k-farthest neighbors needs to be sorted. + /// @param[in] k Number of furthest points to search. + /// @param[in] sorted Indicates if the computed sequence of k-furthest neighbors needs to be sorted. /// @param[in] eps Approximation factor. - /// @return A range (whose `value_type` is `std::size_t`) containing the k-farthest neighbors. - KNS_range query_k_farthest_neighbors( + /// @return A range (whose `value_type` is `std::size_t`) containing the k-furthest neighbors. + KNS_range k_furthest_neighbors( Point const& p, unsigned int k, bool sorted = true, @@ -236,14 +236,14 @@ class Kd_tree_search { return search; } - /// \brief Search incrementally for the farthest neighbors from a query point. + /// \brief Search incrementally for the furthest neighbors from a query point. /// @param[in] p The query point. /// @param[in] eps Approximation factor. /// @return A range (whose `value_type` is `std::size_t`) /// containing the neighbors sorted by their distance to p. /// All the neighbors are not computed by this function, but they will be /// computed incrementally when the iterator on the range is incremented. - INS_range query_incremental_farthest_neighbors(Point const& p, FT eps = FT(0)) const { + INS_range incremental_furthest_neighbors(Point const& p, FT eps = FT(0)) const { // Initialize the search structure, and search all N points // Note that we need to pass the Distance explicitly since it needs to // know the property map @@ -264,7 +264,7 @@ class Kd_tree_search { /// Note: `it` is used this way: `*it++ = each_point`. /// @param[in] eps Approximation factor. template - void near_search(Point const& p, + void all_near_neighbors(Point const& p, FT radius, OutputIterator it, FT eps = FT(0)) const { diff --git a/src/Spatial_searching/test/test_Kd_tree_search.cpp b/src/Spatial_searching/test/test_Kd_tree_search.cpp index 663a103a..8a8334c3 100644 --- a/src/Spatial_searching/test/test_Kd_tree_search.cpp +++ b/src/Spatial_searching/test/test_Kd_tree_search.cpp @@ -48,12 +48,12 @@ BOOST_AUTO_TEST_CASE(test_Kd_tree_search) { Points_ds points_ds(points); - // Test query_k_nearest_neighbors + // Test k_nearest_neighbors std::size_t closest_pt_index = - points_ds.query_k_nearest_neighbors(points[10], 1, false).begin()->first; + points_ds.k_nearest_neighbors(points[10], 1, false).begin()->first; BOOST_CHECK(closest_pt_index == 10); - auto kns_range = points_ds.query_k_nearest_neighbors(points[20], 10, true); + auto kns_range = points_ds.k_nearest_neighbors(points[20], 10, true); std::vector knn_result; FT last_dist = -1.; @@ -63,12 +63,12 @@ BOOST_AUTO_TEST_CASE(test_Kd_tree_search) { last_dist = nghb.second; } - // Test query_incremental_nearest_neighbors + // Test incremental_nearest_neighbors closest_pt_index = - points_ds.query_incremental_nearest_neighbors(points[10]).begin()->first; + points_ds.incremental_nearest_neighbors(points[10]).begin()->first; BOOST_CHECK(closest_pt_index == 10); - auto inn_range = points_ds.query_incremental_nearest_neighbors(points[20]); + auto inn_range = points_ds.incremental_nearest_neighbors(points[20]); std::vector inn_result; last_dist = -1.; @@ -83,8 +83,8 @@ BOOST_AUTO_TEST_CASE(test_Kd_tree_search) { // Same result for KNN and INN? BOOST_CHECK(knn_result == inn_result); - // Test query_k_farthest_neighbors - auto kfn_range = points_ds.query_k_farthest_neighbors(points[20], 10, true); + // Test k_furthest_neighbors + auto kfn_range = points_ds.k_furthest_neighbors(points[20], 10, true); std::vector kfn_result; last_dist = kfn_range.begin()->second; @@ -94,8 +94,8 @@ BOOST_AUTO_TEST_CASE(test_Kd_tree_search) { last_dist = nghb.second; } - // Test query_k_farthest_neighbors - auto ifn_range = points_ds.query_incremental_farthest_neighbors(points[20]); + // Test k_furthest_neighbors + auto ifn_range = points_ds.incremental_furthest_neighbors(points[20]); std::vector ifn_result; last_dist = ifn_range.begin()->second; @@ -110,10 +110,10 @@ BOOST_AUTO_TEST_CASE(test_Kd_tree_search) { // Same result for KFN and IFN? BOOST_CHECK(kfn_result == ifn_result); - // Test near search + // Test all_near_neighbors Point rs_q(rd.get_double(-1., 1), rd.get_double(-1., 1), rd.get_double(-1., 1), rd.get_double(-1., 1)); std::vector rs_result; - points_ds.near_search(rs_q, 0.5, std::back_inserter(rs_result)); + points_ds.all_near_neighbors(rs_q, 0.5, std::back_inserter(rs_result)); K k; for (auto const& p_idx : rs_result) BOOST_CHECK(k.squared_distance_d_object()(points[p_idx], rs_q) <= 0.5); diff --git a/src/Subsampling/include/gudhi/sparsify_point_set.h b/src/Subsampling/include/gudhi/sparsify_point_set.h index 507f8c79..7d3b97fb 100644 --- a/src/Subsampling/include/gudhi/sparsify_point_set.h +++ b/src/Subsampling/include/gudhi/sparsify_point_set.h @@ -83,7 +83,7 @@ sparsify_point_set( *output_it++ = *it_pt; - auto ins_range = points_ds.query_incremental_nearest_neighbors(*it_pt); + auto ins_range = points_ds.incremental_nearest_neighbors(*it_pt); // If another point Q is closer that min_squared_dist, mark Q to be dropped for (auto const& neighbor : ins_range) { diff --git a/src/Tangential_complex/include/gudhi/Tangential_complex.h b/src/Tangential_complex/include/gudhi/Tangential_complex.h index 9fa7c825..a5cefd6a 100644 --- a/src/Tangential_complex/include/gudhi/Tangential_complex.h +++ b/src/Tangential_complex/include/gudhi/Tangential_complex.h @@ -1093,8 +1093,8 @@ class Tangential_complex { std::size_t num_inserted_points = 1; #endif // const int NUM_NEIGHBORS = 150; - // KNS_range ins_range = m_points_ds.query_k_nearest_neighbors(center_pt, NUM_NEIGHBORS); - INS_range ins_range = m_points_ds.query_incremental_nearest_neighbors(center_pt); + // KNS_range ins_range = m_points_ds.k_nearest_neighbors(center_pt, NUM_NEIGHBORS); + INS_range ins_range = m_points_ds.incremental_nearest_neighbors(center_pt); // While building the local triangulation, we keep the radius // of the sphere "star sphere" centered at "center_vertex" @@ -1203,7 +1203,7 @@ class Tangential_complex { Point center_point = compute_perturbed_point(i); // Among updated point, what is the closer from our center point? std::size_t closest_pt_index = - updated_pts_ds.query_k_nearest_neighbors(center_point, 1, false).begin()->first; + updated_pts_ds.k_nearest_neighbors(center_point, 1, false).begin()->first; typename K::Construct_weighted_point_d k_constr_wp = m_k.construct_weighted_point_d_object(); @@ -1315,11 +1315,10 @@ class Tangential_complex { m_k.compute_coordinate_d_object(); #ifdef GUDHI_TC_USE_ANOTHER_POINT_SET_FOR_TANGENT_SPACE_ESTIM - KNS_range kns_range = m_points_ds_for_tse.query_k_nearest_neighbors( - p, num_pts_for_pca, false); + KNS_range kns_range = m_points_ds_for_tse.k_nearest_neighbors(p, num_pts_for_pca, false); const Points &points_for_pca = m_points_for_tse; #else - KNS_range kns_range = m_points_ds.query_k_nearest_neighbors(p, num_pts_for_pca, false); + KNS_range kns_range = m_points_ds.k_nearest_neighbors(p, num_pts_for_pca, false); const Points &points_for_pca = m_points; #endif @@ -1413,11 +1412,10 @@ class Tangential_complex { const Point &p = m_points[*it_index]; #ifdef GUDHI_TC_USE_ANOTHER_POINT_SET_FOR_TANGENT_SPACE_ESTIM - KNS_range kns_range = m_points_ds_for_tse.query_k_nearest_neighbors( - p, num_pts_for_pca, false); + KNS_range kns_range = m_points_ds_for_tse.k_nearest_neighbors(p, num_pts_for_pca, false); const Points &points_for_pca = m_points_for_tse; #else - KNS_range kns_range = m_points_ds.query_k_nearest_neighbors(p, num_pts_for_pca, false); + KNS_range kns_range = m_points_ds.k_nearest_neighbors(p, num_pts_for_pca, false); const Points &points_for_pca = m_points; #endif diff --git a/src/Witness_complex/include/gudhi/Euclidean_strong_witness_complex.h b/src/Witness_complex/include/gudhi/Euclidean_strong_witness_complex.h index fb669ef8..4f3cef4f 100644 --- a/src/Witness_complex/include/gudhi/Euclidean_strong_witness_complex.h +++ b/src/Witness_complex/include/gudhi/Euclidean_strong_witness_complex.h @@ -84,7 +84,7 @@ class Euclidean_strong_witness_complex : landmarks_(std::begin(landmarks), std::end(landmarks)), landmark_tree_(landmarks_) { nearest_landmark_table_.reserve(boost::size(witnesses)); for (auto w : witnesses) - nearest_landmark_table_.push_back(landmark_tree_.query_incremental_nearest_neighbors(w)); + nearest_landmark_table_.push_back(landmark_tree_.incremental_nearest_neighbors(w)); } /** \brief Returns the point corresponding to the given vertex. diff --git a/src/Witness_complex/include/gudhi/Euclidean_witness_complex.h b/src/Witness_complex/include/gudhi/Euclidean_witness_complex.h index 6afe9a5d..ff8bb139 100644 --- a/src/Witness_complex/include/gudhi/Euclidean_witness_complex.h +++ b/src/Witness_complex/include/gudhi/Euclidean_witness_complex.h @@ -86,7 +86,7 @@ class Euclidean_witness_complex : landmarks_(std::begin(landmarks), std::end(landmarks)), landmark_tree_(landmarks) { nearest_landmark_table_.reserve(boost::size(witnesses)); for (auto w : witnesses) - nearest_landmark_table_.push_back(landmark_tree_.query_incremental_nearest_neighbors(w)); + nearest_landmark_table_.push_back(landmark_tree_.incremental_nearest_neighbors(w)); } /** \brief Returns the point corresponding to the given vertex. diff --git a/src/Witness_complex/test/test_euclidean_simple_witness_complex.cpp b/src/Witness_complex/test/test_euclidean_simple_witness_complex.cpp index 62fd1157..4f718203 100644 --- a/src/Witness_complex/test/test_euclidean_simple_witness_complex.cpp +++ b/src/Witness_complex/test/test_euclidean_simple_witness_complex.cpp @@ -75,7 +75,7 @@ BOOST_AUTO_TEST_CASE(simple_witness_complex) { Kd_tree landmark_tree(landmarks); Nearest_landmark_table nearest_landmark_table; for (auto w: witnesses) - nearest_landmark_table.push_back(landmark_tree.query_incremental_nearest_neighbors(w)); + nearest_landmark_table.push_back(landmark_tree.incremental_nearest_neighbors(w)); // Weak witness complex: Euclidean version EuclideanWitnessComplex eucl_witness_complex(landmarks, -- cgit v1.2.3 From 36d71f6a62d0390c5a8193171c92e75a85889b4a Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 29 Sep 2017 21:06:08 +0000 Subject: Doc issue fix git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@2733 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: ea0323fed1ca42ecee50d6fbf9db9fbfb3e64cc9 --- src/Persistent_cohomology/doc/Intro_persistent_cohomology.h | 11 ++++++----- src/cython/doc/cubical_complex_user.rst | 8 ++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h b/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h index e17e5926..6400116b 100644 --- a/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h +++ b/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h @@ -189,10 +189,10 @@ and a weights file. \code $> ./weighted_alpha_complex_3d_persistence ../../data/points/tore3D_300.off ../../data/points/tore3D_300.weights 2 0.45 \endcode \code Simplex_tree dim: 3 -2 -0 0 inf -2 1 0.0682162 1.0001 -2 1 0.0934117 1.00003 -2 2 0.56444 1.03938 \endcode +2 0 -1 inf +2 1 -0.931784 0.000103311 +2 1 -0.906588 2.60165e-05 +2 2 -0.43556 0.0393798 \endcode \li Persistent_cohomology/alpha_complex_persistence.cpp computes the persistent homology with @@ -208,7 +208,8 @@ Simplex_tree dim: 3 \li Persistent_cohomology/periodic_alpha_complex_3d_persistence.cpp computes the persistent homology with \f$\mathbb{Z}/2\mathbb{Z}\f$ coefficients of the periodic alpha complex on points sampling from an OFF file. -\code $> ./periodic_alpha_complex_3d_persistence ../../data/points/grid_10_10_10_in_0_1.off 3 1.0 \endcode +\code $> ./periodic_alpha_complex_3d_persistence ../../data/points/grid_10_10_10_in_0_1.off +../../data/points/iso_cuboid_3_in_0_1.txt 3 1.0 \endcode \code Periodic Delaunay computed. Simplex_tree dim: 3 3 0 0 inf diff --git a/src/cython/doc/cubical_complex_user.rst b/src/cython/doc/cubical_complex_user.rst index 36fa3ba9..4f902d0a 100644 --- a/src/cython/doc/cubical_complex_user.rst +++ b/src/cython/doc/cubical_complex_user.rst @@ -59,7 +59,7 @@ directions, allows to determine, dimension, neighborhood, boundary and coboundar :math:`C \in \mathcal{K}`. .. figure:: - img/Cubical_complex_representation.png + ../../doc/Bitmap_cubical_complex/Cubical_complex_representation.png :alt: Cubical complex. :figclass: align-center @@ -87,7 +87,7 @@ in the example below). Next, in lexicographical order, the filtration of top dim 20 4 7 6 5 in the example below). .. figure:: - img/exampleBitmap.png + ../../doc/Bitmap_cubical_complex/exampleBitmap.png :alt: Example of a input data. :figclass: align-center @@ -97,7 +97,7 @@ The input file for the following complex is: .. literalinclude:: cubicalcomplexdoc.txt -.. centered:: data/bitmap/cubicalcomplexdoc.txt +.. centered:: ../../data/bitmap/cubicalcomplexdoc.txt .. testcode:: @@ -130,7 +130,7 @@ For instance: .. literalinclude:: periodiccubicalcomplexdoc.txt -.. centered:: data/bitmap/periodiccubicalcomplexdoc.txt +.. centered:: ../../data/bitmap/periodiccubicalcomplexdoc.txt Indicate that we have imposed periodic boundary conditions in the direction x, but not in the direction y. -- cgit v1.2.3 From b9132f99c06c91f825854073512eacd87624579e Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 29 Sep 2017 21:08:06 +0000 Subject: Gudhi version 2.0.1 git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@2734 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 3ce829b94a61b9649b663ee85bc68b74f75eb59e --- CMakeGUDHIVersion.txt | 2 +- src/Doxyfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeGUDHIVersion.txt b/CMakeGUDHIVersion.txt index 87daf28e..bfef1590 100644 --- a/CMakeGUDHIVersion.txt +++ b/CMakeGUDHIVersion.txt @@ -1,6 +1,6 @@ set (GUDHI_MAJOR_VERSION 2) set (GUDHI_MINOR_VERSION 0) -set (GUDHI_PATCH_VERSION 1-rc2) +set (GUDHI_PATCH_VERSION 1) set(GUDHI_VERSION ${GUDHI_MAJOR_VERSION}.${GUDHI_MINOR_VERSION}.${GUDHI_PATCH_VERSION}) message(STATUS "GUDHI version : ${GUDHI_VERSION}") diff --git a/src/Doxyfile b/src/Doxyfile index 7f5975eb..0ef81e5c 100644 --- a/src/Doxyfile +++ b/src/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "GUDHI" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = "2.0.1-rc2" +PROJECT_NUMBER = "2.0.1" # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a -- cgit v1.2.3 From 8868bb6e355a4aec8e084aaf73a1ed1cf47a8589 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 29 Sep 2017 21:43:01 +0000 Subject: Build doc issue git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@2736 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 438179e355d47083f9db2c237d7ceb132c7b0168 --- src/cython/doc/cubical_complex_user.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cython/doc/cubical_complex_user.rst b/src/cython/doc/cubical_complex_user.rst index 4f902d0a..2bfac62a 100644 --- a/src/cython/doc/cubical_complex_user.rst +++ b/src/cython/doc/cubical_complex_user.rst @@ -95,7 +95,7 @@ in the example below). Next, in lexicographical order, the filtration of top dim The input file for the following complex is: -.. literalinclude:: cubicalcomplexdoc.txt +.. literalinclude:: ../../data/bitmap/cubicalcomplexdoc.txt .. centered:: ../../data/bitmap/cubicalcomplexdoc.txt @@ -128,7 +128,7 @@ complex with periodic boundary conditions. One can also use Perseus style input conditions in a given direction, then number of top dimensional cells in this direction have to be multiplied by -1. For instance: -.. literalinclude:: periodiccubicalcomplexdoc.txt +.. literalinclude:: ../../data/bitmap/periodiccubicalcomplexdoc.txt .. centered:: ../../data/bitmap/periodiccubicalcomplexdoc.txt -- cgit v1.2.3 From 8d21e4d56cc40e94b395a3a497757c149b4b9f1c Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Sun, 1 Oct 2017 20:35:12 +0000 Subject: Euclidean Witness examples requires CGAL >= 4.8.1 because it is using subsampling (CMake and install doc) Bad link to Gudhi bibtex git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@2741 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 8c1b84a4030029ec7d1470c49662e15836cf02de --- src/cython/CMakeLists.txt | 25 +++++++++++++------------ src/cython/doc/citation.rst | 2 +- src/cython/doc/installation.rst | 23 ++++++++++++----------- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index ec8589f0..afca9d60 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -185,6 +185,19 @@ if(CYTHON_FOUND) add_gudhi_py_test(test_tangential_complex) + # Witness complex AND Subsampling + add_test(NAME euclidean_strong_witness_complex_diagram_persistence_from_off_file_example_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" + ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py" + --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -a 1.0 -n 20 -d 2) + + add_test(NAME euclidean_witness_complex_diagram_persistence_from_off_file_example_py_test + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" + ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py" + --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -a 1.0 -n 20 -d 2) + # Subsampling add_gudhi_py_test(test_subsampling) @@ -218,18 +231,6 @@ if(CYTHON_FOUND) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.6.0) # Euclidean witness - add_test(NAME euclidean_strong_witness_complex_diagram_persistence_from_off_file_example_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" - ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py" - --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -a 1.0 -n 20 -d 2) - - add_test(NAME euclidean_witness_complex_diagram_persistence_from_off_file_example_py_test - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" - ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py" - --no-diagram -f ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off -a 1.0 -n 20 -d 2) - add_gudhi_py_test(test_euclidean_witness_complex) endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.6.0) diff --git a/src/cython/doc/citation.rst b/src/cython/doc/citation.rst index 6cdfb7cc..f4fdf83b 100644 --- a/src/cython/doc/citation.rst +++ b/src/cython/doc/citation.rst @@ -12,4 +12,4 @@ Manual, as well as for publications directly related to the GUDHI library. GUDHI bibtex ************ -.. literalinclude:: how_to_cite_gudhi.bib +.. literalinclude:: ../../biblio/how_to_cite_gudhi.bib diff --git a/src/cython/doc/installation.rst b/src/cython/doc/installation.rst index f98a5039..c182f176 100644 --- a/src/cython/doc/installation.rst +++ b/src/cython/doc/installation.rst @@ -68,31 +68,32 @@ The :doc:`Alpha complex `, C++ library which provides easy access to efficient and reliable geometric algorithms. -Having CGAL version 4.6.0 or higher installed is recommended. The procedure to -install this library according to your operating system is detailed +Having CGAL, the Computational Geometry Algorithms Library, version 4.7.0 or +higher installed is recommended. The procedure to install this library +according to your operating system is detailed `here `_. -The following examples require the Computational Geometry Algorithms Library: - -.. only:: builder_html - - * :download:`euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py <../example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py>` - * :download:`euclidean_witness_complex_diagram_persistence_from_off_file_example.py <../example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py>` - -The following example requires CGAL version ≥ 4.7.0: +The following examples requires CGAL version ≥ 4.7.0: .. only:: builder_html * :download:`alpha_complex_diagram_persistence_from_off_file_example.py <../example/alpha_complex_diagram_persistence_from_off_file_example.py>` * :download:`alpha_complex_from_points_example.py <../example/alpha_complex_from_points_example.py>` -The following example requires CGAL version ≥ 4.8.0: +The following examples requires CGAL version ≥ 4.8.0: .. only:: builder_html * :download:`bottleneck_basic_example.py <../example/bottleneck_basic_example.py>` * :download:`tangential_complex_plain_homology_from_off_file_example.py <../example/tangential_complex_plain_homology_from_off_file_example.py>` +The following examples requires CGAL version ≥ 4.8.1: + +.. only:: builder_html + + * :download:`euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py <../example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py>` + * :download:`euclidean_witness_complex_diagram_persistence_from_off_file_example.py <../example/euclidean_witness_complex_diagram_persistence_from_off_file_example.py>` + Eigen3 ====== -- cgit v1.2.3 From b9d4c8c0073fbd8c0b0bf999ae6ee7d3de60501d Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 5 Oct 2017 17:16:48 +0000 Subject: Doc review : fix find_child explanation git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2758 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 30759214110b29a525cbbf2d97ff84b92b4eace2 --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index fe1e87b4..a8c01f84 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1177,7 +1177,7 @@ class Simplex_tree { } /* \private Returns the Simplex_handle composed of the vertex list (from the Simplex_handle), plus the given - * Vertex_handle. + * Vertex_handle if the Vertex_handle is found in the Simplex_handle children list. * Returns null_simplex() if it does not exist */ Simplex_handle find_child(Simplex_handle sh, Vertex_handle vh) const { -- cgit v1.2.3 From f0cd234b570b0d48c7b5e83af9ce5925eeb40961 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 5 Oct 2017 17:59:50 +0000 Subject: Doc review : prune_above_filtration about automatic_dimension_set mechanism was too strict. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_automatic_dimension_set@2760 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: bccef80ba3f70f87dff28cfa3a85c50f072f695e --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index fd6cd72a..6494aa5d 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1161,8 +1161,9 @@ class Simplex_tree { * \post Some simplex tree functions require the filtration to be valid. `prune_above_filtration()` * function is not launching `initialize_filtration()` but returns the filtration modification information. If the * complex has changed , please call `initialize_filtration()` to recompute it. - * \post Be aware that `prune_above_filtration()` may change the simplex tree dimension (`automatic_dimension_set()` - * to be done). + * \post Note that the dimension of the simplicial complex may be lower after calling `prune_above_filtration()` + * than it was before. However, `Simplex_tree::dimension()` will return the old value, which remains a valid upper + * bound. If you care, you can call `automatic_dimension_set()` to recompute the exact dimension. */ bool prune_above_filtration(Filtration_value filtration) { return rec_prune_above_filtration(root(), filtration); -- cgit v1.2.3 From 479bcccbaede8aa59ae28c8cd9b15de08053a817 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 5 Oct 2017 18:03:24 +0000 Subject: Doc review : automatic_dimension_set return documentation was not clear git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_automatic_dimension_set@2761 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 04b4dee9d228923f36062001529476251eac4ef0 --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 6494aa5d..8a827086 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1196,7 +1196,7 @@ class Simplex_tree { public: /** \brief Deep search simplex tree dimension reset. - * @return The dimension modification information. + * @return True if the dimension was modified, false otherwise. * \pre Be sure the simplex tree has not a too low dimension value as the deep search stops when the former dimension * has been reached (cf. `dimension()` and `set_dimension()` methods). */ -- cgit v1.2.3 From 4e3cf64d56874353aea48ccc1820069bbf37671a Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 19 Oct 2017 20:35:41 +0000 Subject: Code review : remove template specification for std::max Fix cython tests accordingly to the other modifications git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_automatic_dimension_set@2794 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: e1009a3304455fa26fbd368c4cce4451bc3d7784 --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 4 ++-- src/cython/test/test_simplex_tree.py | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 8a827086..a2febe54 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1202,7 +1202,7 @@ class Simplex_tree { */ bool automatic_dimension_set() { int new_dimension = -1; - // Browse the tree from te left to the right as higher dimension cells are more likely on the left part of the tree + // Browse the tree from the left to the right as higher dimension cells are more likely on the left part of the tree for (Simplex_handle sh : skeleton_simplex_range(dimension_)) { #ifdef DEBUG_TRACES for (auto vertex : simplex_vertex_range(sh)) { @@ -1215,7 +1215,7 @@ class Simplex_tree { if (sh_dimension >= dimension_) // Stop browsing as soon as the dimension is reached, no need to go furter return false; - new_dimension = std::max(new_dimension, sh_dimension); + new_dimension = std::max(new_dimension, sh_dimension); } dimension_ = new_dimension; return true; diff --git a/src/cython/test/test_simplex_tree.py b/src/cython/test/test_simplex_tree.py index a6d6a9f3..177cfdad 100755 --- a/src/cython/test/test_simplex_tree.py +++ b/src/cython/test/test_simplex_tree.py @@ -94,12 +94,12 @@ def test_insertion(): assert st.persistence(persistence_dim_max = True) == [(1, (4.0, float('inf'))), (0, (0.0, float('inf')))] assert st.__is_persistence_defined() == True - assert st.betti_numbers() == [1, 1] - assert st.persistent_betti_numbers(-0.1, 10000.0) == [0, 0] - assert st.persistent_betti_numbers(0.0, 10000.0) == [1, 0] - assert st.persistent_betti_numbers(3.9, 10000.0) == [1, 0] - assert st.persistent_betti_numbers(4.0, 10000.0) == [1, 1] - assert st.persistent_betti_numbers(9999.0, 10000.0) == [1, 1] + assert st.betti_numbers() == [1, 1, 0] + assert st.persistent_betti_numbers(-0.1, 10000.0) == [0, 0, 0] + assert st.persistent_betti_numbers(0.0, 10000.0) == [1, 0, 0] + assert st.persistent_betti_numbers(3.9, 10000.0) == [1, 0, 0] + assert st.persistent_betti_numbers(4.0, 10000.0) == [1, 1, 0] + assert st.persistent_betti_numbers(9999.0, 10000.0) == [1, 1, 0] def test_expansion(): st = SimplexTree() -- cgit v1.2.3 From e36dafedbab909ef1d16eceb133cd8b80dd1763d Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 20 Oct 2017 08:10:05 +0000 Subject: Doc review: remove_maximal_simplex about automatic_dimension_set mechanism was too strict. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_automatic_dimension_set@2795 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 0226b3ee6a082b109185c9eff8c1601b61d4f667 --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index a2febe54..7841c793 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1228,7 +1228,9 @@ class Simplex_tree { * \pre Please check the simplex has no coface before removing it. * \exception std::invalid_argument In debug mode, if sh has children. * \post Be aware that removing is shifting data in a flat_map (`initialize_filtration()` to be done). - * \post Be aware that removing may change the simplex tree dimension (`automatic_dimension_set()` to be done). + * \post Note that the dimension of the simplicial complex may be lower after calling `remove_maximal_simplex()` + * than it was before. However, `Simplex_tree::dimension()` will return the old value, which remains a valid upper + * bound. If you care, you can call `automatic_dimension_set()` to recompute the exact dimension. */ void remove_maximal_simplex(Simplex_handle sh) { // Guarantee the simplex has no children -- cgit v1.2.3 From 6fff7c1774365f99c93d57bdf3595e6b89f16b0a Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 20 Oct 2017 08:24:03 +0000 Subject: Code review : rename automatic_dimension_set with downgrade_dimension git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_automatic_dimension_set@2796 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 3b094bc579367d40790c3791f2c4a3700a3d93ae --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 8 ++++---- .../test/simplex_tree_remove_unit_test.cpp | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 7841c793..986cc071 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1163,7 +1163,7 @@ class Simplex_tree { * complex has changed , please call `initialize_filtration()` to recompute it. * \post Note that the dimension of the simplicial complex may be lower after calling `prune_above_filtration()` * than it was before. However, `Simplex_tree::dimension()` will return the old value, which remains a valid upper - * bound. If you care, you can call `automatic_dimension_set()` to recompute the exact dimension. + * bound. If you care, you can call `downgrade_dimension()` to recompute the exact dimension. */ bool prune_above_filtration(Filtration_value filtration) { return rec_prune_above_filtration(root(), filtration); @@ -1195,12 +1195,12 @@ class Simplex_tree { } public: - /** \brief Deep search simplex tree dimension reset. + /** \brief Deep search simplex tree dimension recompute. * @return True if the dimension was modified, false otherwise. * \pre Be sure the simplex tree has not a too low dimension value as the deep search stops when the former dimension * has been reached (cf. `dimension()` and `set_dimension()` methods). */ - bool automatic_dimension_set() { + bool downgrade_dimension() { int new_dimension = -1; // Browse the tree from the left to the right as higher dimension cells are more likely on the left part of the tree for (Simplex_handle sh : skeleton_simplex_range(dimension_)) { @@ -1230,7 +1230,7 @@ class Simplex_tree { * \post Be aware that removing is shifting data in a flat_map (`initialize_filtration()` to be done). * \post Note that the dimension of the simplicial complex may be lower after calling `remove_maximal_simplex()` * than it was before. However, `Simplex_tree::dimension()` will return the old value, which remains a valid upper - * bound. If you care, you can call `automatic_dimension_set()` to recompute the exact dimension. + * bound. If you care, you can call `downgrade_dimension()` to recompute the exact dimension. */ void remove_maximal_simplex(Simplex_handle sh) { // Guarantee the simplex has no children diff --git a/src/Simplex_tree/test/simplex_tree_remove_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_remove_unit_test.cpp index 87c77801..747e7eeb 100644 --- a/src/Simplex_tree/test/simplex_tree_remove_unit_test.cpp +++ b/src/Simplex_tree/test/simplex_tree_remove_unit_test.cpp @@ -112,7 +112,7 @@ BOOST_AUTO_TEST_CASE(remove_maximal_simplex) { std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == 3); - st.automatic_dimension_set(); + st.downgrade_dimension(); std::cout << "st.dimension()=" << st.dimension() << " | st_wo_seven.dimension()=" << st_wo_seven.dimension() << std::endl; BOOST_CHECK(st == st_wo_seven); @@ -152,7 +152,7 @@ BOOST_AUTO_TEST_CASE(auto_dimension_set) { st.remove_maximal_simplex(st.find({1, 2, 3, 5})); std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == 3); - st.automatic_dimension_set(); + st.downgrade_dimension(); std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == 2); @@ -175,7 +175,7 @@ BOOST_AUTO_TEST_CASE(auto_dimension_set) { st.remove_maximal_simplex(st.find({1, 2, 3, 4})); std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == 3); - st.automatic_dimension_set(); + st.downgrade_dimension(); std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == 2); @@ -188,7 +188,7 @@ BOOST_AUTO_TEST_CASE(auto_dimension_set) { st.remove_maximal_simplex(st.find({0, 1, 3, 4})); std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == 3); - st.automatic_dimension_set(); + st.downgrade_dimension(); std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == 2); @@ -208,9 +208,9 @@ BOOST_AUTO_TEST_CASE(auto_dimension_set) { st.set_dimension(1); std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == 1); - st.automatic_dimension_set(); + st.downgrade_dimension(); std::cout << "st.dimension()=" << st.dimension() << std::endl; - // check automatic_dimension_set() is not giving the rigt answer because dimension is too low + // check downgrade_dimension() is not giving the rigt answer because dimension is too low BOOST_CHECK(st.dimension() == 1); @@ -219,9 +219,9 @@ BOOST_AUTO_TEST_CASE(auto_dimension_set) { st.set_dimension(6); std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == 6); - st.automatic_dimension_set(); + st.downgrade_dimension(); std::cout << "st.dimension()=" << st.dimension() << std::endl; - // check automatic_dimension_set() resets the correct dimension + // check downgrade_dimension() resets the correct dimension BOOST_CHECK(st.dimension() == 3); @@ -239,7 +239,7 @@ BOOST_AUTO_TEST_CASE(auto_dimension_set) { st.remove_maximal_simplex(st.find({0, 1, 2, 3, 4, 5, 6})); std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == 6); - st.automatic_dimension_set(); + st.downgrade_dimension(); std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == 5); @@ -344,7 +344,7 @@ BOOST_AUTO_TEST_CASE(prune_above_filtration) { std::cout << " - dimension " << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == 3); - st.automatic_dimension_set(); + st.downgrade_dimension(); std::cout << "dimension=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == -1); -- cgit v1.2.3 From 0f7b41e0357063fcb8a06b17b90fe9fe7b4bda83 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 20 Oct 2017 14:18:03 +0000 Subject: Use simplices iterator instead of skeleton iterator git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_automatic_dimension_set@2798 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 856d2655901b01dd3e75f428f364ab7ac4f07aee --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 986cc071..ce0994da 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1203,7 +1203,7 @@ class Simplex_tree { bool downgrade_dimension() { int new_dimension = -1; // Browse the tree from the left to the right as higher dimension cells are more likely on the left part of the tree - for (Simplex_handle sh : skeleton_simplex_range(dimension_)) { + for (Simplex_handle sh : complex_simplex_range()) { #ifdef DEBUG_TRACES for (auto vertex : simplex_vertex_range(sh)) { std::cout << " " << vertex; -- cgit v1.2.3 From 8f7e5a1259287ee39595623e87149cb07ab2e293 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 26 Oct 2017 20:16:33 +0000 Subject: Code review: downgrade_dimension renamed lower_upper_bound_dimension and make it private. Automatically when dimension_to_be_lowered_ is set (on removal) git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_automatic_dimension_set@2810 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: c764433bcc5357acc6454683d4f4182c7c960d6d --- src/Alpha_complex/test/Alpha_complex_unit_test.cpp | 2 +- src/Simplex_tree/include/gudhi/Simplex_tree.h | 34 ++++++-- .../test/simplex_tree_remove_unit_test.cpp | 98 ++++++++++++---------- src/cython/test/test_simplex_tree.py | 12 +-- 4 files changed, 87 insertions(+), 59 deletions(-) diff --git a/src/Alpha_complex/test/Alpha_complex_unit_test.cpp b/src/Alpha_complex/test/Alpha_complex_unit_test.cpp index e60089c4..166373fe 100644 --- a/src/Alpha_complex/test/Alpha_complex_unit_test.cpp +++ b/src/Alpha_complex/test/Alpha_complex_unit_test.cpp @@ -232,7 +232,7 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_from_points) { BOOST_CHECK(simplex_tree.num_simplices() == 10); std::cout << "simplex_tree.dimension()=" << simplex_tree.dimension() << std::endl; - BOOST_CHECK(simplex_tree.dimension() == 3); + BOOST_CHECK(simplex_tree.dimension() == 1); std::cout << "simplex_tree.num_vertices()=" << simplex_tree.num_vertices() << std::endl; BOOST_CHECK(simplex_tree.num_vertices() == 4); diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index ce0994da..54f5de13 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -492,7 +492,16 @@ class Simplex_tree { } /** \brief Returns an upper bound on the dimension of the simplicial complex. */ - int dimension() const { + int upper_bound_dimension() const { + return dimension_; + } + + /** \brief Returns the dimension of the simplicial complex. + \details This function is not constant time because it can trigger `lower_upper_bound_dimension()` if required. + */ + int dimension() { + if (dimension_to_be_lowered_) + lower_upper_bound_dimension(); return dimension_; } @@ -1162,8 +1171,8 @@ class Simplex_tree { * function is not launching `initialize_filtration()` but returns the filtration modification information. If the * complex has changed , please call `initialize_filtration()` to recompute it. * \post Note that the dimension of the simplicial complex may be lower after calling `prune_above_filtration()` - * than it was before. However, `Simplex_tree::dimension()` will return the old value, which remains a valid upper - * bound. If you care, you can call `downgrade_dimension()` to recompute the exact dimension. + * than it was before. However, `upper_bond_dimension()` will return the old value, which remains a valid upper + * bound. If you care, you can call `dimension()` to recompute the exact dimension. */ bool prune_above_filtration(Filtration_value filtration) { return rec_prune_above_filtration(root(), filtration); @@ -1175,6 +1184,8 @@ class Simplex_tree { auto last = std::remove_if(list.begin(), list.end(), [=](Dit_value_t& simplex) { if (simplex.second.filtration() <= filt) return false; if (has_children(&simplex)) rec_delete(simplex.second.children()); + // dimension may need to be lowered + dimension_to_be_lowered_ = true; return true; }); @@ -1183,6 +1194,8 @@ class Simplex_tree { // Removing the whole siblings, parent becomes a leaf. sib->oncles()->members()[sib->parent()].assign_children(sib->oncles()); delete sib; + // dimension may need to be lowered + dimension_to_be_lowered_ = true; return true; } else { // Keeping some elements of siblings. Remove the others, and recurse in the remaining ones. @@ -1194,13 +1207,15 @@ class Simplex_tree { return modified; } - public: + private: /** \brief Deep search simplex tree dimension recompute. * @return True if the dimension was modified, false otherwise. * \pre Be sure the simplex tree has not a too low dimension value as the deep search stops when the former dimension - * has been reached (cf. `dimension()` and `set_dimension()` methods). + * has been reached (cf. `upper_bound_dimension()` and `set_dimension()` methods). */ - bool downgrade_dimension() { + bool lower_upper_bound_dimension() { + // reset automatic detection to recompute + dimension_to_be_lowered_ = false; int new_dimension = -1; // Browse the tree from the left to the right as higher dimension cells are more likely on the left part of the tree for (Simplex_handle sh : complex_simplex_range()) { @@ -1229,8 +1244,8 @@ class Simplex_tree { * \exception std::invalid_argument In debug mode, if sh has children. * \post Be aware that removing is shifting data in a flat_map (`initialize_filtration()` to be done). * \post Note that the dimension of the simplicial complex may be lower after calling `remove_maximal_simplex()` - * than it was before. However, `Simplex_tree::dimension()` will return the old value, which remains a valid upper - * bound. If you care, you can call `downgrade_dimension()` to recompute the exact dimension. + * than it was before. However, `upper_bond_dimension()` will return the old value, which remains a valid upper + * bound. If you care, you can call `dimension()` to recompute the exact dimension. */ void remove_maximal_simplex(Simplex_handle sh) { // Guarantee the simplex has no children @@ -1248,6 +1263,8 @@ class Simplex_tree { // Sibling is emptied : must be deleted, and its parent must point on his own Sibling child->oncles()->members().at(child->parent()).assign_children(child->oncles()); delete child; + // dimension may need to be lowered + dimension_to_be_lowered_ = true; } } @@ -1262,6 +1279,7 @@ class Simplex_tree { std::vector filtration_vect_; /** \brief Upper bound on the dimension of the simplicial complex.*/ int dimension_; + bool dimension_to_be_lowered_ = false; }; // Print a Simplex_tree in os. diff --git a/src/Simplex_tree/test/simplex_tree_remove_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_remove_unit_test.cpp index 747e7eeb..dc37375c 100644 --- a/src/Simplex_tree/test/simplex_tree_remove_unit_test.cpp +++ b/src/Simplex_tree/test/simplex_tree_remove_unit_test.cpp @@ -109,11 +109,15 @@ BOOST_AUTO_TEST_CASE(remove_maximal_simplex) { std::cout << "st.remove_maximal_simplex({7})" << std::endl; st.remove_maximal_simplex(st.find({7})); - std::cout << "st.dimension()=" << st.dimension() << std::endl; - BOOST_CHECK(st.dimension() == 3); + std::cout << "st.upper_bound_dimension()=" << st.upper_bound_dimension() << std::endl; + BOOST_CHECK(st.upper_bound_dimension() == 3); - st.downgrade_dimension(); + // Check dimension calls lower_upper_bound_dimension to recompute dimension + BOOST_CHECK(st.dimension() == 2); + BOOST_CHECK(st.upper_bound_dimension() == 2); + std::cout << "st.upper_bound_dimension()=" << st.upper_bound_dimension() + << " | st_wo_seven.upper_bound_dimension()=" << st_wo_seven.upper_bound_dimension() << std::endl; std::cout << "st.dimension()=" << st.dimension() << " | st_wo_seven.dimension()=" << st_wo_seven.dimension() << std::endl; BOOST_CHECK(st == st_wo_seven); } @@ -131,116 +135,121 @@ BOOST_AUTO_TEST_CASE(auto_dimension_set) { st.insert_simplex_and_subfaces({6, 7, 8, 9}); st.insert_simplex_and_subfaces({6, 7, 8, 10}); + BOOST_CHECK(st.upper_bound_dimension() == 3); BOOST_CHECK(st.dimension() == 3); std::cout << "st.remove_maximal_simplex({6, 7, 8, 10})" << std::endl; st.remove_maximal_simplex(st.find({6, 7, 8, 10})); - std::cout << "st.dimension()=" << st.dimension() << std::endl; + std::cout << "st.upper_bound_dimension()=" << st.upper_bound_dimension() << std::endl; + BOOST_CHECK(st.upper_bound_dimension() == 3); BOOST_CHECK(st.dimension() == 3); std::cout << "st.remove_maximal_simplex({6, 7, 8, 9})" << std::endl; st.remove_maximal_simplex(st.find({6, 7, 8, 9})); - std::cout << "st.dimension()=" << st.dimension() << std::endl; + std::cout << "st.upper_bound_dimension()=" << st.upper_bound_dimension() << std::endl; + BOOST_CHECK(st.upper_bound_dimension() == 3); BOOST_CHECK(st.dimension() == 3); std::cout << "st.remove_maximal_simplex({1, 2, 3, 4})" << std::endl; st.remove_maximal_simplex(st.find({1, 2, 3, 4})); - std::cout << "st.dimension()=" << st.dimension() << std::endl; + std::cout << "st.upper_bound_dimension()=" << st.upper_bound_dimension() << std::endl; + BOOST_CHECK(st.upper_bound_dimension() == 3); BOOST_CHECK(st.dimension() == 3); std::cout << "st.remove_maximal_simplex({1, 2, 3, 5})" << std::endl; st.remove_maximal_simplex(st.find({1, 2, 3, 5})); - std::cout << "st.dimension()=" << st.dimension() << std::endl; - BOOST_CHECK(st.dimension() == 3); - st.downgrade_dimension(); - std::cout << "st.dimension()=" << st.dimension() << std::endl; + std::cout << "st.upper_bound_dimension()=" << st.upper_bound_dimension() << std::endl; + BOOST_CHECK(st.upper_bound_dimension() == 3); BOOST_CHECK(st.dimension() == 2); + std::cout << "st.dimension()=" << st.dimension() << std::endl; std::cout << "st.insert_simplex_and_subfaces({1, 2, 3, 5})" << std::endl; st.insert_simplex_and_subfaces({1, 2, 3, 5}); - std::cout << "st.dimension()=" << st.dimension() << std::endl; + std::cout << "st.upper_bound_dimension()=" << st.upper_bound_dimension() << std::endl; + BOOST_CHECK(st.upper_bound_dimension() == 3); BOOST_CHECK(st.dimension() == 3); std::cout << "st.insert_simplex_and_subfaces({1, 2, 3, 4})" << std::endl; st.insert_simplex_and_subfaces({1, 2, 3, 4}); - std::cout << "st.dimension()=" << st.dimension() << std::endl; + std::cout << "st.upper_bound_dimension()=" << st.upper_bound_dimension() << std::endl; + BOOST_CHECK(st.upper_bound_dimension() == 3); BOOST_CHECK(st.dimension() == 3); + std::cout << "st.remove_maximal_simplex({1, 2, 3, 5})" << std::endl; st.remove_maximal_simplex(st.find({1, 2, 3, 5})); - std::cout << "st.dimension()=" << st.dimension() << std::endl; + std::cout << "st.upper_bound_dimension()=" << st.upper_bound_dimension() << std::endl; + BOOST_CHECK(st.upper_bound_dimension() == 3); BOOST_CHECK(st.dimension() == 3); + std::cout << "st.remove_maximal_simplex({1, 2, 3, 4})" << std::endl; st.remove_maximal_simplex(st.find({1, 2, 3, 4})); - std::cout << "st.dimension()=" << st.dimension() << std::endl; - BOOST_CHECK(st.dimension() == 3); - st.downgrade_dimension(); - std::cout << "st.dimension()=" << st.dimension() << std::endl; + std::cout << "st.upper_bound_dimension()=" << st.upper_bound_dimension() << std::endl; + BOOST_CHECK(st.upper_bound_dimension() == 3); BOOST_CHECK(st.dimension() == 2); + std::cout << "st.dimension()=" << st.dimension() << std::endl; std::cout << "st.insert_simplex_and_subfaces({0, 1, 3, 4})" << std::endl; st.insert_simplex_and_subfaces({0, 1, 3, 4}); - std::cout << "st.dimension()=" << st.dimension() << std::endl; + std::cout << "st.upper_bound_dimension()=" << st.upper_bound_dimension() << std::endl; + BOOST_CHECK(st.upper_bound_dimension() == 3); BOOST_CHECK(st.dimension() == 3); std::cout << "st.remove_maximal_simplex({0, 1, 3, 4})" << std::endl; st.remove_maximal_simplex(st.find({0, 1, 3, 4})); - std::cout << "st.dimension()=" << st.dimension() << std::endl; - BOOST_CHECK(st.dimension() == 3); - st.downgrade_dimension(); - std::cout << "st.dimension()=" << st.dimension() << std::endl; + std::cout << "st.upper_bound_dimension()=" << st.upper_bound_dimension() << std::endl; + BOOST_CHECK(st.upper_bound_dimension() == 3); BOOST_CHECK(st.dimension() == 2); + std::cout << "st.dimension()=" << st.dimension() << std::endl; std::cout << "st.insert_simplex_and_subfaces({1, 2, 3, 5})" << std::endl; st.insert_simplex_and_subfaces({1, 2, 3, 5}); - std::cout << "st.dimension()=" << st.dimension() << std::endl; + std::cout << "st.upper_bound_dimension()=" << st.upper_bound_dimension() << std::endl; + BOOST_CHECK(st.upper_bound_dimension() == 3); BOOST_CHECK(st.dimension() == 3); std::cout << "st.insert_simplex_and_subfaces({1, 2, 3, 4})" << std::endl; st.insert_simplex_and_subfaces({1, 2, 3, 4}); - std::cout << "st.dimension()=" << st.dimension() << std::endl; + std::cout << "st.upper_bound_dimension()=" << st.upper_bound_dimension() << std::endl; + BOOST_CHECK(st.upper_bound_dimension() == 3); BOOST_CHECK(st.dimension() == 3); // Check you can override the dimension // This is a limit test case - shall not happen st.set_dimension(1); - std::cout << "st.dimension()=" << st.dimension() << std::endl; - BOOST_CHECK(st.dimension() == 1); - st.downgrade_dimension(); - std::cout << "st.dimension()=" << st.dimension() << std::endl; - // check downgrade_dimension() is not giving the rigt answer because dimension is too low + std::cout << "st.upper_bound_dimension()=" << st.upper_bound_dimension() << std::endl; + BOOST_CHECK(st.upper_bound_dimension() == 1); + // check dimension() and lower_upper_bound_dimension() is not giving the right answer because dimension is too low BOOST_CHECK(st.dimension() == 1); // Check you can override the dimension // This is a limit test case - shall not happen st.set_dimension(6); - std::cout << "st.dimension()=" << st.dimension() << std::endl; + std::cout << "st.upper_bound_dimension()=" << st.upper_bound_dimension() << std::endl; + BOOST_CHECK(st.upper_bound_dimension() == 6); + // check dimension() do not launch lower_upper_bound_dimension() BOOST_CHECK(st.dimension() == 6); - st.downgrade_dimension(); - std::cout << "st.dimension()=" << st.dimension() << std::endl; - // check downgrade_dimension() resets the correct dimension - BOOST_CHECK(st.dimension() == 3); // Reset with the correct value st.set_dimension(3); - std::cout << "st.dimension()=" << st.dimension() << std::endl; + std::cout << "st.upper_bound_dimension()=" << st.upper_bound_dimension() << std::endl; + BOOST_CHECK(st.upper_bound_dimension() == 3); BOOST_CHECK(st.dimension() == 3); std::cout << "st.insert_simplex_and_subfaces({0, 1, 2, 3, 4, 5, 6})" << std::endl; st.insert_simplex_and_subfaces({0, 1, 2, 3, 4, 5, 6}); - std::cout << "st.dimension()=" << st.dimension() << std::endl; + std::cout << "st.upper_bound_dimension()=" << st.upper_bound_dimension() << std::endl; + BOOST_CHECK(st.upper_bound_dimension() == 6); BOOST_CHECK(st.dimension() == 6); std::cout << "st.remove_maximal_simplex({0, 1, 2, 3, 4, 5, 6})" << std::endl; st.remove_maximal_simplex(st.find({0, 1, 2, 3, 4, 5, 6})); - std::cout << "st.dimension()=" << st.dimension() << std::endl; - BOOST_CHECK(st.dimension() == 6); - st.downgrade_dimension(); - std::cout << "st.dimension()=" << st.dimension() << std::endl; + std::cout << "st.upper_bound_dimension()=" << st.upper_bound_dimension() << std::endl; + BOOST_CHECK(st.upper_bound_dimension() == 6); BOOST_CHECK(st.dimension() == 5); } @@ -336,17 +345,18 @@ BOOST_AUTO_TEST_CASE(prune_above_filtration) { Stree st_empty; simplex_is_changed = st.prune_above_filtration(0.0); + BOOST_CHECK(simplex_is_changed == true); if (simplex_is_changed) st.initialize_filtration(); // Display the Simplex_tree std::cout << "The complex pruned at 0.0 contains " << st.num_simplices() << " simplices"; - std::cout << " - dimension " << st.dimension() << std::endl; - BOOST_CHECK(st.dimension() == 3); + std::cout << " - upper_bound_dimension " << st.upper_bound_dimension() << std::endl; + BOOST_CHECK(st.upper_bound_dimension() == 3); - st.downgrade_dimension(); - std::cout << "dimension=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == -1); + std::cout << "upper_bound_dimension=" << st.upper_bound_dimension() << std::endl; + BOOST_CHECK(st.upper_bound_dimension() == -1); BOOST_CHECK(st == st_empty); BOOST_CHECK(simplex_is_changed); diff --git a/src/cython/test/test_simplex_tree.py b/src/cython/test/test_simplex_tree.py index 177cfdad..a6d6a9f3 100755 --- a/src/cython/test/test_simplex_tree.py +++ b/src/cython/test/test_simplex_tree.py @@ -94,12 +94,12 @@ def test_insertion(): assert st.persistence(persistence_dim_max = True) == [(1, (4.0, float('inf'))), (0, (0.0, float('inf')))] assert st.__is_persistence_defined() == True - assert st.betti_numbers() == [1, 1, 0] - assert st.persistent_betti_numbers(-0.1, 10000.0) == [0, 0, 0] - assert st.persistent_betti_numbers(0.0, 10000.0) == [1, 0, 0] - assert st.persistent_betti_numbers(3.9, 10000.0) == [1, 0, 0] - assert st.persistent_betti_numbers(4.0, 10000.0) == [1, 1, 0] - assert st.persistent_betti_numbers(9999.0, 10000.0) == [1, 1, 0] + assert st.betti_numbers() == [1, 1] + assert st.persistent_betti_numbers(-0.1, 10000.0) == [0, 0] + assert st.persistent_betti_numbers(0.0, 10000.0) == [1, 0] + assert st.persistent_betti_numbers(3.9, 10000.0) == [1, 0] + assert st.persistent_betti_numbers(4.0, 10000.0) == [1, 1] + assert st.persistent_betti_numbers(9999.0, 10000.0) == [1, 1] def test_expansion(): st = SimplexTree() -- cgit v1.2.3 From 8659c97eff5e4ef0321509abe36f8baa78c2f35b Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 6 Nov 2017 12:33:36 +0000 Subject: doc review : upper_bond_dimension to be replaced with upper_bound_dimension git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_automatic_dimension_set@2829 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: ca70d79176d406f63c3372dd7e062f108365b99f --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index b2d380ea..03dfce70 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1268,7 +1268,7 @@ class Simplex_tree { * function is not launching `initialize_filtration()` but returns the filtration modification information. If the * complex has changed , please call `initialize_filtration()` to recompute it. * \post Note that the dimension of the simplicial complex may be lower after calling `prune_above_filtration()` - * than it was before. However, `upper_bond_dimension()` will return the old value, which remains a valid upper + * than it was before. However, `upper_bound_dimension()` will return the old value, which remains a valid upper * bound. If you care, you can call `dimension()` to recompute the exact dimension. */ bool prune_above_filtration(Filtration_value filtration) { @@ -1342,7 +1342,7 @@ class Simplex_tree { * \exception std::invalid_argument In debug mode, if sh has children. * \post Be aware that removing is shifting data in a flat_map (`initialize_filtration()` to be done). * \post Note that the dimension of the simplicial complex may be lower after calling `remove_maximal_simplex()` - * than it was before. However, `upper_bond_dimension()` will return the old value, which remains a valid upper + * than it was before. However, `upper_bound_dimension()` will return the old value, which remains a valid upper * bound. If you care, you can call `dimension()` to recompute the exact dimension. * \internal @return true if the leaf's branch has no other leaves (branch's children has been re-assigned), false otherwise. */ -- cgit v1.2.3 From b4298589ad5e2cf7136b0ff7a0be29a246b2f956 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 6 Nov 2017 13:14:02 +0000 Subject: Doc review : dimension() method documentation can not mention lower_upper_bound_dimension as it is a private method. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_automatic_dimension_set@2830 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: fec09d2a0b0f896c848a13c54d21625d08efc997 --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 03dfce70..7da767cb 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -487,7 +487,8 @@ class Simplex_tree { } /** \brief Returns the dimension of the simplicial complex. - \details This function is not constant time because it can trigger `lower_upper_bound_dimension()` if required. + \details This function is not constant time because it can recompute dimension if required (can be triggered by + `remove_maximal_simplex()` or `prune_above_filtration()`). */ int dimension() { if (dimension_to_be_lowered_) -- cgit v1.2.3 From 961d3264b4554cdd03d1c5a13e714e1ea38733ff Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 6 Nov 2017 13:39:43 +0000 Subject: Rollback commented lines git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_automatic_dimension_set@2831 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 052a8f264877e7ffa87f8c81abf0f0c83cb60d54 --- src/Persistent_cohomology/example/rips_persistence_step_by_step.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Persistent_cohomology/example/rips_persistence_step_by_step.cpp b/src/Persistent_cohomology/example/rips_persistence_step_by_step.cpp index 75580aac..554eeba6 100644 --- a/src/Persistent_cohomology/example/rips_persistence_step_by_step.cpp +++ b/src/Persistent_cohomology/example/rips_persistence_step_by_step.cpp @@ -88,9 +88,6 @@ int main(int argc, char * argv[]) { Simplex_tree st; // insert the proximity graph in the simplex tree st.insert_graph(prox_graph); - std::cout << "The complex contains " << st.num_simplices() << " simplices \n"; - std::cout << " and has dimension " << st.dimension() << " \n"; -/* // expand the graph until dimension dim_max st.expansion(dim_max); @@ -115,7 +112,7 @@ int main(int argc, char * argv[]) { pcoh.output_diagram(out); out.close(); } -*/ + return 0; } -- cgit v1.2.3