Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing some plot stuff and small gallery improvements #2349

Merged
merged 57 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
2140445
Renaming file and changing thumbnail
germa89 Sep 19, 2023
08429e4
Small fix to doc build
germa89 Sep 19, 2023
c4baa48
Activating plots
germa89 Sep 19, 2023
ae535b7
Removing duplicated plots.
germa89 Sep 19, 2023
17d18fb
Increasing time build
germa89 Sep 20, 2023
4f411cd
Fixing mesh color bug
germa89 Sep 20, 2023
2dafec0
Using pytest-pyvista action for cache. Activating more tests. Improvi…
germa89 Sep 20, 2023
6d67ffb
Changing function name
germa89 Sep 20, 2023
f09d303
Removing unneeded eplot and prints in fixture
germa89 Sep 20, 2023
598a476
Grouping tests. Cosmetic changes
germa89 Sep 20, 2023
0a33d25
Merge branch 'fix/several-plot-fix' of https://github.com/pyansys/pym…
germa89 Sep 20, 2023
d5fe0da
Reorg tests.
germa89 Sep 20, 2023
bb6e510
Small fix to test
germa89 Sep 20, 2023
0e80cd2
Updating image cache
germa89 Sep 20, 2023
922366c
Updating cache
germa89 Sep 20, 2023
edb7cc5
Using a higher tolerance in bc legend tests
germa89 Sep 20, 2023
0229227
Updating image cache
germa89 Sep 20, 2023
3c43545
Adding pytest-pyvista configuration to fixture.
germa89 Sep 20, 2023
cc584e4
Updating image cache
germa89 Sep 20, 2023
19b5dff
Merge branch 'main' into fix/several-plot-fix
germa89 Sep 20, 2023
117356a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 20, 2023
a2476de
Updating cache image
germa89 Sep 20, 2023
3218610
Update image cache
germa89 Sep 21, 2023
a53d01a
Testing adding the files to the PR
germa89 Sep 21, 2023
cfdd076
Commenting out assertion
germa89 Sep 21, 2023
bc2a582
Merge branch 'main' into fix/several-plot-fix
germa89 Sep 21, 2023
cadde8d
commenting unused variable
germa89 Sep 21, 2023
e076b79
fixing yaml
germa89 Sep 21, 2023
69dae21
empty commit to trigger cicd
germa89 Sep 21, 2023
d17d5be
empty commit to reset the plotting.py file
germa89 Sep 21, 2023
8810620
Revent changes
germa89 Sep 21, 2023
9147809
fixing plot bug
germa89 Sep 21, 2023
3fa11c5
reventing ci.yml file
germa89 Sep 21, 2023
a46c5df
reverting to main
germa89 Sep 21, 2023
ea2e3cf
Adding files to PR
germa89 Sep 21, 2023
0d294e2
removing 'local' tag from git config
germa89 Sep 22, 2023
086b407
Fixing link in wsl
germa89 Sep 25, 2023
eb339ba
Updating image cache and removing PR part
germa89 Sep 25, 2023
cafa1ca
Merge branch 'fix/several-plot-fix' of https://github.com/pyansys/pym…
germa89 Sep 28, 2023
ca0004e
Merge branch 'main' into fix/several-plot-fix
germa89 Sep 28, 2023
f6fe979
Making sure the theme is applied at the beginning.
germa89 Sep 28, 2023
d7d2d4b
Improvement to bug template
germa89 Sep 28, 2023
8f6da42
Merge branch 'main' into fix/several-plot-fix
germa89 Oct 2, 2023
de03113
Resetting image cache to main
germa89 Oct 2, 2023
ee5c03d
recache some tests
germa89 Oct 2, 2023
b9cdfc8
removing dedundant tests
germa89 Oct 2, 2023
4167a39
removing codacy warning
germa89 Oct 2, 2023
42fb776
Removing some start imports
germa89 Oct 2, 2023
32d542c
Adding automatically missing images
germa89 Oct 2, 2023
380f753
Adding back useful stuff
germa89 Oct 2, 2023
0145ff0
Recache some test case senstive
germa89 Oct 2, 2023
2dbf2dc
Adding more fields to test to avoid pytest.pyvista names collision. S…
germa89 Oct 2, 2023
bf65985
Merge branch 'fix/several-plot-fix' of https://github.com/pyansys/pym…
germa89 Oct 2, 2023
14ce0b7
adding missing image cache
germa89 Oct 2, 2023
80ce921
Merge branch 'main' into fix/several-plot-fix
germa89 Oct 2, 2023
fea703c
Update the image cache
germa89 Oct 2, 2023
a6f772e
Empty comment to trigger CICD
germa89 Oct 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
name: "Build documentation"
runs-on: ubuntu-latest
needs: doc-style
timeout-minutes: 45
timeout-minutes: 60
germa89 marked this conversation as resolved.
Show resolved Hide resolved
outputs:
PYMAPDL_VERSION: ${{ steps.version.outputs.PYMAPDL_VERSION }}
env:
Expand Down
9 changes: 8 additions & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
import os
import warnings

