Skip to content

issue 10: view several sessions same time #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
17 changes: 10 additions & 7 deletions larray_editor/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,15 @@ def get_title(obj, depth=0, maxnames=3):
return ', '.join(names)


# TODO: update doccstring
def edit(obj=None, title='', minvalue=None, maxvalue=None, readonly=False, depth=0):
"""
Opens a new editor window.

Parameters
----------
obj : np.ndarray, LArray, Session, dict, str or REOPEN_LAST_FILE, optional
Object to visualize. If string, array(s) will be loaded from the file given as argument.
obj : (dict of) np.ndarray, LArray, Session, dict, str or REOPEN_LAST_FILE, optional
Object(s) to visualize. If string, array(s) will be loaded from the file given as argument.
Passing the constant REOPEN_LAST_FILE loads the last opened file.
Defaults to the collection of all local variables where the function was called.
title : str, optional
Expand Down Expand Up @@ -117,13 +118,13 @@ def edit(obj=None, title='', minvalue=None, maxvalue=None, readonly=False, depth
obj.update([(k, global_vars[k]) for k in sorted(global_vars.keys())])
obj.update([(k, local_vars[k]) for k in sorted(local_vars.keys())])

if not isinstance(obj, la.Session) and hasattr(obj, 'keys'):
obj = la.Session(obj)
if hasattr(obj, 'keys'):
obj = OrderedDict(obj)

if not title and obj is not REOPEN_LAST_FILE:
title = get_title(obj, depth=depth + 1)

if obj is REOPEN_LAST_FILE or isinstance(obj, (str, la.Session)):
if obj is REOPEN_LAST_FILE or isinstance(obj, (str, OrderedDict)):
dlg = MappingEditor(parent)
assert minvalue is None and maxvalue is None
setup_ok = dlg.setup_and_check(obj, title=title, readonly=readonly)
Expand All @@ -138,14 +139,16 @@ def edit(obj=None, title='', minvalue=None, maxvalue=None, readonly=False, depth
restore_except_hook()


# TODO: update doccstring
def view(obj=None, title='', depth=0):
"""
Opens a new viewer window. Arrays are loaded in readonly mode and their content cannot be modified.

Parameters
----------
obj : np.ndarray, LArray, Session, dict or str, optional
Object to visualize. If string, array(s) will be loaded from the file given as argument.
obj : (dict of) np.ndarray, LArray, Session, dict, str or REOPEN_LAST_FILE, optional
Object(s) to visualize. If string, array(s) will be loaded from the file given as argument.
Passing the constant REOPEN_LAST_FILE loads the last opened file.
Defaults to the collection of all local variables where the function was called.
title : str, optional
Title for the current object. Defaults to the name of the first object found in the caller namespace which
Expand Down
Loading