Skip to content

Commit 684064f

Browse files
committed
set option DISPLAY_MAXLINES to 200 by default
1 parent 847cebc commit 684064f

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

larray/core/array.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2278,8 +2278,7 @@ def __str__(self):
22782278
elif not len(self):
22792279
return 'LArray([])'
22802280
else:
2281-
maxlines = OPTIONS[DISPLAY_MAXLINES] if OPTIONS[DISPLAY_MAXLINES] is not None else 200
2282-
table = list(self.as_table(maxlines))
2281+
table = list(self.as_table())
22832282
return table2str(table, 'nan', keepcols=self.ndim - 1)
22842283
__repr__ = __str__
22852284

@@ -2296,7 +2295,7 @@ def as_table(self, maxlines=None, edgeitems=None, light=False, wide=True, value_
22962295
Parameters
22972296
----------
22982297
maxlines : int, optional
2299-
Maximum number of lines to show. Default behavior shows all lines.
2298+
Maximum number of lines to show. If 0 all lines are shown.
23002299
edgeitems : int, optional
23012300
If number of lines to display is greater than `maxlines`,
23022301
only the first and last `edgeitems` lines are displayed.
@@ -2389,7 +2388,7 @@ def as_table(self, maxlines=None, edgeitems=None, light=False, wide=True, value_
23892388
other_colnames = self.axes[-1].labels.tolist() if wide else [value_name]
23902389
yield axes_names + other_colnames
23912390
# summary if needed
2392-
if maxlines is not None and height > maxlines:
2391+
if maxlines > 0 and height > maxlines:
23932392
# replace middle lines of the table by '...'.
23942393
# We show only the first and last edgeitems lines.
23952394
startticks = islice(ticks, edgeitems)
@@ -2431,7 +2430,7 @@ def dump(self, header=True, wide=True, value_name='value'):
24312430
# flatten all dimensions except the last one
24322431
return self.data.reshape(-1, self.shape[-1]).tolist()
24332432
else:
2434-
return list(self.as_table(wide=wide, value_name=value_name))
2433+
return list(self.as_table(maxlines=0, wide=wide, value_name=value_name))
24352434

24362435
# XXX: should filter(geo=['W']) return a view by default? (collapse=True)
24372436
# I think it would be dangerous to make it the default

larray/util/options.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
OPTIONS = {
1616
DISPLAY_PRECISION: None,
1717
DISPLAY_WIDTH: 80,
18-
DISPLAY_MAXLINES: None,
18+
DISPLAY_MAXLINES: 200,
1919
DISPLAY_EDGEITEMS: 5,
2020
}
2121

@@ -25,6 +25,11 @@ def _positive_integer(value):
2525
raise ValueError("Expected positive integer")
2626

2727

28+
def _non_negative_integer(value):
29+
if not (isinstance(value, int) and value >= 0):
30+
raise ValueError("Expected non-negative integer")
31+
32+
2833
def _positive_integer_or_none(value):
2934
if value is None:
3035
return
@@ -35,7 +40,7 @@ def _positive_integer_or_none(value):
3540
_VALIDATORS = {
3641
DISPLAY_PRECISION: _positive_integer_or_none,
3742
DISPLAY_WIDTH: _positive_integer,
38-
DISPLAY_MAXLINES: _positive_integer_or_none,
43+
DISPLAY_MAXLINES: _non_negative_integer,
3944
DISPLAY_EDGEITEMS: _positive_integer,
4045
}
4146

@@ -48,7 +53,8 @@ class set_options(object):
4853
4954
- ``display_precision``: number of digits of precision for floating point output.
5055
- ``display_width``: maximum display width for ``repr`` on larray objects. Defaults to 80.
51-
- ``display_maxlines``: Maximum number of lines to show. Default behavior shows all lines.
56+
- ``display_maxlines``: Maximum number of lines to show. If 0 all lines are shown.
57+
Defaults to 200.
5258
- ``display_edgeitems`` : if number of lines to display is greater than ``display_maxlines``,
5359
only the first and last ``display_edgeitems`` lines are displayed.
5460
Only active if ``display_maxlines`` is not None. Defaults to 5.

0 commit comments

Comments
 (0)