Skip to content

docs/test: smooth=TRUE is intentionally a no-op for factor predictors in plot.gg_variable#89

Merged
ehrlinger merged 2 commits into
mainfrom
fix/plot-gg-variable-smooth-factor-comment
May 22, 2026
Merged

docs/test: smooth=TRUE is intentionally a no-op for factor predictors in plot.gg_variable#89
ehrlinger merged 2 commits into
mainfrom
fix/plot-gg-variable-smooth-factor-comment

Conversation

@ehrlinger
Copy link
Copy Markdown
Owner

Summary

geom_smooth requires a continuous x-axis; passing smooth = TRUE with a factor predictor is a silent no-op across all three plot families (binary classification, multi-class classification, regression). This was pre-existing behaviour that was consistent and correct, but undocumented.

  • Added inline comment to each of the three factor-predictor branches explaining the intentional skip
  • Added 3 tests locking in the behaviour: smooth=TRUE with a factor predictor (a) does not error, (b) returns a ggplot with exactly 2 layers (boxplot + jitter, no smooth)

Pre-existing gap first flagged during review of PR #88 (gg_variable classification fix).

Test plan

  • devtools::test(filter='gg_variable') — 47 tests, 0 failures

🤖 Generated with Claude Code

@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.11%. Comparing base (ae0b18e) to head (24b4665).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main      #89   +/-   ##
=======================================
  Coverage   87.11%   87.11%           
=======================================
  Files          38       38           
  Lines        3043     3043           
=======================================
  Hits         2651     2651           
  Misses        392      392           
Files with missing lines Coverage Δ
R/plot.gg_variable.R 82.13% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

… in plot.gg_variable

geom_smooth requires a continuous x-axis; for factor predictors the boxplot
IQR already serves as the spread summary.  Add inline comments to all three
factor-predictor branches (binary classification, multi-class classification,
regression) and three regression-test guard tests to lock in the no-op
behaviour.
@ehrlinger ehrlinger force-pushed the fix/plot-gg-variable-smooth-factor-comment branch from d714218 to 4f9dc48 Compare May 21, 2026 18:49
@ehrlinger ehrlinger requested a review from Copilot May 21, 2026 18:59
Copy link
Copy Markdown

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

Note

Copilot was unable to run its full agentic suite in this review.

Documents and locks in the existing behavior that smooth=TRUE is intentionally a no-op when plot.gg_variable() is called with a factor predictor (since geom_smooth requires a continuous x-axis).

Changes:

  • Added inline comments in plot.gg_variable() explaining why smoothing is skipped for factor predictors across families.
  • Added test coverage for binary classification, multi-class classification, and regression ensuring smooth=TRUE with factor predictors does not error.
  • Added assertions (in some cases) that the resulting plot has two layers (boxplot + jitter) with no smooth layer.

Reviewed changes

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

File Description
tests/testthat/test_gg_variable.R Adds tests asserting smooth=TRUE is a no-op with factor predictors and does not error.
R/plot.gg_variable.R Adds inline documentation clarifying intentional smoothing skip for factor predictors.

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

Comment thread tests/testthat/test_gg_variable.R Outdated
Comment thread tests/testthat/test_gg_variable.R Outdated
Comment thread tests/testthat/test_gg_variable.R Outdated
Comment thread tests/testthat/test_gg_variable.R Outdated
- Replace brittle `length(p$layers) == 2` with a direct GeomSmooth-absence
  check (has_smooth_layer helper) — the actual contract is "no smooth layer
  for a factor predictor", insensitive to benign layer-composition changes.
- Multi-class test now asserts no smooth layer too (was missing the check).
- Call plot() once per test via `expect_no_error(p <- plot(...))` instead of
  twice with identical args.
- Drop ntree 50 -> 25; model quality is irrelevant to these tests.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ehrlinger ehrlinger merged commit c580011 into main May 22, 2026
15 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.

2 participants