From 5b2d120e1de6209be05e51d1f72e3f17ab680750 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 3 Aug 2023 17:09:21 +0200 Subject: [PATCH] Updating pyvista to 0.41 (#2194) * Updating pyvista to 0.41 * Updating reader * Removing rcParams * Using pyvista 0.41.1 * Avoiding importing dpf. * adding missing import * Update tests/test_dpf.py * maint: updating `ansys-dpf-core` version * test: fixing `test_heal` * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * test: revert last commit --------- Co-authored-by: Camille <78221213+clatapie@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- doc/source/conf.py | 6 +++++- pyproject.toml | 10 +++++----- src/ansys/mapdl/core/theme.py | 12 +++++++++--- tests/test_dpf.py | 14 ++++++++++++-- tests/test_pool.py | 2 +- 5 files changed, 32 insertions(+), 12 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 07aa6bf104..004c42955b 100755 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -20,7 +20,11 @@ pyvista.OFF_SCREEN = True # must be less than or equal to the XVFB window size -pyvista.rcParams["window_size"] = np.array([1024, 768]) +try: + pyvista.global_theme.window_size = np.array([1024, 768]) +except AttributeError: + # for compatibility with pyvista < 0.40 + pyvista.rcParams["window_size"] = np.array([1024, 768]) # Save figures in specified directory pyvista.FIGURE_PATH = os.path.join(os.path.abspath("./images/"), "auto-generated/") diff --git a/pyproject.toml b/pyproject.toml index fdad0fd225..7a4fd65b2d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,7 +35,7 @@ dependencies = [ "pyansys-tools-versioning>=0.3.3", "ansys-tools-path>=0.3.1", "pyiges[full]>=0.3.1", # Since v0.3.0, the 'full' flag is needed in order to install 'geomdl' - "pyvista>=0.33.0,<0.41", + "pyvista>=0.33.0", "scipy>=1.3.0", # for sparse (consider optional?) "tqdm>=4.45.0", "vtk>=9.0.0", @@ -56,7 +56,7 @@ classifiers = [ [project.optional-dependencies] tests = [ - "ansys-dpf-core==0.8.1", + "ansys-dpf-core==0.9.0", "autopep8==2.0.2", "matplotlib==3.7.2", "scipy==1.10.1; python_version < '3.9'", # to support python 3.8 @@ -65,14 +65,14 @@ tests = [ "pyiges[full]==0.3.1", "pytest==7.4.0", "pytest-cov==4.1.0", - "pyvista==0.40.1", + "pyvista==0.41.1", "pyansys-tools-report==0.6.0", "vtk==9.2.6", "pytest-rerunfailures==12.0", ] doc = [ "sphinx==7.1.1", - "ansys-dpf-core==0.8.1", + "ansys-dpf-core==0.9.0", "ansys-mapdl-reader==0.52.19", "ansys-sphinx-theme==0.10.0", "grpcio==1.51.1", @@ -88,7 +88,7 @@ doc = [ "pypandoc==1.11", "pytest-sphinx==0.5.0", "pythreejs==2.4.2", - "pyvista[trame]==0.40.1", + "pyvista[trame]==0.41.1", "sphinx-autobuild==2021.3.14", "sphinx-autodoc-typehints==1.24.0", "sphinx-copybutton==0.5.2", diff --git a/src/ansys/mapdl/core/theme.py b/src/ansys/mapdl/core/theme.py index 9702095535..b50f22d033 100644 --- a/src/ansys/mapdl/core/theme.py +++ b/src/ansys/mapdl/core/theme.py @@ -7,10 +7,16 @@ if _HAS_PYVISTA: from pyvista.plotting.colors import get_cycler - try: # new in pyvista 0.40 - from pyvista.themes import Theme + try: + from pyvista.plotting.themes import Theme + except ImportError: - from pyvista.themes import DefaultTheme as Theme + from pyvista import __version__ as pyvista_version + + if "0.40" in pyvista_version: + from pyvista.themes import Theme + else: # older versions + from pyvista.themes import DefaultTheme as Theme base_class = Theme diff --git a/tests/test_dpf.py b/tests/test_dpf.py index fa98877e80..c5b48b580c 100644 --- a/tests/test_dpf.py +++ b/tests/test_dpf.py @@ -1,11 +1,21 @@ """Test the DPF implementation""" import os -from ansys.dpf import core as dpf -from ansys.dpf.core.server_types import DPF_DEFAULT_PORT +import pytest from conftest import skip_if_no_has_dpf +try: + from ansys.dpf import core as dpf + from ansys.dpf.core.server_types import DPF_DEFAULT_PORT +except ImportError: + skip_if_no_has_dpf = pytest.mark.skipif( + True, + reason="""DPF couldn't be imported.""", + ) + DPF_DEFAULT_PORT = None + + DPF_PORT = os.environ.get("DPF_PORT", DPF_DEFAULT_PORT) # Set in ci.yaml diff --git a/tests/test_pool.py b/tests/test_pool.py index 49c30aa00c..ce617b558f 100644 --- a/tests/test_pool.py +++ b/tests/test_pool.py @@ -59,7 +59,7 @@ def pool(): @skip_requires_194 def test_invalid_exec(): with pytest.raises(VersionError): - mapdl_pool = LocalMapdlPool(4, exec_file="/usr/ansys_inc/v194/ansys/bin/mapdl") + LocalMapdlPool(4, exec_file="/usr/ansys_inc/v194/ansys/bin/mapdl") @skip_if_not_local