Skip to content

Commit 542cd05

Browse files
committed
added debug to larray namespace and api
also updated run_editor_on_exception wrapper
1 parent d0a7059 commit 542cd05

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

doc/source/api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,7 @@ Editor
826826

827827
view
828828
edit
829+
debug
829830
compare
830831
run_editor_on_exception
831832

larray/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
from larray.util.options import get_options, set_options
4040

41-
from larray.viewer import view, edit, compare, run_editor_on_exception
41+
from larray.viewer import view, edit, debug, compare, run_editor_on_exception
4242

4343
from larray.extra.ipfp import ipfp
4444

@@ -81,7 +81,7 @@
8181
# utils
8282
'get_options', 'set_options',
8383
# viewer
84-
'view', 'edit', 'compare', 'run_editor_on_exception',
84+
'view', 'edit', 'debug', 'compare', 'run_editor_on_exception',
8585
# ipfp
8686
'ipfp',
8787
# example

larray/viewer/__init__.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,23 @@ def edit(obj=None, title='', minvalue=None, maxvalue=None, readonly=False, depth
7575
raise Exception('edit() is not available because the larray_editor package is not installed')
7676

7777

78+
def debug(depth=0):
79+
r"""
80+
Opens a new debug window.
81+
82+
Parameters
83+
----------
84+
depth : int, optional
85+
Stack depth where to look for variables. Defaults to 0 (where this function was called).
86+
"""
87+
try:
88+
from larray_editor import debug
89+
90+
debug(depth + 1)
91+
except ImportError:
92+
raise Exception('debug() is not available because the larray_editor package is not installed')
93+
94+
7895
def compare(*args, **kwargs):
7996
r"""
8097
Opens a new comparator window, comparing arrays or sessions.
@@ -125,7 +142,7 @@ def compare(*args, **kwargs):
125142
raise Exception('compare() is not available because the larray_editor package is not installed')
126143

127144

128-
def run_editor_on_exception(root_path=None, usercode_traceback=True):
145+
def run_editor_on_exception(root_path=None, usercode_traceback=True, usercode_frame=True):
129146
r"""
130147
Runs the editor when an unhandled exception (a fatal error) happens.
131148
@@ -136,6 +153,9 @@ def run_editor_on_exception(root_path=None, usercode_traceback=True):
136153
usercode_traceback : bool, optional
137154
Whether or not to show only the part of the traceback (error log) which corresponds to the user code.
138155
Otherwise, it will show the complete traceback, including code inside libraries. Defaults to True.
156+
usercode_frame : bool, optional
157+
Whether or not to start the debug window in the frame corresponding to the user code.
158+
This argument is ignored (it is always True) if usercode_traceback is True. Defaults to True.
139159
140160
Notes
141161
-----
@@ -144,6 +164,7 @@ def run_editor_on_exception(root_path=None, usercode_traceback=True):
144164
try:
145165
from larray_editor import run_editor_on_exception
146166

147-
run_editor_on_exception(root_path=root_path, usercode_traceback=usercode_traceback)
167+
run_editor_on_exception(root_path=root_path, usercode_traceback=usercode_traceback,
168+
usercode_frame=usercode_frame)
148169
except ImportError:
149170
raise Exception('run_editor_on_exception() is not available because the larray_editor package is not installed')

0 commit comments

Comments
 (0)