Skip to content

fix(histogram): filter excess groups and align titles - #433

Merged
georgezakinih merged 3 commits into
FNLCR-DMAP:devfrom
zhan4329:feat/histogram-facet-followup
Aug 4, 2026
Merged

georgezakinih merged 3 commits into
FNLCR-DMAP:devfrom
zhan4329:feat/histogram-facet-followup

Conversation

@zhan4329

@zhan4329 zhan4329 commented Jul 1, 2026 •

Copy link
Copy Markdown

Summary

This follow-up focuses on two review-driven fixes:

  • Filter excessive grouped/faceted histogram plots to the most frequent max_groups groups instead of failing outright
  • Align histogram title ownership so core owns per-axis titles and the template owns figure-level titles

Changes

  • Update grouped histogram behavior to emit a UserWarning and plot the top groups when group count exceeds max_groups.
  • Forward the above warnings through the histogram template logger for template users.
  • Simplify histogram titles across direct-call and template paths.
  • Stop template-side raw group title reassignment for multi-axis outputs so panel titles remain consistent with core-rendered groups after filtering.
  • Add focused regression coverage for excessive-group filtering and template figure-title output.

Testing

pytest tests/test_visualization/test_histogram.py tests/templates/test_histogram_template.py

Result:

46 passed, 2 warnings

Example

The screenshot below shows how filtering works: previously when the number of groups exceeds max_groups, it will reject the input. Now it automatically filters the top max_groups frequent groups and plot them. (There are some overlapping issues here due to long titles which I do not intend to take care of in this PR).

image

This screenshot captures checkpoint at zhan4329@f047513. Since the file is too large, you may check the testing notebook at this commit here (at Y.11, or cell 18): https://github.com/zhan4329/SCSAWorkflow/blob/f0475138eda033a844f0509f77326a649140bbd3/notebooks/test_histogram_facet_light_template.ipynb

This pull request body is generated with the help of Codex using GPT-5.

zhan4329 added 2 commits June 30, 2026 10:20
- keep the most frequent groups when `max_groups` is exceeded
- surface the warning through the histogram template logger
- update histogram tests for the filtering path
- Use compact table-aware histogram titles in core and template paths
- Preserve core-owned panel titles for multi-axis outputs
- Add template smoke coverage for figure title output
- Update core title expectations for the revised wording
@zhan4329 zhan4329 changed the title feat(histogram): follow-up for faceted plot fix(histogram): filter excess groups and align titles Jul 1, 2026
@zhan4329
zhan4329 marked this pull request as ready for review July 1, 2026 12:51
Comment thread src/spac/visualization.py Outdated
)
warnings.warn(warning_message, UserWarning)
n_groups = len(groups)
plot_data = plot_data[plot_data[group_by].isin(groups)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we show a message in the plot that we are not showing all groups?

)

self.assertIsNotNone(fig._suptitle)
self.assertTrue(fig._suptitle.get_text())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add an example for various titles that are generated in different scenarios.

- Pass filtering metadata from core histogram output to templates.
- Add grouped and faceted top-N title suffixes.
- Expand title examples and filtering assertions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants