Skip to content

Commit a3a1f6e

Browse files
committed
fixed str(la) where la.shape[0] == 0
1 parent 09673d7 commit a3a1f6e

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

larray/core.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,8 @@ def __setslice__(self, i, j, value):
10821082
def __str__(self):
10831083
if not self.ndim:
10841084
return str(np.asscalar(self))
1085+
elif not len(self):
1086+
return 'LArray([])'
10851087
else:
10861088
s = table2str(list(self.as_table()), 'nan', True,
10871089
keepcols=self.ndim - 1)

larray/tests/test_la.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,9 @@ def test_str(self):
535535
# zero dimension / scalar
536536
self.assertEqual(str(self.small[lipro['P01'], sex['F']]), "15")
537537

538+
# empty / len 0 first dimension
539+
self.assertEqual(str(self.small[sex[[]]]), "LArray([])")
540+
538541
# one dimension
539542
self.assertEqual(str(self.small[lipro3, sex['H']]), """
540543
lipro | P01 | P02 | P03

0 commit comments

Comments
 (0)