Skip to content

Commit

Permalink
Fixing some plot stuff and small gallery improvements (#2349)
Browse files Browse the repository at this point in the history
* Renaming file and changing thumbnail

* Small fix to doc build

* Activating plots

* Removing duplicated plots.

Removing skip_if_no_xserver

* Increasing time build

* Fixing mesh color bug

* Using pytest-pyvista action for cache. Activating more tests. Improving some

* Changing function name

* Removing unneeded eplot and prints in fixture

* Grouping tests. Cosmetic changes

* Reorg tests.
Plotting some returned plotter objects.
Removing unnecessary plots in fixtures.

* Small fix to test

* Updating image cache

* Updating cache

* Using a higher tolerance in bc legend tests

* Updating image cache

* Adding pytest-pyvista configuration to fixture.

* Updating image cache

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Updating cache image

* Update image cache

* Testing adding the files to the PR

* Commenting out assertion

* commenting unused variable

* fixing yaml

* empty commit to trigger cicd

* empty commit to reset the plotting.py file

* Revent changes

* fixing plot bug

* reventing ci.yml file

* reverting to main

* Adding files to PR

* removing 'local' tag from git config

* Fixing link in wsl

* Updating image cache and removing PR part

* Making sure the theme is applied at the beginning.

* Improvement to bug template

* Resetting image cache to main

* recache some tests

* removing dedundant tests

* removing codacy warning

* Removing some start imports

* Adding automatically missing images

* Adding back useful stuff

* Recache some test case senstive

* Adding more fields to test to avoid pytest.pyvista names collision. See pyvista/pytest-pyvista#93

* adding missing image cache

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
germa89 and pre-commit-ci[bot] committed Oct 2, 2023
1 parent 05ba35d commit c077163
Show file tree
Hide file tree
Showing 83 changed files with 196 additions and 282 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ body:
required: true
- label: I am using a [Python virtual environment](https://docs.python.org/3/library/venv.html).
required: true
- label: I am using the [latest version of PyMAPDL](https://github.com/ansys/pymapdl/releases) and its dependencies (fully updated virtual environment). You can update them using ``pip install --upgrade --upgrade-strategy eager ansys-mapdl-core``.
- label: I am using the [latest version of PyMAPDL](https://github.com/ansys/pymapdl/releases) and its dependencies (fully updated virtual environment). You can update them using ``pip install --upgrade --upgrade-strategy eager ansys-mapdl-core`` in your activated virtual environment.
required: true

- type: textarea
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ jobs:
if [[ "${{ matrix.mapdl-version }}" == *"ubuntu"* ]]; then export ON_UBUNTU=true;fi
xvfb-run pytest \
${{ env.PYTEST_ARGUMENTS }} \
--ignore_image_cache \
--cov-report=xml:centos-${{ matrix.mapdl-version }}-remote.xml
- uses: codecov/codecov-action@v3
Expand Down Expand Up @@ -516,7 +517,7 @@ jobs:
export AWP_ROOT222=/ansys_inc
xvfb-run pytest -k "not test_database and not test_dpf" \
${{ env.PYTEST_ARGUMENTS }} \
--reset_only_failed \
--reset_only_failed --add_missing_images \
--cov-report=xml:ubuntu-v22.2.0-local.xml
- name: "Adding the directory as safe directory for later step"
Expand Down Expand Up @@ -620,7 +621,7 @@ jobs:
set PYMAPDL_START_INSTANCE=
python -m pytest -k "not test_database and not test_dpf" \
${{ env.PYTEST_ARGUMENTS }} \
--skip-regression-check \
--ignore_image_cache \
--cov-report=xml:windows-v22.2.0-local.xml
- uses: codecov/codecov-action@v3
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,
)
import numpy as np
import pyvista
from sphinx.application import Sphinx
Expand Down Expand Up @@ -236,6 +241,8 @@
"image_scrapers": ("pyvista", "matplotlib"),
"ignore_pattern": "flycheck*",
"thumbnail_size": (350, 350),
"remove_config_comments": True,
"default_thumb_file": pyansys_logo_white,
}
# ---

Expand Down
2 changes: 1 addition & 1 deletion doc/source/getting_started/wsl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ show how to use it together with MAPDL, PyMAPDL, and `Docker <https://www.docker

.. note::
Because WSL is under constant development, keeping this guide updated is difficult. If you
find any issues or have questions related to WSL, feel free to `open an issue in the GitHub repository <pymapdl_issues>`_.
find any issues or have questions related to WSL, feel free to `open an issue in the GitHub repository <pymapdl_issues_>`_.


Install WSL
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'

import numpy as np
import pyvista as pv

Expand Down Expand Up @@ -292,9 +294,9 @@

plotter = pv.Plotter()

for i in range(0, len(grids)):
for i, grid in enumerate(grids):
plotter.add_mesh(
grids[i],
grid,
scalars=scalars[i],
show_edges=True,
cmap=PyMAPDL_cmap,
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,
background="black",
background="white",
show_bounds=True,
font_size=26,
)
Expand Down
8 changes: 5 additions & 3 deletions src/ansys/mapdl/core/examples/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from .downloads import *
from .downloads import _download_rotor_tech_demo_plot, download_cfx_mapping_example_data
from .examples import *
from .downloads import (
download_bracket,
download_cfx_mapping_example_data,
download_manifold_example_data,
)
from .verif_files import vmfiles
2 changes: 1 addition & 1 deletion src/ansys/mapdl/core/examples/downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def download_vtk_rotor():
return _download_file("rotor.vtk", "geometry")[0]


def _download_rotor_tech_demo_plot():
def _download_rotor_tech_demo_vtk():
"""Download the rotor surface VTK file."""
return _download_file("rotor2.vtk", "geometry")[0]

Expand Down
Binary file modified tests/.image_cache/aplot[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/aplot[False]_1.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/aplot[False]_2.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/aplot[None].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/aplot[None]_1.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/aplot[None]_2.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/aplot[None]_3.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/aplot[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/aplot[True]_1.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/aplot[True]_2.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/aplot[True]_3.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/background.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/bc_plot_bc_labels[CSGZ].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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/bc_plot_bc_labels[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/bc_plot_bc_target[Nodes].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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-False].png
Binary file modified tests/.image_cache/bc_plot_options[False-True-False].png
Binary file modified tests/.image_cache/bc_plot_options[True-False-False].png
Binary file modified tests/.image_cache/bc_plot_options[True-True-False].png
Binary file added tests/.image_cache/cmplot_all[KP].png
Binary file added tests/.image_cache/cmplot_all[NODE].png
Binary file added tests/.image_cache/cmplot_individual[AREA].png
Binary file added tests/.image_cache/cmplot_individual[ELEM].png
Binary file added tests/.image_cache/cmplot_individual[KP].png
Binary file added tests/.image_cache/cmplot_individual[LINE].png
Binary file added tests/.image_cache/cmplot_individual[NODE].png
Binary file added tests/.image_cache/cmplot_individual[VOLU].png
Binary file added tests/.image_cache/color_areas.png
Binary file modified tests/.image_cache/eplot[False].png
Binary file modified tests/.image_cache/eplot[False]_1.png
Binary file modified tests/.image_cache/eplot[False]_2.png
Binary file modified tests/.image_cache/eplot[None].png
Binary file modified tests/.image_cache/eplot[None]_1.png
Binary file modified tests/.image_cache/eplot[None]_2.png
Binary file modified tests/.image_cache/eplot[None]_3.png
Binary file modified tests/.image_cache/eplot[True].png
Binary file modified tests/.image_cache/eplot[True]_1.png
Binary file modified tests/.image_cache/eplot[True]_2.png
Binary file modified tests/.image_cache/eplot[True]_3.png
Binary file modified tests/.image_cache/eplot_savefig.png
Binary file modified tests/.image_cache/kplot[None].png
Binary file modified tests/.image_cache/kplot[True].png
Binary file modified tests/.image_cache/lplot[None].png
Binary file modified tests/.image_cache/lplot[True].png
Binary file added tests/.image_cache/nplot[None-False].png
Binary file added tests/.image_cache/nplot[None-True].png
Binary file added tests/.image_cache/nplot[True-False].png
Binary file added tests/.image_cache/nplot[True-True].png
Binary file added tests/.image_cache/plotter_input.png
Binary file added tests/.image_cache/show_bounds.png
Binary file added tests/.image_cache/vplot[None].png
Binary file added tests/.image_cache/vplot[True].png
28 changes: 14 additions & 14 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from ansys.mapdl.core.errors import MapdlExitedError, MapdlRuntimeError
from ansys.mapdl.core.examples import vmfiles
from ansys.mapdl.core.launcher import get_start_instance, launch_mapdl
from ansys.mapdl.core.theme import _apply_default_theme
from common import (
Element,
Node,
Expand All @@ -28,6 +29,8 @@
is_smp,
)

_apply_default_theme()

################################################################
#
# Setting testing environment
Expand Down Expand Up @@ -209,9 +212,20 @@ def pytest_collection_modifyitems(config, items):

@pytest.fixture(autouse=True)
def wrapped_verify_image_cache(verify_image_cache, pytestconfig):
# Checking if we want to avoid the check using pytest cli.
skip_regression_check = pytestconfig.option.skip_regression_check
if skip_regression_check:
verify_image_cache.skip = True

# Configuration
# default check
verify_image_cache.error_value = 500.0
verify_image_cache.warning_value = 200.0

# High variance test
verify_image_cache.var_error_value = 1000.0
verify_image_cache.var_warning_value = 1000.0

return verify_image_cache


Expand Down Expand Up @@ -703,7 +717,6 @@ def contact_geom_and_mesh(mapdl):
mapdl.vsweep("all")
mapdl.allsel("all")

# mapdl.eplot()
# ==========================================================
# * Contact Pairs
# ==========================================================
Expand Down Expand Up @@ -745,12 +758,10 @@ def contact_geom_and_mesh(mapdl):
mapdl.mat(1)
mapdl.asel("s", "", "", 5)
mapdl.nsla("", 1)
# mapdl.nplot()
mapdl.cm("tn.cnt", "node") # Creating component on weld side of plate1

mapdl.asel("s", "", "", 12)
mapdl.nsla("", 1)
# mapdl.nplot()
mapdl.cm("tn.tgt", "node") # Creating component on weld side of plate2

mapdl.allsel("all")
Expand All @@ -762,7 +773,6 @@ def contact_geom_and_mesh(mapdl):
# for welding, 'C
mapdl.real(6)
mapdl.cmsel("s", "tn.cnt")
# mapdl.nplot()
mapdl.esurf()
mapdl.type(7)
mapdl.real(6)
Expand Down Expand Up @@ -939,7 +949,6 @@ def cuadratic_beam_problem(mapdl):

mapdl.mp("EX", 1, 30e6)
mapdl.mp("PRXY", 1, 0.3)
print(mapdl.mplist())

w_f = 1.048394965
w_w = 0.6856481
Expand All @@ -954,18 +963,9 @@ def cuadratic_beam_problem(mapdl):
# Define one node for the orientation of the beam cross-section.
orient_node = mapdl.n(6, 60, 1)

# Print the list of the created nodes.
print(mapdl.nlist())

for elem_num in range(1, 5):
mapdl.e(elem_num, elem_num + 1, orient_node)

# Print the list of the created elements.
print(mapdl.elist())

# Display elements with their nodes numbers.
mapdl.eplot(show_node_numbering=True, line_width=5, cpos="xy", font_size=40)

# BC for the beams seats
mapdl.d(2, "UX", lab2="UY")
mapdl.d(4, "UY")
Expand Down
6 changes: 3 additions & 3 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from ansys.mapdl.core import EXAMPLES_PATH, examples
from ansys.mapdl.core.examples.downloads import (
_download_file,
_download_rotor_tech_demo_plot,
_download_rotor_tech_demo_vtk,
check_directory_exist,
delete_downloads,
download_bracket,
Expand Down Expand Up @@ -112,9 +112,9 @@ def test_download_vtk_rotor(running_test):
assert download_vtk_rotor() is True


def test__download_rotor_tech_demo_plot(running_test):
def test__download_rotor_tech_demo_vtk(running_test):
with running_test():
assert _download_rotor_tech_demo_plot() is True
assert _download_rotor_tech_demo_vtk() is True


def test_download_example_data(running_test):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def test_vext(mapdl, cleared):
carc0 = mapdl.circle(k0, 1, k1)
a0 = mapdl.al(*carc0)

# next, extrude it and plot it
# next, and extrude it
mapdl.vext(a0, dz=4)


Expand Down Expand Up @@ -153,7 +153,7 @@ def test_va(mapdl, cleared):
a2 = mapdl.a(k1, k2, k3)
a3 = mapdl.a(k0, k2, k3)

# generate and plot the volume
# generate the volume
vnum = mapdl.va(a0, a1, a2, a3)
assert vnum == 1

Expand Down
Loading

0 comments on commit c077163

Please sign in to comment.