Remove dead code, document functions, correct Rmd - #12
Merged
Merged
Conversation
No behaviour change: only commented-out code, an if (FALSE) block, comments, desc strings and Rmd text are touched. Several input descs had been passed positionally into sourceURL; they are now in desc. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Adds tests for `ageNonForest()`, `getCurrentClimate()`, `Init()`/`init`,
`.inputObjects()` and the two covariate-assembly events, on a 4x4 toy
landscape whose every covariate can be worked out by hand. The toy climate
encodes both the year and the cell in its values, so an assertion on a value
proves which layer of which variable was taken.
99 assertions, no skips. Verified to pass identically on `origin/development`
and on this branch, run the way CI runs them (convertToPackage + test_local).
Every substantive test was mutation-checked: 14 mutations of the module
source, 14 detected.
Five defects are recorded, none of them blessed as correct: each states the
INTENDED assertion wrapped in `expect_failure()` so that fixing the defect
trips the test, plus an assertion pinning the current state.
- `.inputObjects` leaves `rstLCC_RTM` NULL: the `suppliedElsewhere("rstLCCs")`
branch does `tail(sim$rstLCCs, 1)[[1]]`, but `rstLCCs` is not a declared
input and so is absent. `Init()` then errors on `.compareRas(rtm, NULL)`,
which makes the module unusable as shipped.
- `.inputObjects` cannot build `flammableRTM`: `defineFlammable(rstLCC, ...)`
uses a local from the other branch and a function the module does not import.
- The covariate tables do not advance with simulation time: `getCurrentClimate()`
only builds `currentClimateRasters` when it is NULL, so from year two on the
climate is frozen at `start(sim)` while the `year` column still tracks
`time(sim)` -- the table claims 2003 and carries 2001 climate.
- `climateYear` does not override `time(sim)`: the inner lapply's formal
`currentYear = time(sim)` shadows the outer `currentYear`.
- `lightningDays` is NaN in the ignition table.
- `Init()` realigns landcover with bilinear `postProcess()`, averaging
categorical class codes into non-classes and silently yielding an all-NA
landcoverDT.
They are pinned observations of fireSenseUtils internals, identical on origin/development and on this branch, not hand-derived truths.
…; add empty save event Removed, never read: parameters .plotInitialTime, .plotInterval, .saveInitialTime, .saveInterval; input fireSense_IgnitionFitted and its check in .inputObjects, which only ran for a Fit module name. whichModulesToPrepare now defaults to the three Predict modules that doEvent tests for. It named fireSense_EscapeFit, which nothing tests for. The save event emits a message and does nothing else. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013B4sgRg9EwyHaAQdDzUaQW
eliotmcintire
added a commit
that referenced
this pull request
Sep 21, 2026
…Rasters alone Merge #12 first; this branch now contains it. Conflicts and how each was resolved: - inputs metadata: #12's text and removals, with #13's climateYear class ("numeric") and the new rstLCCs input. - getCurrentClimate() guard: #13's code. The two dead comments #12 removed stay removed. - getCurrentClimate() assignment: #13's mod$currentClimateYear line, without the dead trailing comment. - .inputObjects rstLCC block, both ends: #13's if (!suppliedElsewhere("rstLCC_RTM", sim)) wrapper. - tests/testthat/test-getCurrentClimate.R: every test from both sides. #12's climateYear expect_failure pin is replaced by #13's test of the fix. Correction to #13's stale-climate fix: the guard was keyed on the year alone, so it rebuilt currentClimateRasters from projectedClimateRasters even when another module had supplied it. In the project the climateYear module supplies it every year, preferring historical rasters. Now a supplied object is left alone, and only an object this module built is rebuilt when the year changes (mod$builtCurrentClimate). New test: supplied every year, left untouched, and the covariate tables carry the supplied values. It fails on #13 as pushed. #12's expect_failure pins for the defects fixed here are now ordinary expectations: rstLCC_RTM from rstLCCs, flammableRTM in .inputObjects, nearest-neighbour landcover, covariates advancing each year. The toy helper's rstLCC_RTM workaround is gone. The lightningDays pin stays; it is not fixed. "the climate rasters are rebuilt when the year changes" now runs through spades(), because mod only persists there. Removed propFlammable (input and assignment): nothing reads it. Version 1.0.4.9000. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013B4sgRg9EwyHaAQdDzUaQW
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.
Removes the commented-out code and an
if (FALSE) {...}block inprepare_IgnitionAndEscapePredict(), adds short roxygen docs to every function, corrects the parameter/input/outputdescstrings, and fills in the Rmd (summary, events, links), which was still the template. Behaviour is unchanged: with comments ignored, every function parses identical todevelopmentexcept for the deletedif (FALSE)block, and parameter names, classes and defaults and input/output names and classes are identical. One metadata change to note: 12 inputs had their description passed positionally intosourceURL, leavingdescasNA; the text is now indescandsourceURLisNA.tests/testthatpasses. The.md/.htmlare left for the render workflow.Removed functions: none (the only dead one,
getRequiredFuelClasses, was already commented out).Possibly unused, kept:
.plotInitialTime,.plotInterval,.saveInitialTime,.saveInterval,.useCache: never read.fireSense_IgnitionFitted: only checked in.inputObjects, and only ifwhichModulesToPreparehasfireSense_IgnitionFit.climateYear: only read in a check whose result (time) is never used; the layer taken is alwaysyear<time(sim)>.propFlammable: set in.inputObjects, never read.timeStepofageNonForest(): not used; TSD always increases by 1.Seen, not changed:
whichModulesToPreparedefaults tofireSense_EscapeFit, but the code tests forfireSense_EscapePredict..inputObjectscallsdefineFlammable(rstLCC, ...);rstLCCdoes not exist whenrstLCCsis supplied, and is a list otherwise.P(sim)$.studyAreaName,sim$studyAreaandsim$rstLCCsare used but not declared in the metadata.🤖 Generated with Claude Code
Tests (added in
3927403)A testthat suite on a 4x4 toy landscape where every covariate is hand-computable. The toy climate encodes both the year and the cell in its values (
year<Y>MDC cell n =(Y-2000)*100 + n,Tmaxits negative), so asserting a value proves which layer of which variable was taken.99 assertions, 0 failures, 0 skips. Verified to pass identically on
origin/developmentand on this branch, run the way CI runs them (convertToPackage()+pkgload::load_all()+test_local()). Every substantive test was mutation-checked by breaking the module source and confirming the test fails: 14 mutations, 14 detected.test-metadata.Rtest-ageNonForest.RtimeStepignoredtest-getCurrentClimate.RcompareGeomguards, supplied-raster passthrough, reuse messagetest-init.RclimateVariablesForFireexpansion,landcoverDTconstruction, event scheduling perwhichModulesToPreparetest-inputObjects.RclimateVariablesForFire; two defects belowtest-covariates.RyoungAge,igAggFactoraggregation andigAggFactor = 1,missingLCCgroup, fuel-class pinsDefects recorded, not blessed
Each states the intended assertion wrapped in
expect_failure()-- so fixing the defect trips the test and forces the assertion to be unwrapped -- plus an assertion pinning the current state. No test asserts that buggy behaviour is correct..inputObjectsleavesrstLCC_RTMNULL. ThesuppliedElsewhere("rstLCCs", sim)branch (l.509-510) doestail(sim$rstLCCs, 1)[[1]], butrstLCCsis not a declared input, so it is absent from the simList and the result is NULL. ArstLCC_RTMpassed tosimInit()is overwritten by this.Init()(l.241) then errorssubscript out of boundson.compareRas(rtm, NULL)-- the module cannot completeinitas shipped. The test helper restoresrstLCC_RTMaftersimInit()so the rest of the suite can exercise the code past this point..inputObjectscannot buildflammableRTM(l.546):defineFlammable(rstLCC, ...)uses a local created only in the other branch, and the function is not imported.getCurrentClimate()(l.296) only buildscurrentClimateRasterswhen itis.null(). The event reschedules annually, but from year two the object is populated and the build is skipped, so climate is frozen atstart(sim)-- while theyearcolumn does tracktime(sim). Running 2001->2003 yields a table labelled 2003 carrying 2001 climate.climateYeardoes not overridetime(sim). The innerlapplyformalcurrentYear = time(sim)(l.322) shadows the outercurrentYear(l.309-313).climateYearonly reaches the "beyond the projection" message.lightningDaysis NaN in the ignition table. The layer is selected correctly (sim$lightningMaps["lightningDays"], l.416, returns the right values -- checked directly); the loss is insidefireSenseUtils::mergePreparedCovs(). Not diagnosed further.Init()destroys categorical landcover on realignment. l.241-245 usespostProcess(..., to = rasterToMatch), which defaults to bilinear resampling; averaging class codes 19/16/210/20 gives values like186.125and43.91, which match no class, somakeLandcoverDT()returns an all-NAlandcoverDT-- silently, with the right rows and column names. Fix ismethod = "near".Also confirmed: with the shipped
whichModulesToPreparedefault (fireSense_EscapeFit), onlygetClimateRastersandageNonForestare scheduled and no covariate table is produced at all.Honest labelling
The fuel-class magnitudes in
test-covariates.Rare a regression pin onfireSenseUtilsinternals, labelled as such -- not hand-derived. (The previous draft claimed they were "pinned fromorigin/development"; that claim was false and has been removed. They are in fact identical on both branches, verified by running the suite against each.)Update (
cbace6d)This replaces "Possibly unused, kept" and the
whichModulesToPreparenote above.Removed; stop setting these:
.plotInitialTime,.plotInterval,.saveInitialTime,.saveIntervalfireSense_IgnitionFittedKept:
.useCache(SpaDES.core reads it),climateYear(#13 makes it work),propFlammable(its only line is inside the block #13 rewrites; remove it after #13).whichModulesToPreparenow defaults tofireSense_SpreadPredict,fireSense_IgnitionPredictandfireSense_EscapePredict. These are the three namesdoEventtests for.The
saveevent now emits a message and does nothing else. The module never schedules it.The version is not bumped here because #13 changes the same line.