Skip to content

Commit b052c85

Browse files
committed
fix: update no_new_attr import logic for pyvista version compatibility
1 parent fa5a915 commit b052c85

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed

src/ansys/mapdl/core/mapdl_core.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2700,7 +2700,12 @@ def _enable_picking_entities(
27002700
pass
27012701

27022702
# adding selection inversor
2703-
pl.scene._inver_mouse_click_selection = False
2703+
import pyvista
2704+
2705+
if pyvista.version_info >= (0, 46, 0):
2706+
pyvista.set_new_attribute(pl.scene, "_inver_mouse_click_selection", False)
2707+
else:
2708+
pl.scene._inver_mouse_click_selection = False
27042709

27052710
selection_text = {
27062711
"S": "New selection",

src/ansys/mapdl/core/plotting/plotting_defaults.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@
2424
from pyvista.core import _vtk_core as _vtk
2525
from pyvista.core.utilities import translate
2626
from pyvista.core.utilities.helpers import wrap
27-
from pyvista.core.utilities.misc import no_new_attr
27+
28+
if pv.version_info >= (0, 46, 0):
29+
# From v0.46.0, this decorator is not needed anymore.
30+
def no_new_attr(cls):
31+
return cls
32+
33+
else:
34+
from pyvista.core.utilities.misc import no_new_attr
2835

2936
# I dont want to have to fix a very recent lower bound for pyvista.
3037
# Hence I'm copying what I need from there.

tests/test_plotting.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -566,8 +566,8 @@ def test_pick_nodes(mapdl, make_block, selection, verify_image_cache):
566566
def debug_orders(pl, point):
567567
pl = pl.scene
568568
pl.show(auto_close=False)
569-
pl.windows_size = (100, 100)
570-
width, height = pl.window_size
569+
width, height = (100, 100)
570+
571571
if pl._picking_right_clicking_observer is None:
572572
pl.iren._mouse_left_button_press(
573573
int(width * point[0]), int(height * point[1])
@@ -638,8 +638,8 @@ def test_pick_kp(mapdl, make_block, selection):
638638
def debug_orders(pl, point):
639639
pl = pl.scene
640640
pl.show(auto_close=False)
641-
pl.windows_size = (100, 100)
642-
width, height = pl.window_size
641+
width, height = (100, 100)
642+
643643
if pl._picking_right_clicking_observer is None:
644644
pl.iren._mouse_left_button_press(
645645
int(width * point[0]), int(height * point[1])
@@ -759,8 +759,7 @@ def test_pick_node_special_cases(mapdl, make_block):
759759
def debug_orders_0(pl, point):
760760
pl = pl.scene
761761
pl.show(auto_close=False)
762-
pl.windows_size = (100, 100)
763-
width, height = pl.window_size
762+
width, height = (100, 100)
764763
pl.iren._mouse_move(int(width * point[0]), int(height * point[1]))
765764

766765
mapdl.nsel("S", "node", "", 1)
@@ -777,8 +776,8 @@ def debug_orders_0(pl, point):
777776
def debug_orders_1(pl, point):
778777
pl = pl.scene
779778
pl.show(auto_close=False)
780-
pl.windows_size = (100, 100)
781-
width, height = pl.window_size
779+
width, height = (100, 100)
780+
782781
# First click
783782
pl.iren._mouse_left_button_press(int(width * point[0]), int(height * point[1]))
784783
pl.iren._mouse_left_button_release(width, height)
@@ -810,8 +809,8 @@ def test_pick_node_select_unselect_with_mouse(mapdl, make_block):
810809
def debug_orders_1(pl, point):
811810
pl = pl.scene
812811
pl.show(auto_close=False)
813-
pl.windows_size = (100, 100)
814-
width, height = pl.window_size
812+
width, height = (100, 100)
813+
815814
# First click- selecting
816815
pl.iren._mouse_left_button_press(int(width * point[0]), int(height * point[1]))
817816
pl.iren._mouse_left_button_release(width, height)
@@ -848,8 +847,7 @@ def test_pick_areas(mapdl, make_block, selection):
848847
def debug_orders(pl, point):
849848
pl = pl.scene
850849
pl.show(auto_close=False)
851-
pl.windows_size = (100, 100)
852-
width, height = pl.window_size
850+
width, height = (100, 100)
853851
if pl._picking_right_clicking_observer is None:
854852
pl.iren._mouse_left_button_press(
855853
int(width * point[0]), int(height * point[1])

0 commit comments

Comments
 (0)