Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/pandas/core/config_init.py: 90%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

197 statements  

1""" 

2This module is imported from the pandas package __init__.py file 

3in order to ensure that the core.config options registered here will 

4be available as soon as the user loads the package. if register_option 

5is invoked inside specific modules, they will not be registered until that 

6module is imported, which may or may not be a problem. 

7 

8If you need to make sure options are available even before a certain 

9module is imported, register them here rather than in the module. 

10 

11""" 

12from __future__ import annotations 

13 

14import os 

15from typing import Callable 

16 

17import pandas._config.config as cf 

18from pandas._config.config import ( 

19 is_bool, 

20 is_callable, 

21 is_instance_factory, 

22 is_int, 

23 is_nonnegative_int, 

24 is_one_of_factory, 

25 is_str, 

26 is_text, 

27) 

28 

29# compute 

30 

31use_bottleneck_doc = """ 

32: bool 

33 Use the bottleneck library to accelerate if it is installed, 

34 the default is True 

35 Valid values: False,True 

36""" 

37 

38 

39def use_bottleneck_cb(key) -> None: 

40 from pandas.core import nanops 

41 

42 nanops.set_use_bottleneck(cf.get_option(key)) 

43 

44 

45use_numexpr_doc = """ 

46: bool 

47 Use the numexpr library to accelerate computation if it is installed, 

48 the default is True 

49 Valid values: False,True 

50""" 

51 

52 

53def use_numexpr_cb(key) -> None: 

54 from pandas.core.computation import expressions 

55 

56 expressions.set_use_numexpr(cf.get_option(key)) 

57 

58 

59use_numba_doc = """ 

60: bool 

61 Use the numba engine option for select operations if it is installed, 

62 the default is False 

63 Valid values: False,True 

64""" 

65 

66 

67def use_numba_cb(key) -> None: 

68 from pandas.core.util import numba_ 

69 

70 numba_.set_use_numba(cf.get_option(key)) 

71 

72 

73with cf.config_prefix("compute"): 

74 cf.register_option( 

75 "use_bottleneck", 

76 True, 

77 use_bottleneck_doc, 

78 validator=is_bool, 

79 cb=use_bottleneck_cb, 

80 ) 

81 cf.register_option( 

82 "use_numexpr", True, use_numexpr_doc, validator=is_bool, cb=use_numexpr_cb 

83 ) 

84 cf.register_option( 

85 "use_numba", False, use_numba_doc, validator=is_bool, cb=use_numba_cb 

86 ) 

87# 

88# options from the "display" namespace 

89 

90pc_precision_doc = """ 

91: int 

92 Floating point output precision in terms of number of places after the 

93 decimal, for regular formatting as well as scientific notation. Similar 

94 to ``precision`` in :meth:`numpy.set_printoptions`. 

95""" 

96 

97pc_colspace_doc = """ 

98: int 

99 Default space for DataFrame columns. 

100""" 

101 

102pc_max_rows_doc = """ 

103: int 

104 If max_rows is exceeded, switch to truncate view. Depending on 

105 `large_repr`, objects are either centrally truncated or printed as 

106 a summary view. 'None' value means unlimited. 

107 

108 In case python/IPython is running in a terminal and `large_repr` 

109 equals 'truncate' this can be set to 0 and pandas will auto-detect 

110 the height of the terminal and print a truncated object which fits 

111 the screen height. The IPython notebook, IPython qtconsole, or 

112 IDLE do not run in a terminal and hence it is not possible to do 

113 correct auto-detection. 

114""" 

115 

116pc_min_rows_doc = """ 

117: int 

118 The numbers of rows to show in a truncated view (when `max_rows` is 

119 exceeded). Ignored when `max_rows` is set to None or 0. When set to 

120 None, follows the value of `max_rows`. 

121""" 

122 

123pc_max_cols_doc = """ 

124: int 

125 If max_cols is exceeded, switch to truncate view. Depending on 

126 `large_repr`, objects are either centrally truncated or printed as 

127 a summary view. 'None' value means unlimited. 

128 

129 In case python/IPython is running in a terminal and `large_repr` 

130 equals 'truncate' this can be set to 0 or None and pandas will auto-detect 

131 the width of the terminal and print a truncated object which fits 

132 the screen width. The IPython notebook, IPython qtconsole, or IDLE 

133 do not run in a terminal and hence it is not possible to do 

134 correct auto-detection and defaults to 20. 

135""" 

