Replace ProSpectSEDlike manual parameter plumbing with ParmOff#31
Open
Copilot wants to merge 2 commits into
Open
Replace ProSpectSEDlike manual parameter plumbing with ParmOff#31Copilot wants to merge 2 commits into
ProSpectSEDlike manual parameter plumbing with ParmOff#31Copilot wants to merge 2 commits into
Conversation
Agent-Logs-Url: https://github.com/asgr/ProSpect/sessions/20970253-fcc0-468d-9a54-4254b92e17f4 Co-authored-by: asgr <5617132+asgr@users.noreply.github.com>
asgr
approved these changes
May 14, 2026
Owner
asgr
left a comment
There was a problem hiding this comment.
All good with the switch to ParmOff
There was a problem hiding this comment.
Pull request overview
This PR refactors ProSpectSEDlike() to delegate parameter bounds and log-space transforms, plus ProSpectSED argument dispatch, to ParmOff, aiming to remove manual parameter “plumbing” and better support logical-vector .logged.
Changes:
- Added a
ParmOff-based preprocessing step to generate the final scalar parameter vector passed intoProSpectSED. - Replaced both
do.call("ProSpectSED", ...)sites withParmOff::ParmOff(..., .return = "func")to centralize argument matching/filtering. - Updated photo-z “z is logged” handling to use name-based
logged_parm_names.
Comments suppressed due to low confidence (2)
R/ProSpect.R:644
scat_scaleextraction currently usesparmlistbeforeparmlistis created by theParmOff::ParmOff(..., .return='args')call, which will error on the first evaluation whenscat_scaleis inData$parm.names. Extractscat_scalefrom the (possibly constrained/bounded/logged) parameter vector after it’s been processed, or processscat_scaleseparately before building the ProSpectSED argument list.
This issue also appears on line 649 of the same file.
if('scat_scale' %in% Data$parm.names){
sel = which('scat_scale' == Data$parm.names)
scat_scale = parmlist[sel]
parmlist = parmlist[-sel]
Data$parm.names = Data$parm.names[-sel]
R/ProSpect.R:656
- After removing
scat_scalefromData$parm.names,parm_lower/parm_upperare still created fromData$intervals$lo/hi(which likely still includescat_scale). Assigningnames(parm_lower) = Data$parm.nameswill fail if the lengths differ. Buildparm_lower/upperfrom the same set of parameters you intend to pass toParmOff(or dropscat_scalefrom the intervals before converting/naming).
parm_lower = NULL
parm_upper = NULL
if (!is.null(Data$intervals)) {
parm_lower = as.list(Data$intervals$lo)
parm_upper = as.list(Data$intervals$hi)
names(parm_lower) = Data$parm.names
names(parm_upper) = Data$parm.names
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ProSpectSEDlikewas still manually handling argument dispatch, bounds (lower/upper), and log-space transforms (logged), which diverged from currentParmOffcapabilities (including logical-vector.logged). This updates the likelihood path to useParmOffas the single parameter/dispatch mechanism with.check = FALSE.Parameter transform/bounds delegation
ParmOff::ParmOff(..., .return = "args", .check = FALSE)preprocessing step to produce the final scalar parameter vector used by the model call.Data$loggedto name-based selection so both scalar and logical-vector cases are handled consistently (includingzin photo-z mode).ProSpectSEDinvocation delegationdo.call("ProSpectSED", ...)call sites (returnall = TRUE/FALSE) withParmOff::ParmOff(.func = ProSpectSED, .return = "func", .check = FALSE).SFH,speclib,Dale,AGN,filtout,returnall,Data$arglist), while centralizing argument matching and filtering throughParmOff.Behavior-preserving guardrails
Data$constraintsapplication order before bounds/log transforms.scat_scale, likelihood, monitor, and return-shape behavior intact.ParmOffarg extraction.