Skip to content

Commit 3851012

Browse files
committed
FIX: copying an array filtered on all dimensions (closes #270)
there are similar bugs remaining but since these are edge cases and this code will change heavily with the adapter refactor I am not inclined to fix them until then
1 parent 18feb4e commit 3851012

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

doc/source/changes/version_0_34_3.rst.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ Fixes
66
* changes made to arrays in the console using the "points" syntax (for example: `arr.points['a0,a1', 'b0,b1'] = 0`)
77
and the other special `.something[]` syntaxes were not detected by the viewer and thus not displayed (closes
88
:editor_issue:`269`).
9+
10+
* fixed copying to clipboard an array filtered on all dimensions (to a single value). Closes :editor_issue:`270`.

larray_editor/arrayadapter.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,10 @@ def selection_to_chain(self, raw_data, axes_names, vlabels, hlabels):
340340
-------
341341
itertools.chain
342342
"""
343+
# FIXME: this function does not support None axes_names, vlabels and hlabels
344+
# which _selection_data() produces in some cases (notably when working
345+
# on a scalar array). Unsure if we should fix _selection_data or this
346+
# method though.
343347
from itertools import chain
344348
topheaders = [axes_names + hlabels]
345349
if self.ndim == 1:

larray_editor/arraywidget.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1055,10 +1055,18 @@ def _selection_data(self, headers=True, none_selects_all=True):
10551055
row_min, row_max, col_min, col_max = bounds
10561056
raw_data = self.model_data.get_values(row_min, col_min, row_max, col_max)
10571057
if headers:
1058+
# FIXME: using data_adapter.ndim here and in the vlabels line below is
1059+
# inherently buggy, because this does not take filter into account,
1060+
# which should be the case for selection-related stuff which work
1061+
# on visible data
10581062
if not self.data_adapter.ndim:
10591063
return raw_data, None, None, None
10601064
axes_names = self.model_axes.get_values()
1061-
hlabels = [label[0] for label in self.model_hlabels.get_values(top=col_min, bottom=col_max)]
1065+
if len(axes_names):
1066+
hlabels = [label[0]
1067+
for label in self.model_hlabels.get_values(top=col_min, bottom=col_max)]
1068+
else:
1069+
hlabels = []
10621070
vlabels = self.model_vlabels.get_values(left=row_min, right=row_max) if self.data_adapter.ndim > 1 else []
10631071
return raw_data, axes_names, vlabels, hlabels
10641072
else:

0 commit comments

Comments
 (0)