136 

137pc_max_categories_doc = """ 

138: int 

139 This sets the maximum number of categories pandas should output when 

140 printing out a `Categorical` or a Series of dtype "category". 

141""" 

142 

143pc_max_info_cols_doc = """ 

144: int 

145 max_info_columns is used in DataFrame.info method to decide if 

146 per column information will be printed. 

147""" 

148 

149pc_nb_repr_h_doc = """ 

150: boolean 

151 When True, IPython notebook will use html representation for 

152 pandas objects (if it is available). 

153""" 

154 

155pc_pprint_nest_depth = """ 

156: int 

157 Controls the number of nested levels to process when pretty-printing 

158""" 

159 

160pc_multi_sparse_doc = """ 

161: boolean 

162 "sparsify" MultiIndex display (don't display repeated 

163 elements in outer levels within groups) 

164""" 

165 

166float_format_doc = """ 

167: callable 

168 The callable should accept a floating point number and return 

169 a string with the desired format of the number. This is used 

170 in some places like SeriesFormatter. 

171 See formats.format.EngFormatter for an example. 

172""" 

173 

174max_colwidth_doc = """ 

175: int or None 

176 The maximum width in characters of a column in the repr of 

177 a pandas data structure. When the column overflows, a "..." 

178 placeholder is embedded in the output. A 'None' value means unlimited. 

179""" 

180 

181colheader_justify_doc = """ 

182: 'left'/'right' 

183 Controls the justification of column headers. used by DataFrameFormatter. 

184""" 

185 

186pc_expand_repr_doc = """ 

187: boolean 

188 Whether to print out the full DataFrame repr for wide DataFrames across 

189 multiple lines, `max_columns` is still respected, but the output will 

190 wrap-around across multiple "pages" if its width exceeds `display.width`. 

191""" 

192 

193pc_show_dimensions_doc = """ 

194: boolean or 'truncate' 

195 Whether to print out dimensions at the end of DataFrame repr. 

196 If 'truncate' is specified, only print out the dimensions if the 

197 frame is truncated (e.g. not display all rows and/or columns) 

198""" 

199 

200pc_east_asian_width_doc = """ 

201: boolean 

202 Whether to use the Unicode East Asian Width to calculate the display text 

203 width. 

204 Enabling this may affect to the performance (default: False) 

205""" 

206 

207pc_ambiguous_as_wide_doc = """ 

208: boolean 

209 Whether to handle Unicode characters belong to Ambiguous as Wide (width=2) 

210 (default: False) 

211""" 

212 

213pc_table_schema_doc = """ 

214: boolean 

215 Whether to publish a Table Schema representation for frontends 

216 that support it. 

217 (default: False) 

218""" 

219 

220pc_html_border_doc = """ 

221: int 

222 A ``border=value`` attribute is inserted in the ``<table>`` tag 

223 for the DataFrame HTML repr. 

224""" 

225 

226pc_html_use_mathjax_doc = """\ 

227: boolean 

228 When True, Jupyter notebook will process table contents using MathJax, 

229 rendering mathematical expressions enclosed by the dollar symbol. 

230 (default: True) 

231""" 

232 

233pc_max_dir_items = """\ 

234: int 

235 The number of items that will be added to `dir(...)`. 'None' value means 

236 unlimited. Because dir is cached, changing this option will not immediately 

237 affect already existing dataframes until a column is deleted or added. 

238 

239 This is for instance used to suggest columns from a dataframe to tab 

240 completion. 

241""" 

242 

243pc_width_doc = """ 

244: int 

245 Width of the display in characters. In case python/IPython is running in 

246 a terminal this can be set to None and pandas will correctly auto-detect 

247 the width. 

248 Note that the IPython notebook, IPython qtconsole, or IDLE do not run in a 

249 terminal and hence it is not possible to correctly detect the width. 

250""" 

251 

252pc_chop_threshold_doc = """ 

253: float or None 

254 if set to a float value, all float values smaller than the given threshold 

255 will be displayed as exactly 0 by repr and friends. 

256""" 

