Skip to content

Commit

Permalink
Merge branch 'main' into fix/codecov-upload-token
Browse files Browse the repository at this point in the history
  • Loading branch information
germa89 committed Mar 15, 2024
2 parents 71a6936 + 2e71c2f commit f3306b0
Show file tree
Hide file tree
Showing 31 changed files with 89 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/codespaces-dev/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
ansys-dpf-core==0.10.1
ansys-dpf-core==0.11.0
autopep8==2.0.4
matplotlib==3.8.3
scipy==1.12.0
pandas==2.2.1
pyiges[full]==0.3.1
pytest==8.0.2
pytest-cov==4.1.0
pyvista==0.43.3
pyvista==0.43.4
pyansys-tools-report==0.7.0
vtk==9.3.0
pytest-rerunfailures==13.0
Expand Down
6 changes: 3 additions & 3 deletions .devcontainer/codespaces-docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sphinx==7.2.6
ansys-dpf-core==0.10.1
ansys-dpf-core==0.11.0
ansys-mapdl-reader==0.53.0
ansys-sphinx-theme==0.14.1
grpcio==1.62.0
Expand All @@ -10,14 +10,14 @@ jupyterlab>=3.2.8
matplotlib==3.8.3
numpydoc==1.6.0
pandas==2.2.1
plotly==5.19.0
plotly==5.20.0
pyiges[full]==0.3.1
pypandoc==1.13
pytest-sphinx==0.6.0
pythreejs==2.4.2
pyvista[trame]==0.43.3
sphinx-autobuild==2024.2.4
sphinx-autodoc-typehints==1.25.2
sphinx-autodoc-typehints==2.0.0
sphinx-copybutton==0.5.2
sphinx-gallery==0.15.0
sphinxcontrib-websupport==1.2.7
Expand Down
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer-local/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
ansys-dpf-core==0.10.1
ansys-dpf-core==0.11.0
autopep8==2.0.4
matplotlib==3.8.3
scipy==1.12.0
pandas==2.2.1
pyiges[full]==0.3.1
pytest==8.0.2
pytest-cov==4.1.0
pyvista==0.43.3
pyvista==0.43.4
pyansys-tools-report==0.7.0
vtk==9.3.0
pytest-rerunfailures==13.0
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ doc = [
"ansys-dpf-core==0.10.1",
"ansys-mapdl-reader==0.53.0",
"ansys-sphinx-theme==0.14.1",
"grpcio==1.62.0",
"grpcio==1.62.1",
"imageio-ffmpeg==0.4.9",
"imageio==2.34.0",
"jupyter_sphinx==0.5.3",
"jupyterlab>=3.2.8",
"matplotlib==3.8.3",
"numpydoc==1.6.0",
"pandas==2.2.1",
"plotly==5.19.0",
"plotly==5.20.0",
"pyiges[full]==0.3.1",
"pypandoc==1.13",
"pytest-sphinx==0.6.0",
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/mapdl/core/mapdl_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ def _kill_server(self):
pass

if (
self._version >= 24.2
self._version and self._version >= 24.2
): # We can't use the non-cached version because of recursion error.
# self.run("/EXIT,NOSAVE,,,,,SERVER")
self._ctrl("EXIT")
Expand Down
25 changes: 25 additions & 0 deletions src/ansys/mapdl/core/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# SOFTWARE.

"""Plotting helper for MAPDL using pyvista"""
from collections import OrderedDict
from typing import Any, Optional
from warnings import warn

Expand Down Expand Up @@ -58,6 +59,10 @@
"ELECTRICAL": ["VOLT", "CHRGS", "AMPS"],
}

FIELDS_ORDERED_LABELS = FIELDS["MECHANICAL"].copy()
FIELDS_ORDERED_LABELS.extend(FIELDS["THERMAL"])
FIELDS_ORDERED_LABELS.extend(FIELDS["ELECTRICAL"])


# All boundary conditions:
BCS = BC_D.copy()
Expand Down Expand Up @@ -1005,6 +1010,7 @@ def bc_nodes_plotter(
# line_width=3,
name=name_,
label=name_,
opacity=0.50,
)

if plot_bc_labels:
Expand Down Expand Up @@ -1032,6 +1038,25 @@ def bc_nodes_plotter(
)

if plot_bc_legend:
# Reorder labels to keep a consistent order
sorted_dict = OrderedDict()
labels_ = pl.renderer._labels.copy()

# sorting the keys
for symbol in FIELDS_ORDERED_LABELS:
for key, value in labels_.items():
if symbol == value[1]:
sorted_dict[key] = value

# moving the not added labels (just in case)
for key, value in labels_.items():
if value[1] not in FIELDS_ORDERED_LABELS:
sorted_dict[key] = value

assert sorted_dict == labels_

