Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/pandas/core/config_init.py: 86%
225 statements
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
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.
8If you need to make sure options are available even before a certain
9module is imported, register them here rather than in the module.
11"""
12from __future__ import annotations
14import os
15from typing import Callable
16import warnings
18import pandas._config.config as cf
19from pandas._config.config import (
20 is_bool,
21 is_callable,
22 is_instance_factory,
23 is_int,
24 is_nonnegative_int,
25 is_one_of_factory,
26 is_str,
27 is_text,
28)
30from pandas.util._exceptions import find_stack_level
32# compute
34use_bottleneck_doc = """
35: bool
36 Use the bottleneck library to accelerate if it is installed,
37 the default is True
38 Valid values: False,True
39"""
42def use_bottleneck_cb(key) -> None:
43 from pandas.core import nanops
45 nanops.set_use_bottleneck(cf.get_option(key))
48use_numexpr_doc = """
49: bool
50 Use the numexpr library to accelerate computation if it is installed,
51 the default is True
52 Valid values: False,True
53"""
56def use_numexpr_cb(key) -> None:
57 from pandas.core.computation import expressions
59 expressions.set_use_numexpr(cf.get_option(key))
62use_numba_doc = """
63: bool
64 Use the numba engine option for select operations if it is installed,
65 the default is False
66 Valid values: False,True
67"""
70def use_numba_cb(key) -> None:
71 from pandas.core.util import numba_
73 numba_.set_use_numba(cf.get_option(key))
76with cf.config_prefix("compute"):
77 cf.register_option(
78 "use_bottleneck",
79 True,
80 use_bottleneck_doc,
81 validator=is_bool,
82 cb=use_bottleneck_cb,
83 )
84 cf.register_option(
85 "use_numexpr", True, use_numexpr_doc, validator=is_bool, cb=use_numexpr_cb
86 )
87 cf.register_option(
88 "use_numba", False, use_numba_doc, validator=is_bool, cb=use_numba_cb
89 )
90#
91# options from the "display" namespace
93pc_precision_doc = """
94: int
95 Floating point output precision in terms of number of places after the
96 decimal, for regular formatting as well as scientific notation. Similar
97 to ``precision`` in :meth:`numpy.set_printoptions`.
98"""
100pc_colspace_doc = """
101: int
102 Default space for DataFrame columns.
103"""
105pc_max_rows_doc = """
106: int
107 If max_rows is exceeded, switch to truncate view. Depending on
108 `large_repr`, objects are either centrally truncated or printed as
109 a summary view. 'None' value means unlimited.
111 In case python/IPython is running in a terminal and `large_repr`
112 equals 'truncate' this can be set to 0 and pandas will auto-detect
113 the height of the terminal and print a truncated object which fits
114 the screen height. The IPython notebook, IPython qtconsole, or
115 IDLE do not run in a terminal and hence it is not possible to do
116 correct auto-detection.
117"""
119pc_min_rows_doc = """
120: int
121 The numbers of rows to show in a truncated view (when `max_rows` is
122 exceeded). Ignored when `max_rows` is set to None or 0. When set to
123 None, follows the value of `max_rows`.
124"""
126pc_max_cols_doc = """
127: int
128 If max_cols is exceeded, switch to truncate view. Depending on
129 `large_repr`, objects are either centrally truncated or printed as
130 a summary view. 'None' value means unlimited.
132 In case python/IPython is running in a terminal and `large_repr`
133 equals 'truncate' this can be set to 0 and pandas will auto-detect
134 the width of the terminal and print a truncated object which fits
135 the screen width. The IPython notebook, IPython qtconsole, or IDLE
136 do not run in a terminal and hence it is not possible to do
137 correct auto-detection.
138"""
140pc_max_categories_doc = """
141: int
142 This sets the maximum number of categories pandas should output when
143 printing out a `Categorical` or a Series of dtype "category".
144"""
146pc_max_info_cols_doc = """
147: int
148 max_info_columns is used in DataFrame.info method to decide if
149 per column information will be printed.
150"""
152pc_nb_repr_h_doc = """
153: boolean
154 When True, IPython notebook will use html representation for
155 pandas objects (if it is available).
156"""
158pc_pprint_nest_depth = """
159: int
160 Controls the number of nested levels to process when pretty-printing
161"""
163pc_multi_sparse_doc = """
164: boolean
165 "sparsify" MultiIndex display (don't display repeated
166 elements in outer levels within groups)
167"""
169float_format_doc = """
170: callable
171 The callable should accept a floating point number and return
172 a string with the desired format of the number. This is used
173 in some places like SeriesFormatter.
174 See formats.format.EngFormatter for an example.
175"""
177max_colwidth_doc = """
178: int or None
179 The maximum width in characters of a column in the repr of
180 a pandas data structure. When the column overflows, a "..."
181 placeholder is embedded in the output. A 'None' value means unlimited.
182"""
184colheader_justify_doc = """
185: 'left'/'right'
186 Controls the justification of column headers. used by DataFrameFormatter.
187"""
189pc_expand_repr_doc = """
190: boolean
191 Whether to print out the full DataFrame repr for wide DataFrames across
192 multiple lines, `max_columns` is still respected, but the output will
193 wrap-around across multiple "pages" if its width exceeds `display.width`.
194"""
196pc_show_dimensions_doc = """
197: boolean or 'truncate'
198 Whether to print out dimensions at the end of DataFrame repr.
199 If 'truncate' is specified, only print out the dimensions if the
200 frame is truncated (e.g. not display all rows and/or columns)
201"""
203pc_east_asian_width_doc = """
204: boolean
205 Whether to use the Unicode East Asian Width to calculate the display text
206 width.
207 Enabling this may affect to the performance (default: False)
208"""
210pc_ambiguous_as_wide_doc = """
211: boolean
212 Whether to handle Unicode characters belong to Ambiguous as Wide (width=2)
213 (default: False)
214"""
216pc_latex_repr_doc = """
217: boolean
218 Whether to produce a latex DataFrame representation for jupyter
219 environments that support it.
220 (default: False)
221"""
223pc_table_schema_doc = """
224: boolean
225 Whether to publish a Table Schema representation for frontends
226 that support it.
227 (default: False)
228"""
230pc_html_border_doc = """
231: int
232 A ``border=value`` attribute is inserted in the ``<table>`` tag
233 for the DataFrame HTML repr.
234"""
236pc_html_use_mathjax_doc = """\
237: boolean
238 When True, Jupyter notebook will process table contents using MathJax,
239 rendering mathematical expressions enclosed by the dollar symbol.
240 (default: True)
241"""
243pc_max_dir_items = """\
244: int
245 The number of items that will be added to `dir(...)`. 'None' value means
246 unlimited. Because dir is cached, changing this option will not immediately
247 affect already existing dataframes until a column is deleted or added.
249 This is for instance used to suggest columns from a dataframe to tab
250 completion.
251"""
253pc_width_doc = """
254: int
255 Width of the display in characters. In case python/IPython is running in
256 a terminal this can be set to None and pandas will correctly auto-detect
257 the width.
258 Note that the IPython notebook, IPython qtconsole, or IDLE do not run in a
259 terminal and hence it is not possible to correctly detect the width.
260"""
262pc_chop_threshold_doc = """
263: float or None
264 if set to a float value, all float values smaller than the given threshold
265 will be displayed as exactly 0 by repr and friends.
266"""
268pc_max_seq_items = """
269: int or None
270 When pretty-printing a long sequence, no more then `max_seq_items`
271 will be printed. If items are omitted, they will be denoted by the
272 addition of "..." to the resulting string.
274 If set to None, the number of items to be printed is unlimited.
275"""
277pc_max_info_rows_doc = """
278: int or None
279 df.info() will usually show null-counts for each column.
280 For large frames this can be quite slow. max_info_rows and max_info_cols
281 limit this null check only to frames with smaller dimensions than
282 specified.
283"""
285pc_large_repr_doc = """
286: 'truncate'/'info'
287 For DataFrames exceeding max_rows/max_cols, the repr (and HTML repr) can
288 show a truncated table (the default from 0.13), or switch to the view from
289 df.info() (the behaviour in earlier versions of pandas).
290"""
292pc_memory_usage_doc = """
293: bool, string or None
294 This specifies if the memory usage of a DataFrame should be displayed when
295 df.info() is called. Valid values True,False,'deep'
296"""
298pc_latex_escape = """
299: bool
300 This specifies if the to_latex method of a Dataframe uses escapes special
301 characters.
302 Valid values: False,True
303"""
305pc_latex_longtable = """
306:bool
307 This specifies if the to_latex method of a Dataframe uses the longtable
308 format.
309 Valid values: False,True
310"""
312pc_latex_multicolumn = """
313: bool
314 This specifies if the to_latex method of a Dataframe uses multicolumns
315 to pretty-print MultiIndex columns.
316 Valid values: False,True
317"""
319pc_latex_multicolumn_format = """
320: string
321 This specifies the format for multicolumn headers.
322 Can be surrounded with '|'.
323 Valid values: 'l', 'c', 'r', 'p{<width>}'
324"""
326pc_latex_multirow = """
327: bool
328 This specifies if the to_latex method of a Dataframe uses multirows
329 to pretty-print MultiIndex rows.
330 Valid values: False,True
331"""
334def table_schema_cb(key) -> None:
335 from pandas.io.formats.printing import enable_data_resource_formatter
337 enable_data_resource_formatter(cf.get_option(key))
340def is_terminal() -> bool:
341 """
342 Detect if Python is running in a terminal.
344 Returns True if Python is running in a terminal or False if not.
345 """
346 try:
347 # error: Name 'get_ipython' is not defined
348 ip = get_ipython() # type: ignore[name-defined]
349 except NameError: # assume standard Python interpreter in a terminal
350 return True
351 else:
352 if hasattr(ip, "kernel"): # IPython as a Jupyter kernel
353 return False
354 else: # IPython in a terminal
355 return True
358with cf.config_prefix("display"):
359 cf.register_option("precision", 6, pc_precision_doc, validator=is_nonnegative_int)
360 cf.register_option(
361 "float_format",
362 None,
363 float_format_doc,
364 validator=is_one_of_factory([None, is_callable]),
365 )
367 def _deprecate_column_space(key):
368 warnings.warn(
369 "column_space is deprecated and will be removed "
370 "in a future version. Use df.to_string(col_space=...) "
371 "instead.",
372 FutureWarning,
373 stacklevel=find_stack_level(),
374 )
376 cf.register_option("column_space", 12, validator=is_int, cb=_deprecate_column_space)
377 cf.register_option(
378 "max_info_rows",
379 1690785,
380 pc_max_info_rows_doc,
381 validator=is_instance_factory((int, type(None))),
382 )
383 cf.register_option("max_rows", 60, pc_max_rows_doc, validator=is_nonnegative_int)
384 cf.register_option(
385 "min_rows",
386 10,
387 pc_min_rows_doc,
388 validator=is_instance_factory([type(None), int]),
389 )
390 cf.register_option("max_categories", 8, pc_max_categories_doc, validator=is_int)
392 def _deprecate_negative_int_max_colwidth(key):
393 value = cf.get_option(key)
394 if value is not None and value < 0:
395 warnings.warn(
396 "Passing a negative integer is deprecated in version 1.0 and "
397 "will not be supported in future version. Instead, use None "
398 "to not limit the column width.",
399 FutureWarning,
400 stacklevel=find_stack_level(),
401 )
403 cf.register_option(
404 # TODO(2.0): change `validator=is_nonnegative_int` see GH#31569
405 "max_colwidth",
406 50,
407 max_colwidth_doc,
408 validator=is_instance_factory([type(None), int]),
409 cb=_deprecate_negative_int_max_colwidth,
410 )
411 if is_terminal(): 411 ↛ 414line 411 didn't jump to line 414, because the condition on line 411 was never false
412 max_cols = 0 # automatically determine optimal number of columns
413 else:
414 max_cols = 20 # cannot determine optimal number of columns
415 cf.register_option(
416 "max_columns", max_cols, pc_max_cols_doc, validator=is_nonnegative_int
417 )
418 cf.register_option(
419 "large_repr",
420 "truncate",
421 pc_large_repr_doc,
422 validator=is_one_of_factory(["truncate", "info"]),
423 )
424 cf.register_option("max_info_columns", 100, pc_max_info_cols_doc, validator=is_int)
425 cf.register_option(
426 "colheader_justify", "right", colheader_justify_doc, validator=is_text
427 )
428 cf.register_option("notebook_repr_html", True, pc_nb_repr_h_doc, validator=is_bool)
429 cf.register_option("pprint_nest_depth", 3, pc_pprint_nest_depth, validator=is_int)
430 cf.register_option("multi_sparse", True, pc_multi_sparse_doc, validator=is_bool)
431 cf.register_option("expand_frame_repr", True, pc_expand_repr_doc)
432 cf.register_option(
433 "show_dimensions",
434 "truncate",
435 pc_show_dimensions_doc,
436 validator=is_one_of_factory([True, False, "truncate"]),
437 )
438 cf.register_option("chop_threshold", None, pc_chop_threshold_doc)
439 cf.register_option("max_seq_items", 100, pc_max_seq_items)
440 cf.register_option(
441 "width", 80, pc_width_doc, validator=is_instance_factory([type(None), int])
442 )
443 cf.register_option(
444 "memory_usage",
445 True,
446 pc_memory_usage_doc,
447 validator=is_one_of_factory([None, True, False, "deep"]),
448 )
449 cf.register_option(
450 "unicode.east_asian_width", False, pc_east_asian_width_doc, validator=is_bool
451 )
452 cf.register_option(
453 "unicode.ambiguous_as_wide", False, pc_east_asian_width_doc, validator=is_bool
454 )
455 cf.register_option("latex.repr", False, pc_latex_repr_doc, validator=is_bool)
456 cf.register_option("latex.escape", True, pc_latex_escape, validator=is_bool)
457 cf.register_option("latex.longtable", False, pc_latex_longtable, validator=is_bool)
458 cf.register_option(
459 "latex.multicolumn", True, pc_latex_multicolumn, validator=is_bool
460 )
461 cf.register_option(
462 "latex.multicolumn_format", "l", pc_latex_multicolumn, validator=is_text
463 )
464 cf.register_option("latex.multirow", False, pc_latex_multirow, validator=is_bool)
465 cf.register_option(
466 "html.table_schema",
467 False,
468 pc_table_schema_doc,
469 validator=is_bool,
470 cb=table_schema_cb,
471 )
472 cf.register_option("html.border", 1, pc_html_border_doc, validator=is_int)
473 cf.register_option(
474 "html.use_mathjax", True, pc_html_use_mathjax_doc, validator=is_bool
475 )
476 cf.register_option(
477 "max_dir_items", 100, pc_max_dir_items, validator=is_nonnegative_int
478 )
480tc_sim_interactive_doc = """
481: boolean
482 Whether to simulate interactive mode for purposes of testing
483"""
485with cf.config_prefix("mode"):
486 cf.register_option("sim_interactive", False, tc_sim_interactive_doc)
488use_inf_as_null_doc = """
489: boolean
490 use_inf_as_null had been deprecated and will be removed in a future
491 version. Use `use_inf_as_na` instead.
492"""
494use_inf_as_na_doc = """
495: boolean
496 True means treat None, NaN, INF, -INF as NA (old way),
497 False means None and NaN are null, but INF, -INF are not NA
498 (new way).
499"""
501# We don't want to start importing everything at the global context level
502# or we'll hit circular deps.
505def use_inf_as_na_cb(key) -> None:
506 from pandas.core.dtypes.missing import _use_inf_as_na
508 _use_inf_as_na(key)
511with cf.config_prefix("mode"):
512 cf.register_option("use_inf_as_na", False, use_inf_as_na_doc, cb=use_inf_as_na_cb)
513 cf.register_option(
514 "use_inf_as_null", False, use_inf_as_null_doc, cb=use_inf_as_na_cb
515 )
518cf.deprecate_option(
519 "mode.use_inf_as_null", msg=use_inf_as_null_doc, rkey="mode.use_inf_as_na"
520)
523data_manager_doc = """
524: string
525 Internal data manager type; can be "block" or "array". Defaults to "block",
526 unless overridden by the 'PANDAS_DATA_MANAGER' environment variable (needs
527 to be set before pandas is imported).
528"""
531with cf.config_prefix("mode"):
532 cf.register_option(
533 "data_manager",
534 # Get the default from an environment variable, if set, otherwise defaults
535 # to "block". This environment variable can be set for testing.
536 os.environ.get("PANDAS_DATA_MANAGER", "block"),
537 data_manager_doc,
538 validator=is_one_of_factory(["block", "array"]),
539 )
542# TODO better name?
543copy_on_write_doc = """
544: bool
545 Use new copy-view behaviour using Copy-on-Write. Defaults to False,
546 unless overridden by the 'PANDAS_COPY_ON_WRITE' environment variable
547 (if set to "1" for True, needs to be set before pandas is imported).
548"""
551with cf.config_prefix("mode"):
552 cf.register_option(
553 "copy_on_write",
554 # Get the default from an environment variable, if set, otherwise defaults
555 # to False. This environment variable can be set for testing.
556 os.environ.get("PANDAS_COPY_ON_WRITE", "0") == "1",
557 copy_on_write_doc,
558 validator=is_bool,
559 )
562# user warnings
563chained_assignment = """
564: string
565 Raise an exception, warn, or no action if trying to use chained assignment,
566 The default is warn
567"""
569with cf.config_prefix("mode"):
570 cf.register_option(
571 "chained_assignment",
572 "warn",
573 chained_assignment,
574 validator=is_one_of_factory([None, "warn", "raise"]),
575 )
578string_storage_doc = """
579: string
580 The default storage for StringDtype.
581"""
583with cf.config_prefix("mode"):
584 cf.register_option(
585 "string_storage",
586 "python",
587 string_storage_doc,
588 validator=is_one_of_factory(["python", "pyarrow"]),
589 )
591# Set up the io.excel specific reader configuration.
592reader_engine_doc = """
593: string
594 The default Excel reader engine for '{ext}' files. Available options:
595 auto, {others}.
596"""
598_xls_options = ["xlrd"]
599_xlsm_options = ["xlrd", "openpyxl"]
600_xlsx_options = ["xlrd", "openpyxl"]
601_ods_options = ["odf"]
602_xlsb_options = ["pyxlsb"]
605with cf.config_prefix("io.excel.xls"):
606 cf.register_option(
607 "reader",
608 "auto",
609 reader_engine_doc.format(ext="xls", others=", ".join(_xls_options)),
610 validator=is_one_of_factory(_xls_options + ["auto"]),
611 )
613with cf.config_prefix("io.excel.xlsm"):
614 cf.register_option(
615 "reader",
616 "auto",
617 reader_engine_doc.format(ext="xlsm", others=", ".join(_xlsm_options)),
618 validator=is_one_of_factory(_xlsm_options + ["auto"]),
619 )
622with cf.config_prefix("io.excel.xlsx"):
623 cf.register_option(
624 "reader",
625 "auto",
626 reader_engine_doc.format(ext="xlsx", others=", ".join(_xlsx_options)),
627 validator=is_one_of_factory(_xlsx_options + ["auto"]),
628 )
631with cf.config_prefix("io.excel.ods"):
632 cf.register_option(
633 "reader",
634 "auto",
635 reader_engine_doc.format(ext="ods", others=", ".join(_ods_options)),
636 validator=is_one_of_factory(_ods_options + ["auto"]),
637 )
639with cf.config_prefix("io.excel.xlsb"):
640 cf.register_option(
641 "reader",
642 "auto",
643 reader_engine_doc.format(ext="xlsb", others=", ".join(_xlsb_options)),
644 validator=is_one_of_factory(_xlsb_options + ["auto"]),
645 )
647# Set up the io.excel specific writer configuration.
648writer_engine_doc = """
649: string
650 The default Excel writer engine for '{ext}' files. Available options:
651 auto, {others}.
652"""
654_xls_options = ["xlwt"]
655_xlsm_options = ["openpyxl"]
656_xlsx_options = ["openpyxl", "xlsxwriter"]
657_ods_options = ["odf"]
660with cf.config_prefix("io.excel.xls"):
661 cf.register_option(
662 "writer",
663 "auto",
664 writer_engine_doc.format(ext="xls", others=", ".join(_xls_options)),
665 validator=str,
666 )
667cf.deprecate_option(
668 "io.excel.xls.writer",
669 msg="As the xlwt package is no longer maintained, the xlwt engine will be "
670 "removed in a future version of pandas. This is the only engine in pandas that "
671 "supports writing in the xls format. Install openpyxl and write to an "
672 "xlsx file instead.",
673)
675with cf.config_prefix("io.excel.xlsm"):
676 cf.register_option(
677 "writer",
678 "auto",
679 writer_engine_doc.format(ext="xlsm", others=", ".join(_xlsm_options)),
680 validator=str,
681 )
684with cf.config_prefix("io.excel.xlsx"):
685 cf.register_option(
686 "writer",
687 "auto",
688 writer_engine_doc.format(ext="xlsx", others=", ".join(_xlsx_options)),
689 validator=str,
690 )
693with cf.config_prefix("io.excel.ods"):
694 cf.register_option(
695 "writer",
696 "auto",
697 writer_engine_doc.format(ext="ods", others=", ".join(_ods_options)),
698 validator=str,
699 )
702# Set up the io.parquet specific configuration.
703parquet_engine_doc = """
704: string
705 The default parquet reader/writer engine. Available options:
706 'auto', 'pyarrow', 'fastparquet', the default is 'auto'
707"""
709with cf.config_prefix("io.parquet"):
710 cf.register_option(
711 "engine",
712 "auto",
713 parquet_engine_doc,
714 validator=is_one_of_factory(["auto", "pyarrow", "fastparquet"]),
715 )
718# Set up the io.sql specific configuration.
719sql_engine_doc = """
720: string
721 The default sql reader/writer engine. Available options:
722 'auto', 'sqlalchemy', the default is 'auto'
723"""
725with cf.config_prefix("io.sql"):
726 cf.register_option(
727 "engine",
728 "auto",
729 sql_engine_doc,
730 validator=is_one_of_factory(["auto", "sqlalchemy"]),
731 )
733# --------
734# Plotting
735# ---------
737plotting_backend_doc = """
738: str
739 The plotting backend to use. The default value is "matplotlib", the
740 backend provided with pandas. Other backends can be specified by
741 providing the name of the module that implements the backend.
742"""
745def register_plotting_backend_cb(key) -> None:
746 if key == "matplotlib": 746 ↛ 749line 746 didn't jump to line 749, because the condition on line 746 was never false
747 # We defer matplotlib validation, since it's the default
748 return
749 from pandas.plotting._core import _get_plot_backend
751 _get_plot_backend(key)
754with cf.config_prefix("plotting"):
755 cf.register_option(
756 "backend",
757 defval="matplotlib",
758 doc=plotting_backend_doc,
759 validator=register_plotting_backend_cb,
760 )
763register_converter_doc = """
764: bool or 'auto'.
765 Whether to register converters with matplotlib's units registry for
766 dates, times, datetimes, and Periods. Toggling to False will remove
767 the converters, restoring any converters that pandas overwrote.
768"""
771def register_converter_cb(key) -> None:
772 from pandas.plotting import (
773 deregister_matplotlib_converters,
774 register_matplotlib_converters,
775 )
777 if cf.get_option(key):
778 register_matplotlib_converters()
779 else:
780 deregister_matplotlib_converters()
783with cf.config_prefix("plotting.matplotlib"):
784 cf.register_option(
785 "register_converters",
786 "auto",
787 register_converter_doc,
788 validator=is_one_of_factory(["auto", True, False]),
789 cb=register_converter_cb,
790 )
792# ------
793# Styler
794# ------
796styler_sparse_index_doc = """
797: bool
798 Whether to sparsify the display of a hierarchical index. Setting to False will
799 display each explicit level element in a hierarchical key for each row.
800"""
802styler_sparse_columns_doc = """
803: bool
804 Whether to sparsify the display of hierarchical columns. Setting to False will
805 display each explicit level element in a hierarchical key for each column.
806"""
808styler_render_repr = """
809: str
810 Determine which output to use in Jupyter Notebook in {"html", "latex"}.
811"""
813styler_max_elements = """
814: int
815 The maximum number of data-cell (<td>) elements that will be rendered before
816 trimming will occur over columns, rows or both if needed.
817"""
819styler_max_rows = """
820: int, optional
821 The maximum number of rows that will be rendered. May still be reduced to
822 satsify ``max_elements``, which takes precedence.
823"""
825styler_max_columns = """
826: int, optional
827 The maximum number of columns that will be rendered. May still be reduced to
828 satsify ``max_elements``, which takes precedence.
829"""
831styler_precision = """
832: int
833 The precision for floats and complex numbers.
834"""
836styler_decimal = """
837: str
838 The character representation for the decimal separator for floats and complex.
839"""
841styler_thousands = """
842: str, optional
843 The character representation for thousands separator for floats, int and complex.
844"""
846styler_na_rep = """
847: str, optional
848 The string representation for values identified as missing.
849"""
851styler_escape = """
852: str, optional
853 Whether to escape certain characters according to the given context; html or latex.
854"""
856styler_formatter = """
857: str, callable, dict, optional
858 A formatter object to be used as default within ``Styler.format``.
859"""
861styler_multirow_align = """
862: {"c", "t", "b"}
863 The specifier for vertical alignment of sparsified LaTeX multirows.
864"""
866styler_multicol_align = r"""
867: {"r", "c", "l", "naive-l", "naive-r"}
868 The specifier for horizontal alignment of sparsified LaTeX multicolumns. Pipe
869 decorators can also be added to non-naive values to draw vertical
870 rules, e.g. "\|r" will draw a rule on the left side of right aligned merged cells.
871"""
873styler_hrules = """
874: bool
875 Whether to add horizontal rules on top and bottom and below the headers.
876"""
878styler_environment = """
879: str
880 The environment to replace ``\\begin{table}``. If "longtable" is used results
881 in a specific longtable environment format.
882"""
884styler_encoding = """
885: str
886 The encoding used for output HTML and LaTeX files.
887"""
889styler_mathjax = """
890: bool
891 If False will render special CSS classes to table attributes that indicate Mathjax
892 will not be used in Jupyter Notebook.
893"""
895with cf.config_prefix("styler"):
896 cf.register_option("sparse.index", True, styler_sparse_index_doc, validator=is_bool)
898 cf.register_option(
899 "sparse.columns", True, styler_sparse_columns_doc, validator=is_bool
900 )
902 cf.register_option(
903 "render.repr",
904 "html",
905 styler_render_repr,
906 validator=is_one_of_factory(["html", "latex"]),
907 )
909 cf.register_option(
910 "render.max_elements",
911 2**18,
912 styler_max_elements,
913 validator=is_nonnegative_int,
914 )
916 cf.register_option(
917 "render.max_rows",
918 None,
919 styler_max_rows,
920 validator=is_nonnegative_int,
921 )
923 cf.register_option(
924 "render.max_columns",
925 None,
926 styler_max_columns,
927 validator=is_nonnegative_int,
928 )
930 cf.register_option("render.encoding", "utf-8", styler_encoding, validator=is_str)
932 cf.register_option("format.decimal", ".", styler_decimal, validator=is_str)
934 cf.register_option(
935 "format.precision", 6, styler_precision, validator=is_nonnegative_int
936 )
938 cf.register_option(
939 "format.thousands",
940 None,
941 styler_thousands,
942 validator=is_instance_factory([type(None), str]),
943 )
945 cf.register_option(
946 "format.na_rep",
947 None,
948 styler_na_rep,
949 validator=is_instance_factory([type(None), str]),
950 )
952 cf.register_option(
953 "format.escape",
954 None,
955 styler_escape,
956 validator=is_one_of_factory([None, "html", "latex"]),
957 )
959 cf.register_option(
960 "format.formatter",
961 None,
962 styler_formatter,
963 validator=is_instance_factory([type(None), dict, Callable, str]),
964 )
966 cf.register_option("html.mathjax", True, styler_mathjax, validator=is_bool)
968 cf.register_option(
969 "latex.multirow_align",
970 "c",
971 styler_multirow_align,
972 validator=is_one_of_factory(["c", "t", "b", "naive"]),
973 )
975 val_mca = ["r", "|r|", "|r", "r|", "c", "|c|", "|c", "c|", "l", "|l|", "|l", "l|"]
976 val_mca += ["naive-l", "naive-r"]
977 cf.register_option(
978 "latex.multicol_align",
979 "r",
980 styler_multicol_align,
981 validator=is_one_of_factory(val_mca),
982 )
984 cf.register_option("latex.hrules", False, styler_hrules, validator=is_bool)
986 cf.register_option(
987 "latex.environment",
988 None,
989 styler_environment,
990 validator=is_instance_factory([type(None), str]),
991 )