Skip to content

Commit

Permalink
Fix some tests and improve test_output_squared_values
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentRouvreau committed Nov 26, 2024
1 parent f3ca164 commit e74f9e5
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 63 deletions.
112 changes: 56 additions & 56 deletions src/python/doc/delaunay_complex_user.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,32 +63,32 @@ The output is:

.. testoutput::

Complex is of dimension 2 - 25 simplices - 7 vertices.
[0] -> 0.00
[1] -> 0.00
[2] -> 0.00
[3] -> 0.00
[4] -> 0.00
[5] -> 0.00
[6] -> 0.00
[2, 3] -> 2.50
[4, 5] -> 2.69
[0, 2] -> 2.92
[0, 1] -> 3.04
[1, 3] -> 3.16
[1, 2] -> 3.35
[1, 2, 3] -> 3.54
[0, 1, 2] -> 3.60
[5, 6] -> 3.64
[2, 4] -> 4.47
[4, 6] -> 4.74
[4, 5, 6] -> 4.74
[3, 6] -> 5.50
[2, 6] -> 6.04
[2, 3, 6] -> 6.04
[2, 4, 6] -> 6.10
[0, 4] -> 6.52
[0, 2, 4] -> 6.52
Complex is of dimension 2 - 25 simplices - 7 vertices.
[0] -> 0.00
[1] -> 0.00
[2] -> 0.00
[3] -> 0.00
[4] -> 0.00
[5] -> 0.00
[6] -> 0.00
[2, 3] -> 2.50
[4, 5] -> 2.69
[0, 2] -> 2.92
[0, 1] -> 3.04
[1, 3] -> 3.16
[1, 2] -> 3.35
[1, 2, 3] -> 3.54
[0, 1, 2] -> 3.60
[5, 6] -> 3.64
[2, 4] -> 4.47
[4, 6] -> 4.74
[4, 5, 6] -> 4.74
[3, 6] -> 5.50
[2, 6] -> 6.04
[2, 3, 6] -> 6.04
[2, 4, 6] -> 6.10
[0, 4] -> 6.52
[0, 2, 4] -> 6.52

**Note:** The Delaunay Čech complex can be easily replaced by the :math:`\alpha`-complex, but note that the resulting
filtration values will be different.
Expand Down Expand Up @@ -124,33 +124,33 @@ The output is:

.. testoutput::

Weighted alpha complex is of dimension 3 - 29 simplices - 5 vertices.
[0, 1, 2, 3] -> -1.00
[0, 1, 2] -> -1.33
[0, 1, 3, 4] -> 95.00
[0, 1, 3] -> -1.33
[0, 1, 4] -> 95.00
[0, 1] -> -2.00
[0, 2, 3, 4] -> 95.00
[0, 2, 3] -> -1.33
[0, 2, 4] -> 95.00
[0, 2] -> -2.00
[0, 3, 4] -> 23.00
[0, 3] -> -2.00
[0, 4] -> 23.00
[0] -> -4.00
[1, 2, 3, 4] -> 95.00
[1, 2, 3] -> -1.33
[1, 2, 4] -> 95.00
[1, 2] -> -2.00
[1, 3, 4] -> 23.00
[1, 3] -> -2.00
[1, 4] -> 23.00
[1] -> -4.00
[2, 3, 4] -> 23.00
[2, 3] -> -2.00
[2, 4] -> 23.00
[2] -> -4.00
[3, 4] -> -1.00
[3] -> -4.00
[4] -> -1.00
Weighted alpha is of dimension 3 - 29 simplices - 5 vertices.
[0, 1, 2, 3] -> -1.00
[0, 1, 2] -> -1.33
[0, 1, 3, 4] -> 95.00
[0, 1, 3] -> -1.33
[0, 1, 4] -> 95.00
[0, 1] -> -2.00
[0, 2, 3, 4] -> 95.00
[0, 2, 3] -> -1.33
[0, 2, 4] -> 95.00
[0, 2] -> -2.00
[0, 3, 4] -> 23.00
[0, 3] -> -2.00
[0, 4] -> 23.00
[0] -> -4.00
[1, 2, 3, 4] -> 95.00
[1, 2, 3] -> -1.33
[1, 2, 4] -> 95.00
[1, 2] -> -2.00
[1, 3, 4] -> 23.00
[1, 3] -> -2.00
[1, 4] -> 23.00
[1] -> -4.00
[2, 3, 4] -> 23.00
[2, 3] -> -2.00
[2, 4] -> 23.00
[2] -> -4.00
[3, 4] -> -1.00
[3] -> -4.00
[4] -> -1.00
18 changes: 11 additions & 7 deletions src/python/test/test_delaunay_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,14 @@ def test_duplicated_2d_points_on_a_plane():
def test_output_squared_values():
for simplicial_complex_helper in [alpha_complex, delaunay_cech_complex]:
for precision in ['fast', 'safe', 'exact']:
pts=[[1, 1], [7, 0], [4, 6], [9, 6], [0, 14], [2, 19], [9, 17]]
stree = simplicial_complex_helper(points=pts, precision=precision, output_squared_values=False)
stree_sqrt = simplicial_complex_helper(points=pts, precision=precision, output_squared_values=True)
for simplex, filt in stree_sqrt.get_filtration():
# np.testing.assert_almost_equal(float('nan'), float('nan')) is ok
# while float('nan') == float('nan') is False
np.testing.assert_almost_equal(filt, math.sqrt(stree.filtration(simplex)))
for max_alpha in [float('inf'), math.sqrt(20.)]:
pts=[[1, 1], [7, 0], [4, 6], [9, 6], [0, 14], [2, 19], [9, 17]]
stree = simplicial_complex_helper(points=pts, precision=precision,
output_squared_values=False, max_alpha=max_alpha)
stree_sqrt = simplicial_complex_helper(points=pts, precision=precision,
output_squared_values=True, max_alpha=max_alpha)
assert stree.num_simplices() == stree_sqrt.num_simplices()
for simplex, filt in stree_sqrt.get_filtration():
# np.testing.assert_almost_equal(float('nan'), float('nan')) is ok
# while float('nan') == float('nan') is False
np.testing.assert_almost_equal(filt, math.sqrt(stree.filtration(simplex)))

0 comments on commit e74f9e5

Please sign in to comment.