257 

258pc_max_seq_items = """ 

259: int or None 

260 When pretty-printing a long sequence, no more then `max_seq_items` 

261 will be printed. If items are omitted, they will be denoted by the 

262 addition of "..." to the resulting string. 

263 

264 If set to None, the number of items to be printed is unlimited. 

265""" 

266 

267pc_max_info_rows_doc = """ 

268: int or None 

269 df.info() will usually show null-counts for each column. 

270 For large frames this can be quite slow. max_info_rows and max_info_cols 

271 limit this null check only to frames with smaller dimensions than 

272 specified. 

273""" 

274 

275pc_large_repr_doc = """ 

276: 'truncate'/'info' 

277 For DataFrames exceeding max_rows/max_cols, the repr (and HTML repr) can 

278 show a truncated table (the default from 0.13), or switch to the view from 

279 df.info() (the behaviour in earlier versions of pandas). 

280""" 

281 

282pc_memory_usage_doc = """ 

283: bool, string or None 

284 This specifies if the memory usage of a DataFrame should be displayed when 

285 df.info() is called. Valid values True,False,'deep' 

286""" 

287 

288 

289def table_schema_cb(key) -> None: 

290 from pandas.io.formats.printing import enable_data_resource_formatter 

291 

292 enable_data_resource_formatter(cf.get_option(key)) 

293 

294 

295def is_terminal() -> bool: 

296 """ 

297 Detect if Python is running in a terminal. 

298 

299 Returns True if Python is running in a terminal or False if not. 

300 """ 

301 try: 

302 # error: Name 'get_ipython' is not defined 

303 ip = get_ipython() # type: ignore[name-defined] 

304 except NameError: # assume standard Python interpreter in a terminal 

305 return True 

306 else: 

307 if hasattr(ip, "kernel"): # IPython as a Jupyter kernel 

308 return False 

309 else: # IPython in a terminal 

310 return True 

311 

312 

313with cf.config_prefix("display"): 

314 cf.register_option("precision", 6, pc_precision_doc, validator=is_nonnegative_int) 

315 cf.register_option( 

316 "float_format", 

317 None, 

318 float_format_doc, 

319 validator=is_one_of_factory([None, is_callable]), 

320 ) 

321 cf.register_option( 

322 "max_info_rows", 

323 1690785, 

324 pc_max_info_rows_doc, 

325 validator=is_instance_factory((int, type(None))), 

326 ) 

327 cf.register_option("max_rows", 60, pc_max_rows_doc, validator=is_nonnegative_int) 

328 cf.register_option( 

329 "min_rows", 

330 10, 

331 pc_min_rows_doc, 

332 validator=is_instance_factory([type(None), int]), 

333 ) 

334 cf.register_option("max_categories", 8, pc_max_categories_doc, validator=is_int) 

335 

336 cf.register_option( 

337 "max_colwidth", 

338 50, 

339 max_colwidth_doc, 

340 validator=is_nonnegative_int, 

341 ) 

342 if is_terminal(): 

343 max_cols = 0 # automatically determine optimal number of columns 

344 else: 

345 max_cols = 20 # cannot determine optimal number of columns 

346 cf.register_option( 

347 "max_columns", max_cols, pc_max_cols_doc, validator=is_nonnegative_int 

348 ) 

349 cf.register_option( 

350 "large_repr", 

351 "truncate", 

352 pc_large_repr_doc, 

353 validator=is_one_of_factory(["truncate", "info"]), 

354 ) 

355 cf.register_option("max_info_columns", 100, pc_max_info_cols_doc, validator=is_int) 

356 cf.register_option( 

357 "colheader_justify", "right", colheader_justify_doc, validator=is_text 

358 ) 

359 cf.register_option("notebook_repr_html", True, pc_nb_repr_h_doc, validator=is_bool) 

360 cf.register_option("pprint_nest_depth", 3, pc_pprint_nest_depth, validator=is_int) 

361 cf.register_option("multi_sparse", True, pc_multi_sparse_doc, validator=is_bool) 

362 cf.register_option("expand_frame_repr", True, pc_expand_repr_doc) 