from ansys_sphinx_theme import ansys_favicon, get_version_match, pyansys_logo_black
from ansys_sphinx_theme import (
ansys_favicon,
get_version_match,
pyansys_logo_black,
pyansys_logo_white,
)
germa89 marked this conversation as resolved.
Show resolved Hide resolved
import numpy as np
import pyvista
from sphinx.application import Sphinx
Expand Down Expand Up @@ -240,6 +245,8 @@
"image_scrapers": ("pyvista", "matplotlib"),
"ignore_pattern": "flycheck*",
"thumbnail_size": (350, 350),
"remove_config_comments": True,
"default_thumb_file": pyansys_logo_white,
germa89 marked this conversation as resolved.
Show resolved Hide resolved
}
# ---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
The Power Graphics style plot is then set up via PyVista.

"""
# sphinx_gallery_thumbnail_path = './_static/model_solenoid_2d.png'
germa89 marked this conversation as resolved.
Show resolved Hide resolved

import numpy as np
import pyvista as pv

Expand Down
2 changes: 1 addition & 1 deletion examples/01-geometry/00-keypoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
# plotting methods.
mapdl.kplot(
show_keypoint_numbering=True,
germa89 marked this conversation as resolved.
Show resolved Hide resolved
background="black",
background="white",
germa89 marked this conversation as resolved.
Show resolved Hide resolved
show_bounds=True,
font_size=26,
)
Expand Down
103 changes: 0 additions & 103 deletions tests/test_mapdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
QUICK_LAUNCH_SWITCHES,
germa89 marked this conversation as resolved.
Show resolved Hide resolved
skip_if_not_local,
skip_if_on_cicd,
skip_no_xserver,
skip_on_windows,
)

Expand Down Expand Up @@ -368,47 +367,6 @@ def test_invalid_input(mapdl):
mapdl.input("thisisnotafile")


@skip_no_xserver
@pytest.mark.parametrize("vtk", [True, False, None])
def test_kplot(cleared, mapdl, tmpdir, vtk):
mapdl.k("", 0, 0, 0)
mapdl.k("", 1, 0, 0)
mapdl.k("", 1, 1, 0)
mapdl.k("", 0, 1, 0)

filename = str(tmpdir.mkdir("tmpdir").join("tmp.png"))
cpos = mapdl.kplot(vtk=vtk, savefig=filename)
assert cpos is None
if vtk:
assert os.path.isfile(filename)


@skip_no_xserver
@pytest.mark.parametrize("vtk", [True, False, None])
def test_aplot(cleared, mapdl, vtk):
k0 = mapdl.k("", 0, 0, 0)
k1 = mapdl.k("", 1, 0, 0)
k2 = mapdl.k("", 1, 1, 0)
k3 = mapdl.k("", 0, 1, 0)
l0 = mapdl.l(k0, k1)
l1 = mapdl.l(k1, k2)
l2 = mapdl.l(k2, k3)
l3 = mapdl.l(k3, k0)
mapdl.al(l0, l1, l2, l3)
mapdl.aplot(show_area_numbering=True)
mapdl.aplot(color_areas=vtk, show_lines=True, show_line_numbering=True)

mapdl.aplot(quality=100)
mapdl.aplot(quality=-1)


@skip_no_xserver
@pytest.mark.parametrize("vtk", [True, False, None])
def test_vplot(cleared, mapdl, vtk):
mapdl.block(0, 1, 0, 1, 0, 1)
mapdl.vplot(vtk=vtk, color_areas=True)


def test_keypoints(cleared, mapdl):
assert mapdl.geometry.n_keypoint == 0
kps = [[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]]
Expand Down Expand Up @@ -443,25 +401,6 @@ def test_lines(cleared, mapdl):
assert mapdl.geometry.n_line == 4


@skip_no_xserver
@pytest.mark.parametrize("vtk", [True, False, None])
def test_lplot(cleared, mapdl, tmpdir, vtk):
k0 = mapdl.k("", 0, 0, 0)
k1 = mapdl.k("", 1, 0, 0)
k2 = mapdl.k("", 1, 1, 0)
k3 = mapdl.k("", 0, 1, 0)
mapdl.l(k0, k1)
mapdl.l(k1, k2)
mapdl.l(k2, k3)
mapdl.l(k3, k0)

filename = str(tmpdir.mkdir("tmpdir").join("tmp.png"))
cpos = mapdl.lplot(vtk=vtk, show_keypoint_numbering=True, savefig=filename)
assert cpos is None
if vtk:
assert os.path.isfile(filename)


@skip_if_not_local
def test_apdl_logging_start(tmpdir):
filename = str(tmpdir.mkdir("tmpdir").join("tmp.inp"))
Expand Down Expand Up @@ -622,24 +561,6 @@ def test_enum(mapdl, make_block):
assert np.allclose(mapdl.mesh.enum, range(1, mapdl.mesh.n_elem + 1))


@pytest.mark.parametrize("nnum", [True, False])
@pytest.mark.parametrize("vtk", [True, False, None])
@skip_no_xserver
def test_nplot_vtk(cleared, mapdl, nnum, vtk):
mapdl.n(1, 0, 0, 0)
mapdl.n(11, 10, 0, 0)
mapdl.fill(1, 11, 9)
mapdl.nplot(vtk=vtk, nnum=nnum, background="w", color="k")


@skip_no_xserver
def test_nplot(cleared, mapdl):
mapdl.n(1, 0, 0, 0)
mapdl.n(11, 10, 0, 0)
mapdl.fill(1, 11, 9)
mapdl.nplot(vtk=False)


def test_elements(cleared, mapdl):
mapdl.et(1, 185)

Expand Down Expand Up @@ -761,30 +682,6 @@ def test_builtin_parameters(mapdl, cleared):
assert mapdl.parameters.real == 1


@skip_no_xserver
@pytest.mark.parametrize("vtk", [True, False, None])
def test_eplot(mapdl, make_block, vtk):
init_elem = mapdl.mesh.n_elem
mapdl.aplot() # check aplot and verify it doesn't mess up the element plotting
mapdl.eplot(show_node_numbering=True, background="w", color="b")
mapdl.eplot(vtk=vtk, show_node_numbering=True, background="w", color="b")
mapdl.aplot() # check aplot and verify it doesn't mess up the element plotting
assert mapdl.mesh.n_elem == init_elem


@skip_no_xserver
def test_eplot_savefig(mapdl, make_block, tmpdir):
filename = str(tmpdir.mkdir("tmpdir").join("tmp.png"))
mapdl.eplot(
background="w",
show_edges=True,
smooth_shading=True,
window_size=[1920, 1080],
savefig=filename,
)
assert os.path.isfile(filename)


def test_partial_mesh_nnum(mapdl, make_block):
allsel_nnum_old = mapdl.mesh.nnum
mapdl.nsel("S", "NODE", vmin=100, vmax=200)
Expand Down
58 changes: 18 additions & 40 deletions tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from ansys.mapdl.core.errors import ComponentDoesNotExits
from ansys.mapdl.core.plotting import general_plotter
from conftest import skip_no_xserver


@pytest.fixture
Expand Down Expand Up @@ -37,23 +36,22 @@ def bc_example(mapdl, make_block):
mapdl.nsel("all")


@skip_no_xserver
def test_kplot(cleared, mapdl, tmpdir):
@pytest.mark.parametrize("vtk", [True, False, None])
def test_kplot(cleared, mapdl, tmpdir, vtk):
germa89 marked this conversation as resolved.
Show resolved Hide resolved
mapdl.k("", 0, 0, 0)
mapdl.k("", 1, 0, 0)
mapdl.k("", 1, 1, 0)
mapdl.k("", 0, 1, 0)

filename = str(tmpdir.mkdir("tmpdir").join("tmp.png"))
cpos = mapdl.kplot(savefig=filename)
cpos = mapdl.kplot(vtk=vtk, savefig=filename)
assert cpos is None
assert os.path.isfile(filename)

mapdl.kplot(vtk=False) # make sure legacy still works
if vtk:
assert os.path.isfile(filename)


@skip_no_xserver
def test_lplot(cleared, mapdl, tmpdir):
@pytest.mark.parametrize("vtk", [True, False, None])
def test_lplot(cleared, mapdl, tmpdir, vtk):
k0 = mapdl.k("", 0, 0, 0)
k1 = mapdl.k("", 1, 0, 0)
k2 = mapdl.k("", 1, 1, 0)
Expand All @@ -64,15 +62,14 @@ def test_lplot(cleared, mapdl, tmpdir):
mapdl.l(k3, k0)

filename = str(tmpdir.mkdir("tmpdir").join("tmp.png"))
cpos = mapdl.lplot(show_keypoint_numbering=True, savefig=filename)
cpos = mapdl.lplot(vtk=vtk, show_keypoint_numbering=True, savefig=filename)
germa89 marked this conversation as resolved.
Show resolved Hide resolved
assert cpos is None
assert os.path.isfile(filename)
if vtk:
assert os.path.isfile(filename)

mapdl.lplot(vtk=False) # make sure legacy still works


@skip_no_xserver
def test_aplot(cleared, mapdl):
@pytest.mark.parametrize("vtk", [True, False, None])
germa89 marked this conversation as resolved.
Show resolved Hide resolved
def test_aplot(cleared, mapdl, vtk):
k0 = mapdl.k("", 0, 0, 0)
k1 = mapdl.k("", 1, 0, 0)
k2 = mapdl.k("", 1, 1, 0)
Expand All @@ -83,49 +80,36 @@ def test_aplot(cleared, mapdl):
l3 = mapdl.l(k3, k0)
mapdl.al(l0, l1, l2, l3)
mapdl.aplot(show_area_numbering=True)
mapdl.aplot(color_areas=True, show_lines=True, show_line_numbering=True)
mapdl.aplot(vtk=vtk, color_areas=vtk, show_lines=True, show_line_numbering=True)
germa89 marked this conversation as resolved.
Show resolved Hide resolved

mapdl.aplot(quality=100)
mapdl.aplot(quality=-1)

# and legacy as well
mapdl.aplot(vtk=False)


@skip_no_xserver
@pytest.mark.parametrize("vtk", [True, False])
@pytest.mark.parametrize("vtk", [True, False, None])
def test_vplot(cleared, mapdl, vtk):
mapdl.block(0, 1, 0, 1, 0, 1)
mapdl.vplot(vtk=vtk, color_areas=True)


@skip_no_xserver
def test_nplot(cleared, mapdl):
mapdl.n(1, 0, 0, 0)
mapdl.n(11, 10, 0, 0)
mapdl.fill(1, 11, 9)
mapdl.nplot(vtk=False)


@pytest.mark.parametrize("nnum", [True, False])
@skip_no_xserver
def test_nplot_vtk(cleared, mapdl, nnum):
@pytest.mark.parametrize("vtk", [True, False, None])
def test_nplot(cleared, mapdl, nnum, vtk):
germa89 marked this conversation as resolved.
Show resolved Hide resolved
mapdl.n(1, 0, 0, 0)
mapdl.n(11, 10, 0, 0)
mapdl.fill(1, 11, 9)
mapdl.nplot(vtk=True, nnum=nnum, background="w", color="k")
mapdl.nplot(vtk=vtk, nnum=nnum, background="w", color="k")


@skip_no_xserver
def test_eplot(mapdl, make_block):
init_elem = mapdl.mesh.n_elem
mapdl.aplot() # check aplot and verify it doesn't mess up the element plotting
mapdl.eplot(show_node_numbering=True, background="w", color="b")
mapdl.eplot(vtk=vtk, show_node_numbering=True, background="w", color="b")
mapdl.aplot() # check aplot and verify it doesn't mess up the element plotting
assert mapdl.mesh.n_elem == init_elem


@skip_no_xserver
def test_eplot_savefig(mapdl, make_block, tmpdir):
filename = str(tmpdir.mkdir("tmpdir").join("tmp.png"))
mapdl.eplot(
Expand All @@ -138,7 +122,6 @@ def test_eplot_savefig(mapdl, make_block, tmpdir):
assert os.path.isfile(filename)


@skip_no_xserver
@pytest.mark.parametrize("return_plotter", [True, False])
@pytest.mark.parametrize("plot_bc_legend", [True, False])
@pytest.mark.parametrize("plot_bc_labels", [True, False])
Expand All @@ -158,7 +141,6 @@ def test_bc_plot_options(
assert p is None


@skip_no_xserver
@pytest.mark.parametrize(
"bc_labels",
[
Expand All @@ -181,7 +163,6 @@ def test_bc_plot_bc_labels(mapdl, bc_example, bc_labels):
assert isinstance(p, Plotter)


@skip_no_xserver
@pytest.mark.parametrize(
"bc_labels",
[
Expand All @@ -199,7 +180,6 @@ def test_bc_plot_bc_labels_error(mapdl, bc_example, bc_labels):
)


@skip_no_xserver
@pytest.mark.parametrize(
"bc_target",
[
Expand All @@ -217,7 +197,6 @@ def test_bc_plot_bc_target(mapdl, bc_example, bc_target):
assert isinstance(p, Plotter)


@skip_no_xserver
@pytest.mark.parametrize(
"bc_target",
[
Expand Down Expand Up @@ -697,7 +676,6 @@ def test_color_areas_fail(mapdl, make_block):
assert len(np.unique(pl.mesh.cell_data["Data"], axis=0)) == mapdl.geometry.n_area


@skip_no_xserver
@pytest.mark.parametrize(
"color_areas",
[
Expand Down