Skip to content

Commit

Permalink
FIX: copying an array filtered on all dimensions (closes #270)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gdementen committed Jul 2, 2024
1 parent 18feb4e commit 3851012
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions doc/source/changes/version_0_34_3.rst.inc
Original file line number Diff line number Diff line change
@@ -6,3 +6,5 @@ Fixes
* changes made to arrays in the console using the "points" syntax (for example: `arr.points['a0,a1', 'b0,b1'] = 0`)
and the other special `.something[]` syntaxes were not detected by the viewer and thus not displayed (closes
:editor_issue:`269`).

* fixed copying to clipboard an array filtered on all dimensions (to a single value). Closes :editor_issue:`270`.
4 changes: 4 additions & 0 deletions larray_editor/arrayadapter.py
Original file line number Diff line number Diff line change
@@ -340,6 +340,10 @@ def selection_to_chain(self, raw_data, axes_names, vlabels, hlabels):
-------
itertools.chain
"""
# FIXME: this function does not support None axes_names, vlabels and hlabels
# which _selection_data() produces in some cases (notably when working
# on a scalar array). Unsure if we should fix _selection_data or this
# method though.
from itertools import chain
topheaders = [axes_names + hlabels]
if self.ndim == 1:
10 changes: 9 additions & 1 deletion larray_editor/arraywidget.py
Original file line number Diff line number Diff line change
@@ -1055,10 +1055,18 @@ def _selection_data(self, headers=True, none_selects_all=True):
row_min, row_max, col_min, col_max = bounds
raw_data = self.model_data.get_values(row_min, col_min, row_max, col_max)
if headers:
# FIXME: using data_adapter.ndim here and in the vlabels line below is
# inherently buggy, because this does not take filter into account,
# which should be the case for selection-related stuff which work
# on visible data
if not self.data_adapter.ndim:
return raw_data, None, None, None
axes_names = self.model_axes.get_values()
hlabels = [label[0] for label in self.model_hlabels.get_values(top=col_min, bottom=col_max)]
if len(axes_names):
hlabels = [label[0]
for label in self.model_hlabels.get_values(top=col_min, bottom=col_max)]
else:
hlabels = []
vlabels = self.model_vlabels.get_values(left=row_min, right=row_max) if self.data_adapter.ndim > 1 else []
return raw_data, axes_names, vlabels, hlabels
else:

0 comments on commit 3851012

Please sign in to comment.