Skip to content

report.py's to_html() drops groups past the display cap with no truncation notice, unlike to_terminal/compare_to_html #433

Description

@yakew7

Where: faircode/report.py's to_html (single-profile HTML report, dimension table rendering) vs to_terminal and compare_to_html in the same file.

The gap: to_terminal and compare_to_html both emit a "... and N more groups" note (DISPLAY_GROUPS = 12) when a dimension has more groups than the display cap. to_html's single-profile report has no equivalent - it silently renders only the first 12 groups with zero indication more exist.

Repro:

>>> import pandas as pd
>>> from faircode import profile
>>> from faircode.report import to_html
>>> df = pd.DataFrame({'region': [f'city_{i}' for i in range(20) for _ in range(5)]})
>>> result = profile(df, overrides={'region': 'geography'})
>>> html = to_html(result)
>>> result['dimensions'][0]['n_groups']
20
>>> 'more groups' in html
False
>>> 'dim-more' in html
False

Why it matters: a shared HTML report is the artifact most likely to be handed to a non-technical stakeholder, and it can look like a complete demographic breakdown while silently hiding up to 8+ groups - inconsistent with the terminal and compare renderers of the exact same data.

Suggested fix: add the same if len(d["groups"]) > DISPLAY_GROUPS: truncation note inside to_html's dimension-block loop, mirroring compare_to_html's existing .dim-more div (faircode/report.py around line 391-392).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions