Add tests for theme/aesthetic helper functions#524
Add tests for theme/aesthetic helper functions#524utkarshpawade wants to merge 4 commits intostan-dev:masterfrom
Conversation
There was a problem hiding this comment.
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 = FALSEtoelement_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.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #524 +/- ##
=======================================
Coverage 99.15% 99.15%
=======================================
Files 35 35
Lines 5920 5920
=======================================
Hits 5870 5870
Misses 50 50 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jgabry
left a comment
There was a problem hiding this comment.
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.
Fixes #523
expect_s3_class, incomplete theme validation) forplot_bg(),panel_bg(),facet_bg(),legend_move(),legend_text()on = FALSE→element_blankverification for all three background helpersppc_hist,ppc_dens_overlay,ppc_dens)overlay_functionreturn type check (LayerInstance, nottheme) and plot compositionlegend_move("none")equivalence withlegend_none()