Skip to content

Commit 734e4da

Browse files
committed
more tests
1 parent 89d5631 commit 734e4da

File tree

2 files changed

+68
-5
lines changed

2 files changed

+68
-5
lines changed

src/compas/datastructures/volmesh/volmesh.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,11 @@ def delete_cell(self, cell):
10231023
-------
10241024
None
10251025
1026+
Raises
1027+
------
1028+
KeyError
1029+
If the cell does not exist.
1030+
10261031
See Also
10271032
--------
10281033
:meth:`delete_vertex`, :meth:`delete_halfface`

tests/compas/datastructures/test_volmesh.py

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,66 @@ def test_cells_where_predicate():
245245
# Methods
246246
# ==============================================================================
247247

248-
def test_delete_cell():
249-
hf = VolMesh.from_meshgrid(10, 10, 10, 5, 5, 5)
250-
assert hf.number_of_cells() == 125
251-
hf.delete_cell(1)
252-
assert hf.number_of_cells() == 124
248+
249+
def test_delete_cell_of_volmesh_with_1_1_1():
250+
volmesh = VolMesh.from_meshgrid(1, 1, 1, 1, 1, 1)
251+
nov = volmesh.number_of_vertices()
252+
noe = volmesh.number_of_edges()
253+
nof = volmesh.number_of_faces()
254+
noc = volmesh.number_of_cells()
255+
256+
volmesh.delete_cell(0)
257+
258+
assert volmesh.number_of_vertices() == nov
259+
assert volmesh.number_of_cells() == noc - 1
260+
assert volmesh.number_of_edges() == noe - 12
261+
assert volmesh.number_of_faces() == nof - 6
262+
263+
264+
@pytest.mark.parametrize(
265+
"c",
266+
[0, 1],
267+
)
268+
def test_delete_cell_of_volmesh_with_2_1_1(c):
269+
volmesh = VolMesh.from_meshgrid(1, 1, 1, 2, 1, 1)
270+
nov = volmesh.number_of_vertices()
271+
noe = volmesh.number_of_edges()
272+
nof = volmesh.number_of_faces()
273+
noc = volmesh.number_of_cells()
274+
275+
volmesh.delete_cell(c)
276+
277+
assert volmesh.number_of_vertices() == nov
278+
assert volmesh.number_of_cells() == noc - 1
279+
assert volmesh.number_of_edges() == noe - 8
280+
assert volmesh.number_of_faces() == nof - 5
281+
282+
283+
@pytest.mark.parametrize(
284+
"c",
285+
[0, 1, 2],
286+
)
287+
def test_delete_cell_of_volmesh_with_3_1_1(c):
288+
volmesh = VolMesh.from_meshgrid(1, 1, 1, 3, 1, 1)
289+
nov = volmesh.number_of_vertices()
290+
noe = volmesh.number_of_edges()
291+
nof = volmesh.number_of_faces()
292+
noc = volmesh.number_of_cells()
293+
294+
volmesh.delete_cell(c)
295+
296+
if c == 0:
297+
assert volmesh.number_of_vertices() == nov
298+
assert volmesh.number_of_cells() == noc - 1
299+
assert volmesh.number_of_edges() == noe - 8
300+
assert volmesh.number_of_faces() == nof - 5
301+
elif c == 1:
302+
assert volmesh.number_of_vertices() == nov
303+
assert volmesh.number_of_cells() == noc - 1
304+
assert volmesh.number_of_edges() == noe - 4
305+
assert volmesh.number_of_faces() == nof - 4
306+
elif c == 2:
307+
assert volmesh.number_of_vertices() == nov
308+
assert volmesh.number_of_cells() == noc - 1
309+
assert volmesh.number_of_edges() == noe - 8
310+
assert volmesh.number_of_faces() == nof - 5

0 commit comments

Comments
 (0)