Skip to content

Pass code arguments to the DEoptim objective without running them - #73

Merged
eliotmcintire merged 1 commit into
developmentfrom
fix/doCallQuoteLanguageArgs
Dec 4, 2026
Merged

eliotmcintire merged 1 commit into
developmentfrom
fix/doCallQuoteLanguageArgs

Conversation

@eliotmcintire

Copy link
Copy Markdown
Contributor

The MPB spread fit hands its objective a piece of code to run later, inside the objective. The fitting loop ran that code too early, in the main R session, so the fit stopped before any worker started.

Affects: fits whose objective takes a quoted expression (mpbRedTopSpread) now run; other fits are unchanged.

Technical details

.DEoptimChunk() (R/DEoptim.R:67) calls do.call(DEoptim::DEoptim, c(list(...), dotsList)), and .rescoreFn() (R/DEoptim.R:188) calls do.call(fn, c(list(par), args)). Without quote = TRUE, do.call() puts a language object such as quotedSpread = quote({...}) into the call as code. DEoptim then evaluated it when parApply() forced its ..., in the main process: "object 'massAttackRasStart' not found". Both calls now use quote = TRUE.

New test-DEoptimLanguageArgs.R passes a quoted stop() to an objective through each function. Both tests failed before the fix. test-DEoptimChunks, test-DEoptimRescore and test-DEoptimIterative pass.

🤖 Generated with Claude Code

.DEoptimChunk() and .rescoreFn() built the objective's call with do.call()
and no quote = TRUE, so a language argument (mpbRedTopSpread's quotedSpread)
was run as code in the main process.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@eliotmcintire eliotmcintire added bug Something isn't working backwards compatible Existing code and results keep working unchanged labels Dec 4, 2026
eliotmcintire added a commit to achubaty/mpbRedTopSpread that referenced this pull request Dec 4, 2026
…the cluster workers"

It treated a symptom: the quoted spread ran in the main process because
clusters' do.call() lacked quote = TRUE (PredictiveEcology/clusters#73). On
the workers it runs inside objFunInner, which sees the module's functions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Dec 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.23%. Comparing base (c43cb05) to head (5db1da2).
⚠️ Report is 1 commits behind head on development.

Additional details and impacted files
@@               Coverage Diff               @@
##           development      #73      +/-   ##
===============================================
+ Coverage        76.22%   76.23%   +0.01%     
===============================================
  Files               24       24              
  Lines             2145     2146       +1     
===============================================
+ Hits              1635     1636       +1     
  Misses             510      510              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@eliotmcintire
eliotmcintire merged commit e919431 into development Dec 4, 2026
14 checks passed
@eliotmcintire
eliotmcintire deleted the fix/doCallQuoteLanguageArgs branch December 4, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backwards compatible Existing code and results keep working unchanged bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant