Fix CRAN compliance: par() on.exit() + self-contained donttest examples#20
Conversation
…ed examples
- Fix maxent_plot_response_curves: extract device+par management into
.maxent_safe_png() helper with proper on.exit() cleanup, avoiding
the loop-scope on.exit() anti-pattern.
- Make all \donttest{} examples self-contained with synthetic data so
R CMD check --run-donttest passes. Examples that were referencing
undefined objects (model, g1, g2, contrib, perm_imp, etc.) now
create their own data via runif(), data.frame(), and the package's
own constructors.
- Guard terra-dependent examples with requireNamespace('terra') so
they gracefully skip when terra is not installed (e.g. CRAN with
_R_CHECK_FORCE_SUGGESTS_=false).
- Regenerate man/ files via roxygen2.
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
| #' Defaults to all variables. | ||
| #' @param n_steps Integer: number of steps in each curve (default 100). | ||
| #' @param thumbnail Logical: also write a 210 × 140 pixel thumbnail PNG | ||
| #' @param thumbnail Logical: also write a 210 \times 140 pixel thumbnail PNG |
There was a problem hiding this comment.
🟡 Bare \times in Rd text is not a valid Rd macro; will cause R CMD check warning
The PR changed the Unicode × character to \times in the @param thumbnail roxygen comment at R/maxent_plots.R:19. However, \times is not a valid standalone Rd macro — it's only valid inside \eqn{}. The existing codebase already uses the correct pattern at R/grid_io.R:73: \eqn{\times}. This bare \times propagates into man/maxent_plot_response_curves.Rd:37 and will likely produce an R CMD check warning ("unknown macro '\times'"), which is ironic since this PR's goal is CRAN compliance.
| #' @param thumbnail Logical: also write a 210 \times 140 pixel thumbnail PNG | |
| #' @param thumbnail Logical: also write a 210 x 140 pixel thumbnail PNG |
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Good catch — already fixed in 6bdbdc9. Changed to plain x as suggested.
Summary
Fixes CI failures introduced by PR #18 (
\\dontrun{}→\\donttest{}). The core issue:\\donttest{}examples are actually executed duringR CMD check --run-donttest, but most maxentcpp examples referenced undefined objects (model,g1,g2,contrib, etc.) and crashed.Changes:
CRAN par() compliance —
maxent_plot_response_curveschangedpar()inside a loop withouton.exit(). Extracted device+par management into a.maxent_safe_png()internal helper with properon.exit()cleanup, avoiding the loop-scope on.exit anti-pattern.Self-contained examples — All
\\donttest{}examples that referenced undefined objects now create synthetic data viarunif(),data.frame(), and the package's own constructors (maxent_grid_from_matrix,maxent_featured_space, etc.).terra guard — Examples depending on
terra(a Suggests package) are wrapped inif (requireNamespace(\"terra\", quietly = TRUE))so they gracefully skip when terra is unavailable (e.g. CRAN with_R_CHECK_FORCE_SUGGESTS_=false).Regenerated man/ — All
.Rdfiles regenerated viaroxygen2::roxygenise().Files changed: 10 R source files + 23 man/ pages (33 total).
Review & Testing Checklist for Human
R CMD check --as-cranpasses on all CI platforms (ubuntu release/devel, macOS release, CRAN preflight).maxent_safe_png()helper correctly restorespar()even whenplot()errorsroxygen2::roxygenise()locally with roxygen2 7.3.3 to confirm no additional diffs from the version mismatch (this PR used 7.1.2)Notes
maxent_plot_variable_importanceandmaxent_write_prediction_pngalready had correcton.exit()— no changes needed there."Link to Devin session: https://app.devin.ai/sessions/3413d366498a4e738395d701b4866e1f
Requested by: @alrobles