363 cf.register_option( 

364 "show_dimensions", 

365 "truncate", 

366 pc_show_dimensions_doc, 

367 validator=is_one_of_factory([True, False, "truncate"]), 

368 ) 

369 cf.register_option("chop_threshold", None, pc_chop_threshold_doc) 

370 cf.register_option("max_seq_items", 100, pc_max_seq_items) 

371 cf.register_option( 

372 "width", 80, pc_width_doc, validator=is_instance_factory([type(None), int]) 

373 ) 

374 cf.register_option( 

375 "memory_usage", 

376 True, 

377 pc_memory_usage_doc, 

378 validator=is_one_of_factory([None, True, False, "deep"]), 

379 ) 

380 cf.register_option( 

381 "unicode.east_asian_width", False, pc_east_asian_width_doc, validator=is_bool 

382 ) 

383 cf.register_option( 

384 "unicode.ambiguous_as_wide", False, pc_east_asian_width_doc, validator=is_bool 

385 ) 

386 cf.register_option( 

387 "html.table_schema", 

388 False, 

389 pc_table_schema_doc, 

390 validator=is_bool, 

391 cb=table_schema_cb, 

392 ) 

393 cf.register_option("html.border", 1, pc_html_border_doc, validator=is_int) 

394 cf.register_option( 

395 "html.use_mathjax", True, pc_html_use_mathjax_doc, validator=is_bool 

396 ) 

397 cf.register_option( 

398 "max_dir_items", 100, pc_max_dir_items, validator=is_nonnegative_int 

399 ) 

400 

401tc_sim_interactive_doc = """ 

402: boolean 

403 Whether to simulate interactive mode for purposes of testing 

404""" 

405 

406with cf.config_prefix("mode"): 

407 cf.register_option("sim_interactive", False, tc_sim_interactive_doc) 

408 

409use_inf_as_na_doc = """ 

410: boolean 

411 True means treat None, NaN, INF, -INF as NA (old way), 

412 False means None and NaN are null, but INF, -INF are not NA 

413 (new way). 

414""" 

415 

416# We don't want to start importing everything at the global context level 

417# or we'll hit circular deps. 

418 

419 

420def use_inf_as_na_cb(key) -> None: 

421 from pandas.core.dtypes.missing import _use_inf_as_na 

422 

423 _use_inf_as_na(key) 

424 

425 

426with cf.config_prefix("mode"): 

427 cf.register_option("use_inf_as_na", False, use_inf_as_na_doc, cb=use_inf_as_na_cb) 

428 

429 

430data_manager_doc = """ 

431: string 

432 Internal data manager type; can be "block" or "array". Defaults to "block", 

433 unless overridden by the 'PANDAS_DATA_MANAGER' environment variable (needs 

434 to be set before pandas is imported). 

435""" 

436 

437 

438with cf.config_prefix("mode"): 

439 cf.register_option( 

440 "data_manager", 

441 # Get the default from an environment variable, if set, otherwise defaults 

442 # to "block". This environment variable can be set for testing. 

443 os.environ.get("PANDAS_DATA_MANAGER", "block"), 

444 data_manager_doc, 

445 validator=is_one_of_factory(["block", "array"]), 

446 ) 

447 

448 

449# TODO better name? 

450copy_on_write_doc = """ 

451: bool 

452 Use new copy-view behaviour using Copy-on-Write. Defaults to False, 

453 unless overridden by the 'PANDAS_COPY_ON_WRITE' environment variable 

454 (if set to "1" for True, needs to be set before pandas is imported). 

455""" 

456 

457 

458with cf.config_prefix("mode"): 

459 cf.register_option( 

460 "copy_on_write", 

461 # Get the default from an environment variable, if set, otherwise defaults 

462 # to False. This environment variable can be set for testing. 

463 os.environ.get("PANDAS_COPY_ON_WRITE", "0") == "1", 

464 copy_on_write_doc, 

465 validator=is_bool, 

466 ) 

467 

468 

469# user warnings 

470chained_assignment = """ 

471: string 

472 Raise an exception, warn, or no action if trying to use chained assignment, 

473 The default is warn 

474""" 

475 

476with cf.config_prefix("mode"): 

