Skip to content

Add tests for theme/aesthetic helper functions#524

Merged
jgabry merged 6 commits intostan-dev:masterfrom
utkarshpawade:test/theme-helper-coverage
Apr 15, 2026
Merged

Add tests for theme/aesthetic helper functions#524
jgabry merged 6 commits intostan-dev:masterfrom
utkarshpawade:test/theme-helper-coverage

Conversation

@utkarshpawade
Copy link
Copy Markdown
Contributor

@utkarshpawade utkarshpawade commented Apr 2, 2026

Fixes #523

  • Added legend_move("none") equivalence with legend_none()

Copilot AI review requested due to automatic review settings April 2, 2026 16:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds expanded test coverage for bayesplot theme/aesthetic convenience helpers, with checks for return types and compatibility when added to real bayesplot ggplot objects.

Changes:

  • Added tests asserting helper outputs are incomplete themes and map on = FALSE to element_blank().
  • Added composition tests ensuring helpers and overlay_function() can be added to real bayesplot plots.
  • Added a NEWS entry documenting the added tests.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
tests/testthat/test-convenience-functions.R Adds new testthat cases around theme helper return types and plot composition.
NEWS.md Documents newly added tests for theme/aesthetic helpers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/testthat/test-convenience-functions.R Outdated
Comment thread tests/testthat/test-convenience-functions.R Outdated
Comment thread tests/testthat/test-convenience-functions.R Outdated
Comment thread NEWS.md Outdated
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.18%. Comparing base (6d49142) to head (6f82364).
⚠️ Report is 14 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #524   +/-   ##
=======================================
  Coverage   99.18%   99.18%           
=======================================
  Files          35       35           
  Lines        6120     6120           
=======================================
  Hits         6070     6070           
  Misses         50       50           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@jgabry jgabry left a comment

Choose a reason for hiding this comment

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

Thanks @utkarshpawade. I think the legend_move("none") test is worth keeping, since that behavior is explicitly documented and it guards a real contract of the helper.

For the rest, I’m not convinced the added tests are giving us much benefit. Most of these helpers are very thin wrappers around ggplot2::theme() or ggplot2::stat_function(), and the existing tests already cover the main behavior by checking the returned objects directly. The new composition tests mostly confirm that ggplot can still add a valid theme/layer object to a plot, which is more ggplot behavior than bayesplot behavior. The extra on = FALSE checks also seem redundant with the existing expectations that already compare against element_blank() themes.

So my preference would be to keep the legend_move("none") test and drop the others, to avoid adding test volume without much additional protection.

Copy link
Copy Markdown
Member

@jgabry jgabry left a comment

Choose a reason for hiding this comment

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

Thanks, looks good! I'm looking into the failing CI run. It's not related to this PR, but I might try to fix it before merging more PRs.

@jgabry jgabry merged commit 14c1c74 into stan-dev:master Apr 15, 2026
5 of 6 checks passed
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.

Add dedicated tests for theme/aesthetic helper functions

4 participants