Skip to content

Commit

Permalink
Improve test coverage of Plotter.add_floor (#4866)
Browse files Browse the repository at this point in the history
* Improve test coverage of Plotter.add_floor

* Update renderer.py

* Apply suggestions from code review

* Update test_plotter.py

* Update test_plotter.py
  • Loading branch information
tkoyama010 committed Sep 13, 2023
1 parent 03db646 commit 279c9ff
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyvista/plotting/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1948,7 +1948,7 @@ def add_floor(
i_size = ranges[2]
j_size = ranges[1]
else:
raise NotImplementedError(f'Face ({face}) not implementd')
raise NotImplementedError(f'Face ({face}) not implemented')
self._floor = pyvista.Plane(
center=center,
direction=normal,
Expand Down
23 changes: 23 additions & 0 deletions tests/plotting/test_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,3 +402,26 @@ def test_plotter_meshes(sphere, cube):
assert sphere in pl.meshes
assert cube in pl.meshes
assert len(pl.meshes) == 2


@pytest.mark.parametrize(
'face, normal',
[
('-Z', (0, 0, 1)),
('-Y', (0, 1, 0)),
('-X', (1, 0, 0)),
('+Z', (0, 0, -1)),
('+Y', (0, -1, 0)),
('+X', (-1, 0, 0)),
],
)
def test_plotter_add_floor(face, normal):
pl = pv.Plotter()
pl.add_floor(face=face)
assert np.allclose(pl.renderer._floor.face_normals[0], normal)


def test_plotter_add_floor_raise_error():
pl = pv.Plotter()
with pytest.raises(NotImplementedError, match='not implemented'):
pl.add_floor(face='invalid')

0 comments on commit 279c9ff

Please sign in to comment.