477 cf.register_option( 

478 "chained_assignment", 

479 "warn", 

480 chained_assignment, 

481 validator=is_one_of_factory([None, "warn", "raise"]), 

482 ) 

483 

484 

485string_storage_doc = """ 

486: string 

487 The default storage for StringDtype. 

488""" 

489 

490with cf.config_prefix("mode"): 

491 cf.register_option( 

492 "string_storage", 

493 "python", 

494 string_storage_doc, 

495 validator=is_one_of_factory(["python", "pyarrow"]), 

496 ) 

497 

498 

499# Set up the io.excel specific reader configuration. 

500reader_engine_doc = """ 

501: string 

502 The default Excel reader engine for '{ext}' files. Available options: 

503 auto, {others}. 

504""" 

505 

506_xls_options = ["xlrd"] 

507_xlsm_options = ["xlrd", "openpyxl"] 

508_xlsx_options = ["xlrd", "openpyxl"] 

509_ods_options = ["odf"] 

510_xlsb_options = ["pyxlsb"] 

511 

512 

513with cf.config_prefix("io.excel.xls"): 

514 cf.register_option( 

515 "reader", 

516 "auto", 

517 reader_engine_doc.format(ext="xls", others=", ".join(_xls_options)), 

518 validator=is_one_of_factory(_xls_options + ["auto"]), 

519 ) 

520 

521with cf.config_prefix("io.excel.xlsm"): 

522 cf.register_option( 

523 "reader", 

524 "auto", 

525 reader_engine_doc.format(ext="xlsm", others=", ".join(_xlsm_options)), 

526 validator=is_one_of_factory(_xlsm_options + ["auto"]), 

527 ) 

528 

529 

530with cf.config_prefix("io.excel.xlsx"): 

531 cf.register_option( 

532 "reader", 

533 "auto", 

534 reader_engine_doc.format(ext="xlsx", others=", ".join(_xlsx_options)), 

535 validator=is_one_of_factory(_xlsx_options + ["auto"]), 

536 ) 

537 

538 

539with cf.config_prefix("io.excel.ods"): 

540 cf.register_option( 

541 "reader", 

542 "auto", 

543 reader_engine_doc.format(ext="ods", others=", ".join(_ods_options)), 

544 validator=is_one_of_factory(_ods_options + ["auto"]), 

545 ) 

546 

547with cf.config_prefix("io.excel.xlsb"): 

548 cf.register_option( 

549 "reader", 

550 "auto", 

551 reader_engine_doc.format(ext="xlsb", others=", ".join(_xlsb_options)), 

552 validator=is_one_of_factory(_xlsb_options + ["auto"]), 

553 ) 

554 

555# Set up the io.excel specific writer configuration. 

556writer_engine_doc = """ 

557: string 

558 The default Excel writer engine for '{ext}' files. Available options: 

559 auto, {others}. 

560""" 

561 

562_xlsm_options = ["openpyxl"] 

563_xlsx_options = ["openpyxl", "xlsxwriter"] 

564_ods_options = ["odf"] 

565 

566 

567with cf.config_prefix("io.excel.xlsm"): 

568 cf.register_option( 

569 "writer", 

570 "auto", 

571 writer_engine_doc.format(ext="xlsm", others=", ".join(_xlsm_options)), 

572 validator=str, 

573 ) 

574 

575 

576with cf.config_prefix("io.excel.xlsx"): 

577 cf.register_option( 

578 "writer", 

579 "auto", 

580 writer_engine_doc.format(ext="xlsx", others=", ".join(_xlsx_options)), 

581 validator=str, 

582 ) 

583 

584 

585with cf.config_prefix("io.excel.ods"): 

586 cf.register_option( 

587 "writer", 

588 "auto", 

589 writer_engine_doc.format(ext="ods", others=", ".join(_ods_options)), 

590 validator=str, 

591 ) 

592 

593 

594# Set up the io.parquet specific configuration. 

595parquet_engine_doc = """ 

596: string 

597 The default parquet reader/writer engine. Available options: 

598 'auto', 'pyarrow', 'fastparquet', the default is 'auto' 

599""" 

600 

601with cf.config_prefix("io.parquet"): 

602 cf.register_option( 

603 "engine", 

604 "auto", 

605 parquet_engine_doc, 

606 validator=is_one_of_factory(["auto", "pyarrow", "fastparquet"]), 

607 ) 

