Skip to content

Commit b59f6ed

Browse files
committed
fix #179 : fixed error when loading a session with non array objects from a file
1 parent e585f54 commit b59f6ed

File tree

2 files changed

+13
-38
lines changed

2 files changed

+13
-38
lines changed
Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,21 @@
11
.. py:currentmodule:: larray_editor
22

3-
Syntax changes
4-
^^^^^^^^^^^^^^
5-
6-
* renamed ``MappingEditor.old_method_name()`` to :py:obj:`MappingEditor.new_method_name()` (closes :editor_issue:`1`).
7-
8-
* renamed ``old_argument_name`` argument of :py:obj:`MappingEditor.method_name()` to ``new_argument_name``.
9-
10-
11-
Backward incompatible changes
12-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13-
14-
* other backward incompatible changes
15-
16-
173
New features
184
^^^^^^^^^^^^
195

20-
* added a feature (see the :ref:`miscellaneous section <misc_editor>` for details).
21-
22-
* added another feature in the editor (closes :editor_issue:`1`).
23-
24-
.. note::
25-
26-
- It works for foo bar !
27-
- It does not work for foo baz !
6+
*
287

298

309
.. _misc_editor:
3110

3211
Miscellaneous improvements
3312
^^^^^^^^^^^^^^^^^^^^^^^^^^
3413

35-
* improved something.
14+
*
3615

3716

3817
Fixes
3918
^^^^^
4019

41-
* fixed something (closes :editor_issue:`1`).
20+
* fixed exception raised when loading a session with non array objects
21+
from a file (closes :editor_issue:`179`).

larray_editor/editor.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,14 @@ def void_formatter(array, *args, **kwargs):
396396
self.new()
397397
# convert input data to Session if not
398398
else:
399-
self.data = data if isinstance(data, Session) else Session(data)
400-
if qtconsole_available:
401-
self.kernel.shell.push(dict(self.data.items()))
402-
arrays = [k for k, v in self.data.items() if self._display_in_grid(k, v)]
403-
self.add_list_items(arrays)
399+
self._push_data(data)
400+
401+
def _push_data(self, data):
402+
self.data = data if isinstance(data, Session) else Session(data)
403+
if qtconsole_available:
404+
self.kernel.shell.push(dict(self.data.items()))
405+
arrays = [k for k, v in self.data.items() if self._display_in_grid(k, v)]
406+
self.add_list_items(arrays)
404407
self._listwidget.setCurrentRow(0)
405408

406409
def _reset(self):
@@ -670,13 +673,6 @@ def set_current_file(self, filepath):
670673
self.current_file = filepath
671674
self.update_title()
672675

673-
def _add_arrays(self, arrays):
674-
for k, v in arrays.items():
675-
self.data[k] = v
676-
self.add_list_item(k)
677-
if qtconsole_available:
678-
self.kernel.shell.push(dict(arrays))
679-
680676
def _ask_to_save_if_unsaved_modifications(self):
681677
"""
682678
Returns
@@ -933,8 +929,7 @@ def _open_file(self, filepath):
933929
try:
934930
session.load(filepath, names)
935931
self._reset()
936-
self._add_arrays(session)
937-
self._listwidget.setCurrentRow(0)
932+
self._push_data(session)
938933
self.set_current_file(current_file_name)
939934
self.unsaved_modifications = False
940935
self.statusBar().showMessage("Loaded: {}".format(display_name), 4000)

0 commit comments

Comments
 (0)