Skip to content

Run without Biomass_speciesData in study areas with no tree species - #140

Merged
eliotmcintire merged 1 commit into
developmentfrom
fix/null-speciesLayers-fallback
Oct 15, 2026
Merged

eliotmcintire merged 1 commit into
developmentfrom
fix/null-speciesLayers-fallback

Conversation

@eliotmcintire

Copy link
Copy Markdown
Collaborator

When Biomass_speciesData is not in a project, this module makes the species cover maps itself. In a study area with no tree species that step stopped the run. Now it carries on, as it already does when Biomass_speciesData supplies the maps.

Affects: projects that leave out Biomass_speciesData no longer fail in non-forested study areas; nothing else changes.

Technical details

prepSpeciesLayers_SCANFI() returns NULL when there are no species (LandR R/maps.R, loadSCANFISpeciesLayers()). .inputObjects then called NAcover2zero(NULL, ...) (Biomass_borealDataPrep.R:1919), which errors: unable to find an inherited method for function 'cover' for signature 'x = "NULL"'. The fix skips that call for NULL. The noSpecies branch in init already handles NULL, which is what Biomass_speciesData passes in this case (Biomass_speciesData.R:242).

New test tests/testthat/test-speciesLayersFallback.R evaluates the fallback block from the module source with prepSpeciesLayers_SCANFI() mocked to return NULL. It fails without the fix.

🤖 Generated with Claude Code

With no Biomass_speciesData, .inputObjects builds speciesLayers from
prepSpeciesLayers_SCANFI(), which returns NULL for an ELF with no tree
species. NAcover2zero() then errored on NULL. Skip it; init's
no-species branch already expects NULL.

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 Oct 15, 2026
@eliotmcintire
eliotmcintire merged commit b04c31c into development Oct 15, 2026
6 checks passed
@eliotmcintire
eliotmcintire deleted the fix/null-speciesLayers-fallback branch October 15, 2026 19:59
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