Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvanmele committed Nov 1, 2024
1 parent 89d5631 commit 734e4da
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/compas/datastructures/volmesh/volmesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,11 @@ def delete_cell(self, cell):
-------
None
Raises
------
KeyError
If the cell does not exist.
See Also
--------
:meth:`delete_vertex`, :meth:`delete_halfface`
Expand Down
68 changes: 63 additions & 5 deletions tests/compas/datastructures/test_volmesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,66 @@ def test_cells_where_predicate():
# Methods
# ==============================================================================

def test_delete_cell():
hf = VolMesh.from_meshgrid(10, 10, 10, 5, 5, 5)
assert hf.number_of_cells() == 125
hf.delete_cell(1)
assert hf.number_of_cells() == 124

def test_delete_cell_of_volmesh_with_1_1_1():
volmesh = VolMesh.from_meshgrid(1, 1, 1, 1, 1, 1)
nov = volmesh.number_of_vertices()
noe = volmesh.number_of_edges()
nof = volmesh.number_of_faces()
noc = volmesh.number_of_cells()

volmesh.delete_cell(0)

assert volmesh.number_of_vertices() == nov
assert volmesh.number_of_cells() == noc - 1
assert volmesh.number_of_edges() == noe - 12
assert volmesh.number_of_faces() == nof - 6


@pytest.mark.parametrize(
"c",
[0, 1],
)
def test_delete_cell_of_volmesh_with_2_1_1(c):
volmesh = VolMesh.from_meshgrid(1, 1, 1, 2, 1, 1)
nov = volmesh.number_of_vertices()
noe = volmesh.number_of_edges()
nof = volmesh.number_of_faces()
noc = volmesh.number_of_cells()

volmesh.delete_cell(c)

assert volmesh.number_of_vertices() == nov
assert volmesh.number_of_cells() == noc - 1
assert volmesh.number_of_edges() == noe - 8
assert volmesh.number_of_faces() == nof - 5


@pytest.mark.parametrize(
"c",
[0, 1, 2],
)
def test_delete_cell_of_volmesh_with_3_1_1(c):
volmesh = VolMesh.from_meshgrid(1, 1, 1, 3, 1, 1)
nov = volmesh.number_of_vertices()
noe = volmesh.number_of_edges()
nof = volmesh.number_of_faces()
noc = volmesh.number_of_cells()

volmesh.delete_cell(c)

if c == 0:
assert volmesh.number_of_vertices() == nov
assert volmesh.number_of_cells() == noc - 1
assert volmesh.number_of_edges() == noe - 8
assert volmesh.number_of_faces() == nof - 5
elif c == 1:
assert volmesh.number_of_vertices() == nov
assert volmesh.number_of_cells() == noc - 1
assert volmesh.number_of_edges() == noe - 4
assert volmesh.number_of_faces() == nof - 4
elif c == 2:
assert volmesh.number_of_vertices() == nov
assert volmesh.number_of_cells() == noc - 1
assert volmesh.number_of_edges() == noe - 8
assert volmesh.number_of_faces() == nof - 5

0 comments on commit 734e4da

Please sign in to comment.