Skip to content

Commit

Permalink
Merge from 3.x: PR #5662
Browse files Browse the repository at this point in the history
Fixes #5628
  • Loading branch information
ccordoba12 committed Nov 6, 2017
2 parents a4ee455 + 07230f0 commit 8db575c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 5 additions & 2 deletions spyder/widgets/variableexplorer/arrayeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,8 +760,11 @@ def change_active_widget(self, index):
stack_index = self.dim_indexes[self.last_dim].get(data_index)
if stack_index == None:
stack_index = self.stack.count()
self.stack.addWidget(ArrayEditorWidget(self,
self.data[slice_index]))
try:
self.stack.addWidget(ArrayEditorWidget(self,
self.data[slice_index]))
except IndexError: # Handle arrays of size 0 in one axis
self.stack.addWidget(ArrayEditorWidget(self, self.data))
self.dim_indexes[self.last_dim][data_index] = stack_index
self.stack.update()
self.stack.setCurrentIndex(stack_index)
Expand Down
7 changes: 7 additions & 0 deletions spyder/widgets/variableexplorer/tests/test_arrayeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ def test_arrayeditor_with_3d_array(qtbot):
assert_array_equal(arr, launch_arrayeditor(arr, "3D array"))


def test_arrayeditor_with_empty_3d_array(qtbot):
arr = np.zeros((0, 10, 2))
assert_array_equal(arr, launch_arrayeditor(arr, "3D array"))
arra = np.zeros((1, 10, 2))
assert_array_equal(arr, launch_arrayeditor(arr, "3D array"))


def test_arrayeditor_edit_1d_array(qtbot):
exp_arr = np.array([1, 0, 2, 3, 4])
arr = np.arange(0, 5)
Expand Down

0 comments on commit 8db575c

Please sign in to comment.