From 27f251520f1fc355e2b7d83225d44adbf6ce63c8 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 23 Jun 2016 16:06:31 +0000 Subject: Pytest unitary tests git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@1333 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 0f0b284583267400574c2c2f644d5a99dfb6032e --- src/cython/test/test_rips_complex.py | 70 +++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 33 deletions(-) (limited to 'src/cython/test/test_rips_complex.py') diff --git a/src/cython/test/test_rips_complex.py b/src/cython/test/test_rips_complex.py index ecc676c7..877289cf 100755 --- a/src/cython/test/test_rips_complex.py +++ b/src/cython/test/test_rips_complex.py @@ -1,6 +1,4 @@ -import unittest - -import gudhi +from gudhi import RipsComplex """This file is part of the Gudhi Library. The Gudhi library (Geometric Understanding in Higher Dimensions) is a generic C++ @@ -29,33 +27,39 @@ __copyright__ = "Copyright (C) 2016 INRIA" __license__ = "GPL v3" -class TestRipsComplex(unittest.TestCase): - - def test_rips(self): - point_list = [[0, 0], [1, 0], [0, 1], [1, 1]] - rips_complex = gudhi.RipsComplex(points=point_list, max_dimension=1, - max_edge_length=42) - - self.assertEqual(rips_complex.num_simplices(), 10) - self.assertEqual(rips_complex.num_vertices(), 4) - - self.assertEqual(rips_complex.get_filtered_tree(), - [([0], 0.0), ([1], 0.0), ([2], 0.0), ([3], 0.0), - ([0, 1], 1.0), ([0, 2], 1.0), ([1, 3], 1.0), - ([2, 3], 1.0), ([1, 2], 1.4142135623730951), - ([0, 3], 1.4142135623730951)]) - self.assertEqual(rips_complex.get_star_tree([0]), - [([0], 0.0), ([0, 1], 1.0), ([0, 2], 1.0), - ([0, 3], 1.4142135623730951)]) - self.assertEqual(rips_complex.get_coface_tree([0], 1), - [([0, 1], 1.0), ([0, 2], 1.0), - ([0, 3], 1.4142135623730951)]) - - filtered_rips = gudhi.RipsComplex(points=point_list, max_dimension=1, - max_edge_length=1.0) - - self.assertEqual(filtered_rips.num_simplices(), 8) - self.assertEqual(filtered_rips.num_vertices(), 4) - -if __name__ == '__main__': - unittest.main() +def test_empty_rips(): + rips_complex = RipsComplex() + assert rips_complex.__is_defined() == True + assert rips_complex.__is_persistence_defined() == False + +def test_rips(): + point_list = [[0, 0], [1, 0], [0, 1], [1, 1]] + rips_complex = RipsComplex(points=point_list, max_dimension=1, + max_edge_length=42) + assert rips_complex.__is_defined() == True + assert rips_complex.__is_persistence_defined() == False + + assert rips_complex.num_simplices() == 10 + assert rips_complex.num_vertices() == 4 + + assert rips_complex.get_filtered_tree() == \ + [([0], 0.0), ([1], 0.0), ([2], 0.0), ([3], 0.0), + ([0, 1], 1.0), ([0, 2], 1.0), ([1, 3], 1.0), + ([2, 3], 1.0), ([1, 2], 1.4142135623730951), + ([0, 3], 1.4142135623730951)] + assert rips_complex.get_star_tree([0]) == \ + [([0], 0.0), ([0, 1], 1.0), ([0, 2], 1.0), + ([0, 3], 1.4142135623730951)] + assert rips_complex.get_coface_tree([0], 1) == \ + [([0, 1], 1.0), ([0, 2], 1.0), + ([0, 3], 1.4142135623730951)] + +def test_filtered_rips(): + point_list = [[0, 0], [1, 0], [0, 1], [1, 1]] + filtered_rips = RipsComplex(points=point_list, max_dimension=1, + max_edge_length=1.0) + assert filtered_rips.__is_defined() == True + assert filtered_rips.__is_persistence_defined() == False + + assert filtered_rips.num_simplices() == 8 + assert filtered_rips.num_vertices() == 4 -- cgit v1.2.3