65
65
from larray .util .misc import (table2str , size2str , basestring , izip , rproduct , ReprString , duplicates ,
66
66
float_error_handler_factory , _isnoneslice , light_product , unique_list , common_type ,
67
67
renamed_to , deprecate_kwarg , LHDFStore , lazy_attribute )
68
- from larray .util .options import OPTIONS , DISPLAY_MAXLINES , DISPLAY_EDGEITEMS
68
+ from larray .util .options import OPTIONS , DISPLAY_MAXLINES , DISPLAY_EDGEITEMS , DISPLAY_WIDTH , DISPLAY_PRECISION
69
69
70
70
71
71
def all (values , axis = None ):
@@ -2278,8 +2278,9 @@ def __str__(self):
2278
2278
elif not len (self ):
2279
2279
return 'LArray([])'
2280
2280
else :
2281
- table = list (self .as_table ())
2282
- return table2str (table , 'nan' , keepcols = self .ndim - 1 )
2281
+ table = list (self .as_table (OPTIONS [DISPLAY_MAXLINES ], OPTIONS [DISPLAY_EDGEITEMS ]))
2282
+ return table2str (table , 'nan' , maxwidth = OPTIONS [DISPLAY_WIDTH ], keepcols = self .ndim - 1 ,
2283
+ precision = OPTIONS [DISPLAY_PRECISION ])
2283
2284
__repr__ = __str__
2284
2285
2285
2286
def __iter__ (self ):
@@ -2288,20 +2289,20 @@ def __iter__(self):
2288
2289
def __contains__ (self , key ):
2289
2290
return any (key in axis for axis in self .axes )
2290
2291
2291
- def as_table (self , maxlines = None , edgeitems = None , light = False , wide = True , value_name = 'value' ):
2292
+ def as_table (self , maxlines = - 1 , edgeitems = 5 , light = False , wide = True , value_name = 'value' ):
2292
2293
r"""
2293
2294
Generator. Returns next line of the table representing an array.
2294
2295
2295
2296
Parameters
2296
2297
----------
2297
2298
maxlines : int, optional
2298
- Maximum number of lines to show. If 0 all lines are shown.
2299
- See :py:obj:`set_options` for default value .
2299
+ Maximum number of lines to show. If negative all lines are shown.
2300
+ Defaults to -1 .
2300
2301
edgeitems : int, optional
2301
2302
If number of lines to display is greater than `maxlines`,
2302
2303
only the first and last `edgeitems` lines are displayed.
2303
2304
Only active if `maxlines` is not 0.
2304
- See :py:obj:`set_options` for default value .
2305
+ Defaults to 5 .
2305
2306
light: bool, optional
2306
2307
Whether or not printing the array in the same way as a pandas DataFrame with a MultiIndex
2307
2308
(see example below). Defaults to False.
@@ -2351,12 +2352,6 @@ def as_table(self, maxlines=None, edgeitems=None, light=False, wide=True, value_
2351
2352
if not self .ndim :
2352
2353
return
2353
2354
2354
- # get default options
2355
- if maxlines is None :
2356
- maxlines = OPTIONS [DISPLAY_MAXLINES ]
2357
- if edgeitems is None :
2358
- edgeitems = OPTIONS [DISPLAY_EDGEITEMS ]
2359
-
2360
2355
# ert unit geo\time 2012 2011 2010
2361
2356
# NEER27 I05 AT 101.41 101.63 101.63
2362
2357
# NEER27 I05 AU 134.86 125.29 117.08
@@ -2432,7 +2427,7 @@ def dump(self, header=True, wide=True, value_name='value'):
2432
2427
# flatten all dimensions except the last one
2433
2428
return self .data .reshape (- 1 , self .shape [- 1 ]).tolist ()
2434
2429
else :
2435
- return list (self .as_table (maxlines = 0 , wide = wide , value_name = value_name ))
2430
+ return list (self .as_table (maxlines = - 1 , wide = wide , value_name = value_name ))
2436
2431
2437
2432
# XXX: should filter(geo=['W']) return a view by default? (collapse=True)
2438
2433
# I think it would be dangerous to make it the default
0 commit comments