Convert do.call calls to ParmOff#16
Conversation
…gtri Agent-Logs-Url: https://github.com/asgr/magicaxis/sessions/b1365e3a-b831-4f58-913b-b006daa3c6c6 Co-authored-by: asgr <5617132+asgr@users.noreply.github.com>
asgr
left a comment
There was a problem hiding this comment.
Add relevant unit tests and create a long form vignette magicaxis.Rmd that uses fig.width and fig.height of 6.
Agent-Logs-Url: https://github.com/asgr/magicaxis/sessions/e8cd5243-668b-401a-936b-63f792e6d411 Co-authored-by: asgr <5617132+asgr@users.noreply.github.com>
Done in 523981a. Added:
Also updated |
… ways to envoke magaxis inside magplot since there are subtle issues with argument clashes.
…thub.com/asgr/magicaxis into copilot/convert-do-call-to-parmoff-again
There was a problem hiding this comment.
Pull request overview
This PR replaces internal do.call dispatch with ParmOff::ParmOff, adds package/test/vignette infrastructure for the new dependency, and expands magtri() argument routing so top-level ... can reach plotting subcalls.
Changes:
- Adds
ParmOffimports plus testthat/vignette dependencies. - Converts plotting helper dispatch in
magaxis,magplot,magbin,magimage,magimageRGB, andmagtri. - Adds ParmOff routing tests and a new long-form vignette.
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
.gitignore |
Ignores .positai. |
DESCRIPTION |
Bumps package version and adds ParmOff/test/vignette dependencies. |
NAMESPACE |
Imports ParmOff and points.default. |
R/magaxis.R |
Replaces axis/mtext dispatch with ParmOff. |
R/magbin.R |
Replaces magmap/magplot/magbar dispatch with ParmOff. |
R/magcon.R |
Passes only x/y/z components into magimage. |
R/magimage.R |
Replaces image dispatch with ParmOff. |
R/magimageRGB.R |
Replaces image dispatch with ParmOff. |
R/magplot.R |
Replaces maghist/magmap/points/magbar dispatch with ParmOff. |
R/magtri.R |
Routes ... through ParmOff to magaxis, magcon, and points calls. |
man/magaxis.Rd |
Removes an extra blank line. |
man/magmap.Rd |
Removes an extra blank line. |
tests/testthat.R |
Adds testthat entry point. |
tests/testthat/test-parmoff-routing.R |
Adds routing/rendering regression tests. |
vignettes/magicaxis.Rmd |
Adds a package vignette documenting plotting helpers and ParmOff routing. |
Comments suppressed due to low confidence (1)
R/magplot.R:222
- The standard scatter branch no longer passes
...intomagaxis(), which regresses existingmagplot(..., cex.axis=..., col.axis=..., cex.lab=...)usage for custom axes. Since the baseplot()call hasaxes = FALSE, these axis styling arguments are not applied elsewhere.
axis.col = axis.col
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ParmOff(mtext, c(list(text=xlab, side=ifelse(side[1] %in% c(1,3), side[1], side[2]), line=mtline[1]), dots), .use_args = keepmtext) | ||
| } | ||
| if(is.null(ylab)==FALSE){ | ||
| do.call("mtext", c(list(text=ylab, side=ifelse(side[2] %in% c(2,4), side[2], side[1]), line=mtline[2]), dotsmtext)) | ||
| ParmOff(mtext, c(list(text=ylab, side=ifelse(side[2] %in% c(2,4), side[2], side[1]), line=mtline[2]), dots), .use_args = keepmtext) |
| ticks.lwd = ticks.lwd, | ||
| axis.col = axis.col, | ||
| ... | ||
| axis.col = axis.col |
| dots_carry = ParmOff(magaxis, dots, side=1:2, grid=grid, grid.col='lightgrey', labels=FALSE, do.tick=do.tick, .pass_dots=FALSE, .return='func_args')$args_out$ignore_args | ||
| ParmOff(points.default, dots_carry, x=chains[usesamps,i], y=chains[usesamps,j], pch='.', col='darkgrey', .pass_dots=TRUE) | ||
| ParmOff(points.default, dots_carry, x=meanvec[i], y=meanvec[j], col='red', pch=4, cex=2, .pass_dots=TRUE) |
| expect_no_error(magaxis(side = 1:2, xlab = "X axis", ylab = "Y axis", | ||
| cex.lab = 1.2, col.lab = "darkred")) |
| test_that("magtri accepts pch forwarded to points without error", { | ||
| with_null_dev({ | ||
| set.seed(10) | ||
| chains <- data.frame(x = rnorm(200), y = rnorm(200), z = rnorm(200)) | ||
| expect_no_error(magtri(chains, samples = 100, pch = 16)) | ||
| }) |
asgr
left a comment
There was a problem hiding this comment.
All good. I need to get ParmOff onto CRAN before magicaxis can be updated on CRAN.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Replaces all
do.callcalls across the package withParmOff::ParmOff, and improves argument routing inmagtriso that...is forwarded tomagaxis,magcon, andpointsinstead of onlymagcon.Changes
Package infrastructure
ParmOfftoImportsinDESCRIPTIONwith aRemotes: asgr/ParmOffentryimportFrom("ParmOff", "ParmOff")toNAMESPACEtestthat (>= 3.0.0),knitr, andrmarkdowntoSuggestsVignetteBuilder: knitrandConfig/testthat/edition: 31-to-1
do.call→ParmOffreplacements (no behaviour change)magaxis.R—axis(×6) andmtext(×2) callsmagplot.R—maghist,magmap,points,magbarcallsmagbin.R—magmap(×3),magplot(×2),magbarcallsmagimage.R—imagecallmagimageRGB.R—imagecallmagtri.R— the main improvementPreviously, all
...passed tomagtri()were forwarded exclusively tomagcon. Now adots = list(...)is collected once and routed viaParmOffto every sub-function call:magaxis(…)(all panels)...magcon(…)......(ParmOff deduplicates)points(…)...This means callers can now do things like:
ParmOff's argument merging ensures user-supplied values override the defaults while avoiding duplicate-argument errors that the old
do.call(func, c(list(fixed), dots))pattern would throw.Tests and vignette
tests/testthat/test-parmoff-routing.Rwith 15 unit tests covering ParmOff argument routing throughmagaxis,magplot,magmap,magbin/plot.magbin,magimage, andmagtri(including forwardingcex.axis→magaxis,lty→magcon,pch→points).vignettes/magicaxis.Rmd, a long-form vignette withfig.width = 6/fig.height = 6throughout, coveringmagaxis,magplot,maghist,magcon,magbin,magimage, andmagtri; includes a dedicated section demonstrating the new ParmOff-based argument routing inmagtri.