Skip to content

Commit

Permalink
TEST: added test and even more explanation for issue #261
Browse files Browse the repository at this point in the history
  • Loading branch information
gdementen committed Oct 5, 2023
1 parent 6ce43ed commit 773192b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion larray_editor/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,16 @@ def _show_dialog(app_name, create_dialog_func, *args, **kwargs):
# (see issue #253) or after showing matplotlib figures (see issue #261).

# We have not found any way to explicitly check whether the main event loop
# is already running, so we now assume that if the parent window is not
# is already running (*), so we now assume that if the parent window is not
# a descendant of our own MappingEditor, no event loop is running, as it is
# unlikely another Qt application calls the *api functions* instead of
# embedding the widget. Note that jupyter qtconsole works, because the
# Python kernel process is not the same as the process running the
# interface, so QApplication.instance() returns None in the kernel process.

# (*) QEventLoop has an isRunning() method, but QCoreApplication *acts*
# as an event loop but does not inherit from QEventLoop, and it lacks
# the method.
if parent is None:
# We do not use install_except_hook/restore_except_hook so that we can restore the hook actually used when
# this function is called instead of the one which was used when the module was loaded.
Expand Down
11 changes: 11 additions & 0 deletions larray_editor/tests/test_api_larray.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ def make_demo(width=20, ball_radius=5, path_radius=5, steps=30):
return la.maximum(ball_radius - la.sqrt((x - ball_center_x) ** 2 + (y - ball_center_y) ** 2), 0).transpose(x, y)


def test_matplotlib_show_interaction():
import matplotlib.pyplot as plt

arr = la.ndtest((3, 4))
arr.plot()
plt.show()
edit()


demo = make_demo(9, 2.5, 1.5)
sphere = make_sphere(9, 4)
extreme_array = la.Array([-la.inf, -1, 0, la.nan, 1, la.inf])
Expand Down Expand Up @@ -208,3 +217,5 @@ def test_run_editor_on_exception(local_arr):
# run_editor_on_exception(usercode_traceback=False, usercode_frame=False)

# test_run_editor_on_exception(arr2)

test_matplotlib_show_interaction()

0 comments on commit 773192b

Please sign in to comment.