8000 TEST: added test and even more explanation for issue #261 · larray-project/larray-editor@773192b · GitHub
[go: up one dir, main page]

Skip to content

Commit 773192b

Browse files
committed
TEST: added test and even more explanation for issue #261
1 parent 6ce43ed commit 773192b

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

larray_editor/api.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,16 @@ def _show_dialog(app_name, create_dialog_func, *args, **kwargs):
5757
# (see issue #253) or after showing matplotlib figures (see issue #261).
5858

5959
# We have not found any way to explicitly check whether the main event loop
60-
# is already running, so we now assume that if the parent window is not
60+
# is already running (*), so we now assume that if the parent window is not
6161
# a descendant of our own MappingEditor, no event loop is running, as it is
6262
# unlikely another Qt application calls the *api functions* instead of
6363
# embedding the widget. Note that jupyter qtconsole works, because the
6464
# Python kernel process is not the same as the process running the
6565
# interface, so QApplication.instance() returns None in the kernel process.
66+
67+
# (*) QEventLoop has an isRunning() method, but QCoreApplication *acts*
68+
# as an event loop but does not inherit from QEventLoop, and it lacks
69+
# the method.
6670
if parent is None:
6771
# We do not use install_except_hook/restore_except_hook so that we can restore the hook actually used when
6872
# this function is called instead of the one which was used when the module was loaded.

larray_editor/tests/test_api_larray.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ def make_demo(width=20, ball_radius=5, path_radius=5, steps=30):
100100
return la.maximum(ball_radius - la.sqrt((x - ball_center_x) ** 2 + (y - ball_center_y) ** 2), 0).transpose(x, y)
101101

102102

103+
def test_matplotlib_show_interaction():
104+
import matplotlib.pyplot as plt
105+
106+
arr = la.ndtest((3, 4))
107+
arr.plot()
108+
plt.show()
109+
edit()
110+
111+
103112
demo = make_demo(9, 2.5, 1.5)
104113
sphere = make_sphere(9, 4)
105114
extreme_array = la.Array([-la.inf, -1, 0, la.nan, 1, la.inf])
@@ -208,3 +217,5 @@ def test_run_editor_on_exception(local_arr):
208217
# run_editor_on_exception(usercode_traceback=False, usercode_frame=False)
209218

210219
# test_run_editor_on_exception(arr2)
220+
221+
test_matplotlib_show_interaction()

0 commit comments

Comments
 (0)
0