608 

609 

610# Set up the io.sql specific configuration. 

611sql_engine_doc = """ 

612: string 

613 The default sql reader/writer engine. Available options: 

614 'auto', 'sqlalchemy', the default is 'auto' 

615""" 

616 

617with cf.config_prefix("io.sql"): 

618 cf.register_option( 

619 "engine", 

620 "auto", 

621 sql_engine_doc, 

622 validator=is_one_of_factory(["auto", "sqlalchemy"]), 

623 ) 

624 

625# -------- 

626# Plotting 

627# --------- 

628 

629plotting_backend_doc = """ 

630: str 

631 The plotting backend to use. The default value is "matplotlib", the 

632 backend provided with pandas. Other backends can be specified by 

633 providing the name of the module that implements the backend. 

634""" 

635 

636 

637def register_plotting_backend_cb(key) -> None: 

638 if key == "matplotlib": 

639 # We defer matplotlib validation, since it's the default 

640 return 

641 from pandas.plotting._core import _get_plot_backend 

642 

643 _get_plot_backend(key) 

644 

645 

646with cf.config_prefix("plotting"): 

647 cf.register_option( 

648 "backend", 

649 defval="matplotlib", 

650 doc=plotting_backend_doc, 

651 validator=register_plotting_backend_cb, 

652 ) 

653 

654 

655register_converter_doc = """ 

656: bool or 'auto'. 

657 Whether to register converters with matplotlib's units registry for 

658 dates, times, datetimes, and Periods. Toggling to False will remove 

659 the converters, restoring any converters that pandas overwrote. 

660""" 

661 

662 

663def register_converter_cb(key) -> None: 

664 from pandas.plotting import ( 

665 deregister_matplotlib_converters, 

666 register_matplotlib_converters, 

667 ) 

668 

669 if cf.get_option(key): 

670 register_matplotlib_converters() 

671 else: 

672 deregister_matplotlib_converters() 

673 

674 

675with cf.config_prefix("plotting.matplotlib"): 

676 cf.register_option( 

677 "register_converters", 

678 "auto", 

679 register_converter_doc, 

680 validator=is_one_of_factory(["auto", True, False]), 

681 cb=register_converter_cb, 

682 ) 

683 

684# ------ 

685# Styler 

686# ------ 

687 

688styler_sparse_index_doc = """ 

689: bool 

690 Whether to sparsify the display of a hierarchical index. Setting to False will 

691 display each explicit level element in a hierarchical key for each row. 

692""" 

693 

694styler_sparse_columns_doc = """ 

695: bool 

696 Whether to sparsify the display of hierarchical columns. Setting to False will 

697 display each explicit level element in a hierarchical key for each column. 

698""" 

699 

700styler_render_repr = """ 

701: str 

702 Determine which output to use in Jupyter Notebook in {"html", "latex"}. 

703""" 

704 

705styler_max_elements = """ 

706: int 

707 The maximum number of data-cell (<td>) elements that will be rendered before 

708 trimming will occur over columns, rows or both if needed. 

709""" 

710 

711styler_max_rows = """ 

712: int, optional 

713 The maximum number of rows that will be rendered. May still be reduced to 

714 satsify ``max_elements``, which takes precedence. 

715""" 

716 

717styler_max_columns = """ 

718: int, optional 

719 The maximum number of columns that will be rendered. May still be reduced to 

720 satsify ``max_elements``, which takes precedence. 

721""" 

722 

723styler_precision = """ 

724: int 

725 The precision for floats and complex numbers. 

726""" 

727 

728styler_decimal = """ 

729: str 

730 The character representation for the decimal separator for floats and complex. 

731""" 

732 

733styler_thousands = """ 

734: str, optional 

735 The character representation for thousands separator for floats, int and complex. 

736""" 

737 

738styler_na_rep = """ 

739: str, optional 

740 The string representation for values identified as missing. 

741""" 

742 

743styler_escape = """ 

744: str, optional 

745 Whether to escape certain characters according to the given context; html or latex. 

746""" 

747 

748styler_formatter = """ 

749: str, callable, dict, optional 

750 A formatter object to be used as default within ``Styler.format``. 

751""" 

