Skip to content

Commit ee601a7

Browse files
moe-adpre-commit-ci[bot]pyansys-ci-bot
authored
test: add plotly tests for volumetric meshes (#449)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: pyansys-ci-bot <[email protected]>
1 parent 3fa0211 commit ee601a7

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Test: add plotly tests for volumetric meshes

tests/test_plotly_backend.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
# SOFTWARE.
2222
"""Test module for plotly backend."""
23+
import numpy as np
2324
from plotly.graph_objects import Mesh3d, Scatter3d
2425
import pyvista as pv
2526

@@ -70,6 +71,28 @@ def test_plot_pyvista_mesh(tmp_path, image_compare):
7071
pl.show(screenshot=file)
7172
assert image_compare(file)
7273

74+
def test_plot_structured_grid(tmp_path, image_compare):
75+
"""Adds structured grid to the plotter."""
76+
pl = Plotter(backend=PlotlyBackend())
77+
xrng = np.arange(-10, 10, 2, dtype=np.float32)
78+
yrng = np.arange(-10, 10, 5, dtype=np.float32)
79+
zrng = np.arange(-10, 10, 1, dtype=np.float32)
80+
x, y, z = np.meshgrid(xrng, yrng, zrng, indexing='ij')
81+
grid = pv.StructuredGrid(x, y, z)
82+
pl.plot(grid)
83+
file = tmp_path / "test_plot_structured_grid.png"
84+
pl.show(screenshot=file)
85+
assert image_compare(file)
86+
87+
def test_plot_unstructured_grid(tmp_path, image_compare):
88+
"""Adds unstructured grid to the plotter."""
89+
pl = Plotter(backend=PlotlyBackend())
90+
sphere = pv.Sphere()
91+
ug = pv.UnstructuredGrid(sphere)
92+
pl.plot(ug)
93+
file = tmp_path / "test_plot_unstructured_grid.png"
94+
pl.show(screenshot=file)
95+
assert image_compare(file)
7396

7497
def test_plot_pyvista_multiblock(tmp_path, image_compare):
7598
"""Test plotting a PyVista MultiBlock mesh."""

tox.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ basepython =
1717
setenv =
1818
PYTHONUNBUFFERED = yes
1919
coverage: PYTEST_EXTRA_ARGS = --cov=ansys.tools.visualization_interface --cov-report=term --cov-report=xml:.cov/xml --cov-report=html:.cov/html
20-
extras = tests
20+
extras =
21+
tests
22+
all
2123
commands =
2224
pytest {env:PYTEST_MARKERS:} {env:PYTEST_EXTRA_ARGS:} {posargs:-vv}
2325

0 commit comments

Comments
 (0)