larray-project / larray-editor

Graphical User Interface for LArray
GNU General Public License v3.0
2 stars 2 forks source link

"IndexError: List index out of range" when copying value from filtered (single-value) array #270

Closed yvdabb closed 3 months ago

yvdabb commented 3 months ago

Example:

import larray as la

age = la.Axis(['young', 'old'], 'age')
time = la.Axis('time=2021..2023')
gender = la.Axis(['female', 'male'], 'gender')
data = [
    [[1, 2, 3],
     [4, 5, 6]],
    [[7, 8, 9],
     [10, 11, 12]]
]

population = la.Array(data, axes=[age, gender, time])

la.view()

When filtering this array down to a "single-value array," the copy functionality stops working.

image

The following error is produced:

IndexError: list index out of range
Traceback (most recent call last):
  File "C:\soft\Miniconda3\lib\site-packages\larray_editor\arraywidget.py", line 1069, in copy
    raw_data, axes_names, vlabels, hlabels = self._selection_data()
  File "C:\soft\Miniconda3\lib\site-packages\larray_editor\arraywidget.py", line 1061, in _selection_data
    hlabels = [label[0] for label in self.model_hlabels.get_values(top=col_min, bottom=col_max)]
  File "C:\soft\Miniconda3\lib\site-packages\larray_editor\arraywidget.py", line 1061, in <listcomp>
    hlabels = [label[0] for label in self.model_hlabels.get_values(top=col_min, bottom=col_max)]
gdementen commented 3 months ago

FWIW, for creating test cases, I usually prefer using ndtest, as that is more condensed. The above array can be created with just:

population = la.ndtest('age=young,old;gender=female,male;time=2021..2023', start=1)