Skip to content

TST: Fix doctests in style.py #42759

Closed
@Leonardofreua

Description

@Leonardofreua

tl;dr

Fix the numerous doctests that are giving errors in the style.py file:

FAILED pandas/io/formats/style.py::pandas.io.formats.style.Styler.apply
FAILED pandas/io/formats/style.py::pandas.io.formats.style.Styler.applymap
FAILED pandas/io/formats/style.py::pandas.io.formats.style.Styler.background_gradient
FAILED pandas/io/formats/style.py::pandas.io.formats.style.Styler.hide_columns
FAILED pandas/io/formats/style.py::pandas.io.formats.style.Styler.hide_index
FAILED pandas/io/formats/style.py::pandas.io.formats.style.Styler.highlight_between
FAILED pandas/io/formats/style.py::pandas.io.formats.style.Styler.highlight_quantile
FAILED pandas/io/formats/style.py::pandas.io.formats.style.Styler.pipe
FAILED pandas/io/formats/style.py::pandas.io.formats.style.Styler.set_properties
FAILED pandas/io/formats/style.py::pandas.io.formats.style.Styler.set_table_attributes
FAILED pandas/io/formats/style.py::pandas.io.formats.style.Styler.set_table_styles
FAILED pandas/io/formats/style.py::pandas.io.formats.style.Styler.set_td_classes
FAILED pandas/io/formats/style.py::pandas.io.formats.style.Styler.set_tooltips
FAILED pandas/io/formats/style.py::pandas.io.formats.style.Styler.text_gradient
FAILED pandas/io/formats/style.py::pandas.io.formats.style.Styler.to_latex
FAILED pandas/io/formats/style.py::pandas.io.formats.style.Styler.where
======================================================================== 16 failed, 1 passed, 1 warning in 0.76s ========================================================================

Detailed instructions

Each of the doctests failed for different reasons. You can see the reason for each of them by running the command below:

python -m pytest --doctest-modules pandas/io/formats/style.py

In general, the above errors can be fixed with things like:

  • Fixing a typo (a missing comma, a misspelled variable name...)
  • Adding an object that hasn't been defined (like, if df is used, but
    no sample dataset df has been first defined)
  • Fixing the expected output, when it's wrong
  • In exceptional cases, examples shouldn't run, since they can't work.
    For example, a function that connects to a private webservice. In
    such cases, we can add # doctest: +SKIP at the end of the lines
    that should not run
  • In some cases, as it is not possible to display the result as it may
    involve the styling of a table, it will be necessary to skip the
    test (ensuring that it is happening correctly) or use the tag # doctest: +ELLIPSIS

Observation

In some cases it'll be necessary to use # doctest: +SKIP and later in another use or in this same issue, add images for some results that cannot be displayed, such as stylizations and color addition (this was dealt with in another issue).

Metadata

Metadata

Assignees

Labels

CIContinuous IntegrationDocsStylerconditional formatting using DataFrame.style

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions