Skip to content

Commit 17e6423

Browse files
committed
FIX: Array.values(axes=0) (closes #1093)
1 parent 4c0bab3 commit 17e6423

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

doc/source/changes/version_0_34_3.rst.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,6 @@ Fixes
6262

6363
* fixed copying a sheet from one Excel workbook to another when the destination
6464
sheet is given by position (closes :issue:`1092`).
65+
66+
* fixed :py:obj:`Array.values()` and :py:obj:`Array.items()` on the first axis given by position.
67+
(e.g. `my_array.values(axes=0)`). Closes :issue:`1093`.

larray/core/array.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3434,13 +3434,14 @@ def values(self, axes=None, ascending=True) -> Union[np.ndarray, List['Array'],
34343434
combined = np.ravel(self.data)
34353435
# combined[::-1] *is* indexable
34363436
return combined if ascending else combined[::-1]
3437-
elif not axes:
3438-
# empty axes list
3439-
return [self]
34403437

34413438
if not isinstance(axes, (tuple, list, AxisCollection)):
34423439
axes = (axes,)
34433440

3441+
if len(axes) == 0:
3442+
# empty axes list
3443+
return [self]
3444+
34443445
axes = self.axes[axes]
34453446
# move axes in front
34463447
transposed = self.transpose(axes)

larray/tests/test_array.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,11 @@ def test_values():
336336
res = list(values)
337337
assert_larray_equal(res[0], arr)
338338

339+
# issue 1093
340+
values = arr.values(0)
341+
res = list(values)
342+
assert_larray_equal(res[0], arr['a0'])
343+
339344

340345
def test_items():
341346
arr = ndtest((2, 2))
@@ -399,6 +404,14 @@ def test_items():
399404
assert key == (b.i[0],)
400405
assert_larray_equal(value, arr['b0'])
401406

407+
# issue 1093
408+
items = arr.items(0)
409+
items_list = list(items)
410+
key, value = items_list[0]
411+
assert key == (a.i[0],)
412+
assert_larray_equal(value, arr['a0'])
413+
414+
402415

403416
def test_rename(array):
404417
new_array = array.rename('c', 'c2')

0 commit comments

Comments
 (0)