From 587c1a514ca1fbbc3896b3c30b9d4cf2d0af237d Mon Sep 17 00:00:00 2001 From: Eliot McIntire Date: Fri, 13 Nov 2026 16:36:49 -0700 Subject: [PATCH] Document the 0.001 minimum of lowerAsymptote The check is fireSenseUtils::checkLinkParams(); the tests use the minimum instead of 0 and expect 0 to stop. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6 --- fireSense_spreadPredict.R | 2 +- tests/testthat/test-smoothLinks.R | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/fireSense_spreadPredict.R b/fireSense_spreadPredict.R index 5c9e2b6..d36bcaf 100644 --- a/fireSense_spreadPredict.R +++ b/fireSense_spreadPredict.R @@ -108,7 +108,7 @@ defineModule(sim, list( "linear predictor, as the fit does. \"powerLaw\": `pc` (the row's", "`maxAsymptote`), `gamma`, `floor` (`lowerSpreadProb`) and `shape` of", "`fireSenseUtils::powerLawLink()`; \"powerLawSmooth\" also `lower` (the row's", - "`lowerAsymptote`); \"richards\": `pc`, `lower`, `nu` (the row's `richardsNu`) and `B`.", + "`lowerAsymptote`, at least `fireSenseUtils::spreadLowerAsymptoteMin`, 0.001: `fireSenseUtils::checkLinkParams()`); \"richards\": `pc`, `lower`, `nu` (the row's `richardsNu`) and `B`.", "A numeric vector with one fitted ELF; with several, a raster with one layer per name,", "blended like `fireSense_SpreadSD`.")), createsOutput(objectName = "fireSense_SpreadLinear", objectClass = "SpatRaster", diff --git a/tests/testthat/test-smoothLinks.R b/tests/testthat/test-smoothLinks.R index 905dcd3..373464a 100644 --- a/tests/testthat/test-smoothLinks.R +++ b/tests/testthat/test-smoothLinks.R @@ -29,7 +29,7 @@ xSL <- function() { } test_that("a powerLawSmooth row predicts the smooth link with its gamma and lower asymptote", { - for (L in c(0, 0.05, 0.13)) { + for (L in c(fireSenseUtils::spreadLowerAsymptoteMin, 0.05, 0.13)) { sim <- toyRun(inputsSL("powerLawSmooth", lower = L, gamma = 3)) v <- predVals(sim) expect_equal(v[cellsSL], fireSenseUtils::powerLawSmoothLink(xSL(), 0.25, 3, 0.13, 1, L), tolerance = 1e-9) @@ -84,6 +84,8 @@ test_that("rows without the columns their link needs stop; the helpers read the sa <- inputsSL("powerLawSmooth")$studyAreaWithSpreadParams sa[[lowerColSL]] <- 0.5 expect_error(ledgerLowerAsymptote(sa, 1L), "lowerAsymptote must be") + sa[[lowerColSL]] <- 0 # a lower asymptote of 0 is never accepted + expect_error(ledgerLowerAsymptote(sa, 1L), "never 0") sa[[lowerColSL]] <- NULL expect_error(ledgerLowerAsymptote(sa, 1L), "lowerAsymptote must be") expect_null(ledgerRichardsNu(inputsSL("powerLawSmooth")$studyAreaWithSpreadParams, 1L)) @@ -96,13 +98,13 @@ test_that("with several ELFs of one new link the parameters blend; with differen ins <- multiInputs() ins$studyAreaWithSpreadParams$params <- lapply(ins$studyAreaWithSpreadParams$params, function(p) { p$MDC <- 1; p }) ins$studyAreaWithSpreadParams[[linkColSL]] <- c("richards", "richards") - ins$studyAreaWithSpreadParams[[lowerColSL]] <- c(0, 0.1) + ins$studyAreaWithSpreadParams[[lowerColSL]] <- c(fireSenseUtils::spreadLowerAsymptoteMin, 0.1) ins$studyAreaWithSpreadParams[[nuColSL]] <- c(0.5, 2) sim <- toyRun(ins, params = list(ELFblendWidth = 20000)) pl <- sim$fireSense_SpreadPowerLaw expect_identical(names(pl), c("pc", "lower", "nu", "B")) lo <- terra::values(pl[["lower"]], mat = FALSE) - expect_equal(lo[1], 0); expect_equal(lo[10], 0.1) + expect_equal(lo[1], fireSenseUtils::spreadLowerAsymptoteMin); expect_equal(lo[10], 0.1) expect_identical(sim$fireSense_SpreadLink, "richards") ins$studyAreaWithSpreadParams[[linkColSL]] <- c("richards", "powerLawSmooth") ins$studyAreaWithSpreadParams[[gammaColSL]] <- c(NA, 2)