summaryrefslogtreecommitdiff
path: root/src/Simplex_tree/test/simplex_tree_unit_test.cpp
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-03-23 08:09:39 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-03-23 08:09:39 +0000
commitbbf22c32a893c9875f6ea0e217d0bf6cf77c3257 (patch)
treeb1a546fd5c2cc35d28d5af2c1611b4979be36469 /src/Simplex_tree/test/simplex_tree_unit_test.cpp
parent5276b0a9e344ed0bb4fdb8b079f2ce86649d12a4 (diff)
prune_above_filtration returns filtration vector modification information instead of calling initialize_filtration()
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alphashapes@1071 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 6fdc1797ac6e7b452abe150643f0ec9578c3bbab
Diffstat (limited to 'src/Simplex_tree/test/simplex_tree_unit_test.cpp')
-rw-r--r--src/Simplex_tree/test/simplex_tree_unit_test.cpp71
1 files changed, 57 insertions, 14 deletions
diff --git a/src/Simplex_tree/test/simplex_tree_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_unit_test.cpp
index b8c1cc35..b1bb23b1 100644
--- a/src/Simplex_tree/test/simplex_tree_unit_test.cpp
+++ b/src/Simplex_tree/test/simplex_tree_unit_test.cpp
@@ -1012,20 +1012,30 @@ BOOST_AUTO_TEST_CASE(prune_above_filtration) {
// o
// 5
+ bool simplex_is_changed = false;
// Check the no action cases
// greater than initial filtration value
- st.prune_above_filtration(10.0);
+ 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
- st.prune_above_filtration(6.0);
+ 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
- st.prune_above_filtration(5.0);
+ 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() << " - filtration " << st.filtration() << std::endl;
+ 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) << "] ";
@@ -1036,35 +1046,46 @@ BOOST_AUTO_TEST_CASE(prune_above_filtration) {
}
// Check the pruned cases
- // Set the st_pruned filtration for operator==
- st.prune_above_filtration(2.5);
+ 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() << " - filtration " << st.filtration() << std::endl;
+ std::cout << " - dimension " << st.dimension() << std::endl;
- st.prune_above_filtration(2.0);
+ 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() << " - filtration " << st.filtration() << std::endl;
+ 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);
- st.prune_above_filtration(0.0);
+ 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() << " - filtration " << st.filtration() << std::endl;
+ std::cout << " - dimension " << st.dimension() << std::endl;
BOOST_CHECK(st == st_empty);
+ BOOST_CHECK(simplex_is_changed);
// Test case to the limit
- st.prune_above_filtration(-1.0);
+ 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) {
@@ -1096,11 +1117,33 @@ BOOST_AUTO_TEST_CASE(mini_prune_above_filtration) {
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
- st.prune_above_filtration(-1.0);
+ 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;
- BOOST_CHECK(st.num_simplices() == 0);
} \ No newline at end of file