Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
be15967
add sparsify to to_html
attack68 Jun 11, 2021
c187dc2
add tests
attack68 Jun 11, 2021
c53040e
doc fix
attack68 Jun 11, 2021
44cca16
Merge remote-tracking branch 'upstream/master' into styler_to_html_sp…
attack68 Jun 12, 2021
6427b88
Merge branch 'rls1.3.0' into styler_to_html_sparse_args
attack68 Jun 15, 2021
6bf29f8
Merge remote-tracking branch 'upstream/master' into styler_to_html_sp…
attack68 Jun 18, 2021
2b166b4
Merge remote-tracking branch 'upstream/master' into styler_to_html_sp…
attack68 Jun 20, 2021
ad4cee6
Merge remote-tracking branch 'upstream/master' into styler_to_html_sp…
attack68 Jun 29, 2021
3889890
Merge remote-tracking branch 'upstream/master' into styler_to_html_sp…
attack68 Jul 3, 2021
60053ab
Merge remote-tracking branch 'upstream/master' into styler_to_html_sp…
attack68 Jul 5, 2021
512af50
whats new 1.4.0
attack68 Jul 5, 2021
13090ab
better test
attack68 Jul 5, 2021
38559f5
versionadded
attack68 Jul 5, 2021
5ba2db9
Merge remote-tracking branch 'upstream/master' into styler_to_html_sp…
attack68 Jul 8, 2021
2ca6207
Merge remote-tracking branch 'upstream/master' into styler_to_html_sp…
attack68 Jul 10, 2021
855e886
Merge remote-tracking branch 'upstream/master' into styler_to_html_sp…
attack68 Jul 13, 2021
e796368
Merge remote-tracking branch 'upstream/master' into styler_to_html_sp…
attack68 Jul 14, 2021
1770300
Merge remote-tracking branch 'upstream/master' into styler_to_html_sp…
attack68 Jul 20, 2021
ad1f85d
Merge remote-tracking branch 'upstream/master' into styler_to_html_sp…
attack68 Jul 24, 2021
71c9dae
Merge branch 'master' into styler_to_html_sparse_args
jreback Jul 28, 2021
cadcc3e
Merge remote-tracking branch 'upstream/master' into styler_to_html_sp…
attack68 Jul 28, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add tests
  • Loading branch information
attack68 committed Jun 11, 2021
commit c187dc2367fc4e7877fbd41ae5867ed881d4dbb2
31 changes: 30 additions & 1 deletion pandas/tests/io/formats/style/test_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

import pytest

from pandas import DataFrame
from pandas import (
DataFrame,
MultiIndex,
option_context,
)

jinja2 = pytest.importorskip("jinja2")
from pandas.io.formats.style import Styler
Expand Down Expand Up @@ -236,3 +240,28 @@ def test_from_custom_template(tmpdir):
def test_caption_as_sequence(styler):
styler.set_caption(("full cap", "short cap"))
assert "<caption>full cap</caption>" in styler.render()


def test_sparse_options():
cidx = MultiIndex.from_tuples([("Z", "a"), ("Z", "b"), ("Y", "c")])
ridx = MultiIndex.from_tuples([("A", "a"), ("A", "b"), ("B", "c")])
df = DataFrame([[1, 2, 3], [4, 5, 6], [7, 8, 9]], index=ridx, columns=cidx)
styler = df.style

base_html = styler.to_html()

# test option context and method arguments simultaneously
# output generation is tested in test_style.test_mi_sparse
for sparse_index in [True, False]:
with option_context("styler.sparse.index", sparse_index):
html1 = styler.to_html()
assert (html1 == base_html) is sparse_index
html2 = styler.to_html(sparse_index=sparse_index, sparse_columns=True)
assert html1 == html2

for sparse_columns in [True, False]:
with option_context("styler.sparse.columns", sparse_columns):
html1 = styler.to_html()
assert (html1 == base_html) is sparse_columns
html2 = styler.to_html(sparse_index=True, sparse_columns=sparse_columns)
assert html1 == html2