3
3
from larray .util .misc import basestring
4
4
5
5
6
- __all__ = ['set_printoptions ' ]
6
+ __all__ = ['set_options ' ]
7
7
8
8
9
- DISPLAY_PRECISION = 'precision '
9
+ DISPLAY_PRECISION = 'display_precision '
10
10
DISPLAY_WIDTH = 'display_width'
11
- MAXLINES = 'maxlines '
12
- EDGEITEMS = 'edgeitems '
11
+ DISPLAY_MAXLINES = 'display_maxlines '
12
+ DISPLAY_EDGEITEMS = 'display_edgeitems '
13
13
14
14
15
15
OPTIONS = {
16
16
DISPLAY_PRECISION : None ,
17
17
DISPLAY_WIDTH : 80 ,
18
- MAXLINES : None ,
19
- EDGEITEMS : 5 ,
18
+ DISPLAY_MAXLINES : None ,
19
+ DISPLAY_EDGEITEMS : 5 ,
20
20
}
21
21
22
22
@@ -35,22 +35,23 @@ def _positive_integer_or_none(value):
35
35
_VALIDATORS = {
36
36
DISPLAY_PRECISION : _positive_integer_or_none ,
37
37
DISPLAY_WIDTH : _positive_integer ,
38
- MAXLINES : _positive_integer_or_none ,
39
- EDGEITEMS : _positive_integer ,
38
+ DISPLAY_MAXLINES : _positive_integer_or_none ,
39
+ DISPLAY_EDGEITEMS : _positive_integer ,
40
40
}
41
41
42
42
43
43
# idea taken from xarray. See xarray/core/options.py module for original implementation.
44
- class set_printoptions (object ):
45
- r"""Set options for printing arrays in a controlled context.
44
+ class set_options (object ):
45
+ r"""Set options for larray in a controlled context.
46
46
47
47
Currently supported options:
48
48
49
- - ``precision ``: number of digits of precision for floating point output.
49
+ - ``display_precision ``: number of digits of precision for floating point output.
50
50
- ``display_width``: maximum display width for ``repr`` on larray objects. Defaults to 80.
51
- - ``maxlines``: Maximum number of lines to show. Default behavior shows all lines.
52
- - ``edgeitems`` : if number of lines to display is greater than ``maxlines``, only the first and last
53
- ``edgeitems`` lines are displayed. Only active if ``maxlines`` is not None. Defaults to 5.
51
+ - ``display_maxlines``: Maximum number of lines to show. Default behavior shows all lines.
52
+ - ``display_edgeitems`` : if number of lines to display is greater than ``display_maxlines``,
53
+ only the first and last ``display_edgeitems`` lines are displayed.
54
+ Only active if ``display_maxlines`` is not None. Defaults to 5.
54
55
55
56
Examples
56
57
--------
@@ -59,31 +60,31 @@ class set_printoptions(object):
59
60
60
61
You can use ``set_options`` either as a context manager:
61
62
62
- >>> with set_printoptions (display_width=60, edgeitems=2, precision =2):
63
+ >>> with set_options (display_width=100, display_edgeitems =2):
63
64
... print(arr)
64
- a\b b0 b1 ... b98 b99
65
- a0 0.00 0.33 ... 32.67 33.00
66
- a1 33.33 33.67 ... 66.00 66.33
67
- ... ... ... ... ... ...
68
- a498 16600.00 16600.33 ... 16632.67 16633.00
69
- a499 16633.33 16633.67 ... 16666.00 16666.33
65
+ a\b b0 b1 ... b98 b99
66
+ a0 0.0 0.3333333333333333 ... 32.666666666666664 33.0
67
+ a1 33.333333333333336 33.666666666666664 ... 66.0 66.33333333333333
68
+ ... ... ... ... ... ...
69
+ a498 16600.0 16600.333333333332 ... 16632.666666666668 16633.0
70
+ a499 16633.333333333332 16633.666666666668 ... 16666.0 16666.333333333332
70
71
71
72
Or to set global options:
72
73
73
- >>> set_printoptions(display_width=40, maxlines= 10, precision =2) # doctest: +SKIP
74
+ >>> set_options(display_maxlines= 10, display_precision =2) # doctest: +SKIP
74
75
>>> print(arr) # doctest: +SKIP
75
- a\b b0 ... b99
76
- a0 0.00 ... 33.00
77
- a1 33.33 ... 66.33
78
- a2 66.67 ... 99.67
79
- a3 100.00 ... 133.00
80
- a4 133.33 ... 166.33
81
- ... ... ... ...
82
- a495 16500.00 ... 16533.00
83
- a496 16533.33 ... 16566.33
84
- a497 16566.67 ... 16599.67
85
- a498 16600.00 ... 16633.00
86
- a499 16633.33 ... 16666.33
76
+ a\b b0 b1 b2 ... b97 b98 b99
77
+ a0 0.00 0.33 0.67 ... 32.33 32.67 33.00
78
+ a1 33.33 33.67 34.00 ... 65.67 66.00 66.33
79
+ a2 66.67 67.00 67.33 ... 99.00 99.33 99.67
80
+ a3 100.00 100.33 100.67 ... 132.33 132.67 133.00
81
+ a4 133.33 133.67 134.00 ... 165.67 166.00 166.33
82
+ ... ... ... ... ... ... ... ...
83
+ a495 16500.00 16500.33 16500.67 ... 16532.33 16532.67 16533.00
84
+ a496 16533.33 16533.67 16534.00 ... 16565.67 16566.00 16566.33
85
+ a497 16566.67 16567.00 16567.33 ... 16599.00 16599.33 16599.67
86
+ a498 16600.00 16600.33 16600.67 ... 16632.33 16632.67 16633.00
87
+ a499 16633.33 16633.67 16634.00 ... 16665.67 16666.00 16666.33
87
88
"""
88
89
89
90
def __init__ (self , ** kwargs ):
0 commit comments