# overwriting labels
pl.renderer._labels = sorted_dict
pl.add_legend(bcolor=None)

return pl
Expand Down
Binary file modified tests/.image_cache/bc_plot_options[False-False-False].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/.image_cache/bc_plot_options[False-False-True].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/.image_cache/bc_plot_options[False-True-False].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/.image_cache/bc_plot_options[False-True-True].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/.image_cache/bc_plot_options[True-False-False].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/.image_cache/bc_plot_options[True-False-True].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/.image_cache/single_glyph[0-FX].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/.image_cache/single_glyph[0-FY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/.image_cache/single_glyph[0-FZ].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/.image_cache/single_glyph[0-UX].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/.image_cache/single_glyph[0-UY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/.image_cache/single_glyph[0-UZ].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/.image_cache/single_glyph[50-FX].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/.image_cache/single_glyph[50-FY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/.image_cache/single_glyph[50-FZ].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/.image_cache/single_glyph[50-UX].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/.image_cache/single_glyph[50-UY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/.image_cache/single_glyph[50-UZ].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/.image_cache/single_glyph[500-FX].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/.image_cache/single_glyph[500-FY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/.image_cache/single_glyph[500-FZ].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/.image_cache/single_glyph[500-UX].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/.image_cache/single_glyph[500-UY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/.image_cache/single_glyph[500-UZ].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 54 additions & 11 deletions tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,51 @@


@pytest.fixture
def bc_example(mapdl, make_block):
def bc_example(mapdl):
mapdl.prep7()
mapdl.et("", 189)

mapdl.n(1, 0, 0, 0)
mapdl.n(2, 1, 0, 0)
mapdl.n(3, 2, 0, 0)
mapdl.n(4, 0, 0, 1)
mapdl.n(5, 1, 0, 1)
mapdl.n(6, 2, 0, 1)

mapdl.nsel("s", "node", "", 1)
mapdl.f("all", "FX", 0)
mapdl.nsel("s", "node", "", 2)
mapdl.f("all", "FY", 0)
mapdl.nsel("s", "node", "", 3)
mapdl.f("all", "FZ", 0)

mapdl.nsel("s", "node", "", 2)
mapdl.f("all", "FX", 100)
mapdl.f("all", "FY", 200)
mapdl.f("all", "FZ", 100)

mapdl.nsel("s", "node", "", 3)
mapdl.nsel("s", "node", "", 4)
mapdl.d("all", "UX", 0)
mapdl.nsel("s", "node", "", 5)
mapdl.d("all", "UY", 0)
mapdl.nsel("s", "node", "", 6)
mapdl.d("all", "UZ", 0)

mapdl.nsel("s", "node", "", 4)
mapdl.d("all", "UX", 1)
mapdl.d("all", "UY", 2)
mapdl.d("all", "UZ", 3)
mapdl.n(7, 0, 1, 0)
mapdl.n(8, 1, 1, 0)
mapdl.n(9, 2, 1, 0)
mapdl.n(10, 0, 2, 0)
mapdl.n(11, 1, 2, 0)
mapdl.n(12, 2, 2, 0)

mapdl.nsel("s", "node", "", 7)
mapdl.f("all", "FX", 10)
mapdl.nsel("s", "node", "", 8)
mapdl.f("all", "FY", 20)
mapdl.nsel("s", "node", "", 9)
mapdl.f("all", "FZ", 30)

mapdl.nsel("s", "node", "", 10)
mapdl.d("all", "UX", 20)
mapdl.nsel("s", "node", "", 11)
mapdl.d("all", "UY", 20)
mapdl.nsel("s", "node", "", 12)
mapdl.d("all", "UZ", 20)

mapdl.nsel("all")

Expand Down Expand Up @@ -212,6 +235,25 @@ def test_eplot_savefig(mapdl, make_block, tmpdir):
assert os.path.isfile(filename)


@pytest.mark.parametrize("field", ["UX", "UY", "UZ", "FX", "FY", "FZ"])
@pytest.mark.parametrize("magnitude", [0, 50, 500])
def test_single_glyph(mapdl, field, magnitude, verify_image_cache):
mapdl.clear()
mapdl.prep7()
mapdl.et("", 189)
mapdl.n(1, 0, 0, 0)

if "U" in field:
mapdl.d(1, field, magnitude)
else:
mapdl.f(1, field, magnitude)

mapdl.allsel()
p = mapdl.nplot(
plot_bc=True, point_size=max(magnitude, 10), render_points_as_spheres=True
)


@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 @@ -222,6 +264,7 @@ def test_bc_plot_options(
return_plotter,
plot_bc_legend,
plot_bc_labels,
bc_labels_font_size=50,
):
if plot_bc_legend or plot_bc_labels:
# The legend and labels generate highly variance than other tests
Expand Down

0 comments on commit f3306b0

Please sign in to comment.