752 

753styler_multirow_align = """ 

754: {"c", "t", "b"} 

755 The specifier for vertical alignment of sparsified LaTeX multirows. 

756""" 

757 

758styler_multicol_align = r""" 

759: {"r", "c", "l", "naive-l", "naive-r"} 

760 The specifier for horizontal alignment of sparsified LaTeX multicolumns. Pipe 

761 decorators can also be added to non-naive values to draw vertical 

762 rules, e.g. "\|r" will draw a rule on the left side of right aligned merged cells. 

763""" 

764 

765styler_hrules = """ 

766: bool 

767 Whether to add horizontal rules on top and bottom and below the headers. 

768""" 

769 

770styler_environment = """ 

771: str 

772 The environment to replace ``\\begin{table}``. If "longtable" is used results 

773 in a specific longtable environment format. 

774""" 

775 

776styler_encoding = """ 

777: str 

778 The encoding used for output HTML and LaTeX files. 

779""" 

780 

781styler_mathjax = """ 

782: bool 

783 If False will render special CSS classes to table attributes that indicate Mathjax 

784 will not be used in Jupyter Notebook. 

785""" 

786 

787with cf.config_prefix("styler"): 

788 cf.register_option("sparse.index", True, styler_sparse_index_doc, validator=is_bool) 

789 

790 cf.register_option( 

791 "sparse.columns", True, styler_sparse_columns_doc, validator=is_bool 

792 ) 

793 

794 cf.register_option( 

795 "render.repr", 

796 "html", 

797 styler_render_repr, 

798 validator=is_one_of_factory(["html", "latex"]), 

799 ) 

800 

801 cf.register_option( 

802 "render.max_elements", 

803 2**18, 

804 styler_max_elements, 

805 validator=is_nonnegative_int, 

806 ) 

807 

808 cf.register_option( 

809 "render.max_rows", 

810 None, 

811 styler_max_rows, 

812 validator=is_nonnegative_int, 

813 ) 

814 

815 cf.register_option( 

816 "render.max_columns", 

817 None, 

818 styler_max_columns, 

819 validator=is_nonnegative_int, 

820 ) 

821 

822 cf.register_option("render.encoding", "utf-8", styler_encoding, validator=is_str) 

823 

824 cf.register_option("format.decimal", ".", styler_decimal, validator=is_str) 

825 

826 cf.register_option( 

827 "format.precision", 6, styler_precision, validator=is_nonnegative_int 

828 ) 

829 

830 cf.register_option( 

831 "format.thousands", 

832 None, 

833 styler_thousands, 

834 validator=is_instance_factory([type(None), str]), 

835 ) 

836 

837 cf.register_option( 

838 "format.na_rep", 

839 None, 

840 styler_na_rep, 

841 validator=is_instance_factory([type(None), str]), 

842 ) 

843 

844 cf.register_option( 

845 "format.escape", 

846 None, 

847 styler_escape, 

848 validator=is_one_of_factory([None, "html", "latex"]), 

849 ) 

850 

851 cf.register_option( 

852 "format.formatter", 

853 None, 

854 styler_formatter, 

855 validator=is_instance_factory([type(None), dict, Callable, str]), 

856 ) 

857 

858 cf.register_option("html.mathjax", True, styler_mathjax, validator=is_bool) 

859 

860 cf.register_option( 

861 "latex.multirow_align", 

862 "c", 

863 styler_multirow_align, 

864 validator=is_one_of_factory(["c", "t", "b", "naive"]), 

865 ) 

866 

867 val_mca = ["r", "|r|", "|r", "r|", "c", "|c|", "|c", "c|", "l", "|l|", "|l", "l|"] 

868 val_mca += ["naive-l", "naive-r"] 

869 cf.register_option( 

870 "latex.multicol_align", 

871 "r", 

872 styler_multicol_align, 

873 validator=is_one_of_factory(val_mca), 

874 ) 

875 

876 cf.register_option("latex.hrules", False, styler_hrules, validator=is_bool) 

877 

878 cf.register_option( 

879 "latex.environment", 

880 None, 

881 styler_environment, 

882 validator=is_instance_factory([type(None), str]), 

883 )