@@ -227,35 +227,48 @@ Miscellaneous improvements
227
227
* added :py:obj:`set_options` allowing to set options for larray within a ``with`` block or globally:
228
228
229
229
>>> from larray import *
230
- >>> arr = ndtest((500 , 100 ), dtype=float) / 3
230
+ >>> arr = ndtest((500 , 100 ), dtype=float) + 0.123456
231
231
232
232
You can use ``set_options`` either as a context manager:
233
233
234
+ >>> # display_width defines the maximum display width when printing an array
235
+ >>> # display_edgeitems defines the number of lines of the header and tail to display
234
236
>>> with set_options (display_width=100 , display_edgeitems=2 ):
235
237
... print(arr)
236
- a\b b0 b1 ... b98 b99
237
- a0 0.0 0.3333333333333333 ... 32.666666666666664 33.0
238
- a1 33.333333333333336 33.666666666666664 ... 66.0 66.33333333333333
239
- ... ... ... ... ... ...
240
- a498 16600.0 16600.333333333332 ... 16632.666666666668 16633.0
241
- a499 16633.333333333332 16633.666666666668 ... 16666.0 16666.333333333332
238
+ a\b b0 b1 b2 ... b97 b98 b99
239
+ a0 0.123456 1.123456 2.123456 ... 97.123456 98.123456 99.123456
240
+ a1 100.123456 101.123456 102.123456 ... 197.123456 198.123456 199.123456
241
+ ... ... ... ... ... ... ... ...
242
+ a498 49800.123456 49801.123456 49802.123456 ... 49897.123456 49898.123456 49899.123456
243
+ a499 49900.123456 49901.123456 49902.123456 ... 49997.123456 49998.123456 49999.123456
242
244
243
245
Or to set global options:
244
246
245
- >>> set_options(display_maxlines=10 , display_precision=2 ) # doctest: +SKIP
246
- >>> print (arr) # doctest: +SKIP
247
+ >>> # display_maxlines defines the maximum number of lines to show
248
+ >>> # display_precision defines the number of digits of precision for floating point output
249
+ >>> set_options (display_maxlines=10 , display_precision=2 )
250
+ >>> print(arr)
247
251
a\b b0 b1 b2 ... b97 b98 b99
248
- a0 0.00 0.33 0.67 ... 32.33 32.67 33.00
249
- a1 33.33 33.67 34.00 ... 65.67 66.00 66.33
250
- a2 66.67 67.00 67.33 ... 99.00 99.33 99.67
251
- a3 100.00 100.33 100.67 ... 132.33 132.67 133.00
252
- a4 133.33 133.67 134.00 ... 165.67 166.00 166.33
252
+ a0 0.12 1.12 2.12 ... 97.12 98.12 99.12
253
+ a1 100.12 101.12 102.12 ... 197.12 198.12 199.12
254
+ a2 200.12 201.12 202.12 ... 297.12 298.12 299.12
255
+ a3 300.12 301.12 302.12 ... 397.12 398.12 399.12
256
+ a4 400.12 401.12 402.12 ... 497.12 498.12 499.12
253
257
... ... ... ... ... ... ... ...
254
- a495 16500.00 16500.33 16500.67 ... 16532.33 16532.67 16533.00
255
- a496 16533.33 16533.67 16534.00 ... 16565.67 16566.00 16566.33
256
- a497 16566.67 16567.00 16567.33 ... 16599.00 16599.33 16599.67
257
- a498 16600.00 16600.33 16600.67 ... 16632.33 16632.67 16633.00
258
- a499 16633.33 16633.67 16634.00 ... 16665.67 16666.00 16666.33
258
+ a495 49500.12 49501.12 49502.12 ... 49597.12 49598.12 49599.12
259
+ a496 49600.12 49601.12 49602.12 ... 49697.12 49698.12 49699.12
260
+ a497 49700.12 49701.12 49702.12 ... 49797.12 49798.12 49799.12
261
+ a498 49800.12 49801.12 49802.12 ... 49897.12 49898.12 49899.12
262
+ a499 49900.12 49901.12 49902.12 ... 49997.12 49998.12 49999.12
263
+
264
+ To put back the default options, you can use:
265
+
266
+ >>> set_options(display_precision=None, display_width=80 , display_maxlines=200 , display_edgeitems=5 )
267
+
268
+ The :py:obj:`get_options` function returns a view of the current options as a dictionary:
269
+
270
+ >>> get_options()
271
+ {' display_precision' : None, ' display_width' : 80 , ' display_maxlines' : 200 , ' display_edgeitems' : 5 }
259
272
260
273
Closes :issue:`274 `.
261
274
0 commit comments