adjustSizeGrid(): warn on per-species diet loss instead of resource biomass#453
Merged
Conversation
The high-end resource truncation check previously warned when
non-negligible resource *biomass* was discarded above the new maximum
size. Biomass loss is not the relevant quantity: what matters is whether
truncation changes the food a fish actually gets. This replaces that
check with a per-species diet-loss check, mirroring the existing low-end
check, evaluated at the largest size each species occupies (where the
largest resource matters most). It reports the fraction of the fish's
total encounter that is lost.
The low-end and high-end resource checks now use consistent wording
("diet of smallest/largest fish ... lost due to resource truncation"),
and the tol documentation makes clear that all three checks (biomass,
smallest-fish diet, largest-fish diet) are applied separately to each
species.
Lost fractions are now reported with 3 significant figures rather than
two decimal places, so a loss just above the default tol = 1e-6 shows as
0.0001% instead of 0.00%.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
Reworks the resource-truncation warnings in
adjustSizeGrid()so they report what actually matters for the model dynamics — how much of each species' food (encounter) is discarded — rather than resource biomass.Changes
High-end resource truncation now warns on diet loss, not resource biomass. The previous check warned when a non-negligible fraction of resource biomass was discarded above the new maximum size. Biomass loss is not the relevant quantity: encounter feeds growth and reproduction only through the fish's total food intake. The new check mirrors the existing low-end (smallest-fish) check but is evaluated at the largest size each species occupies, where the largest resource particles matter most. It reports the lost resource encounter as a fraction of that fish's total encounter.
Consistent wording. The low-end and high-end messages now read symmetrically — "Non-negligible diet of smallest/largest fish was lost due to resource truncation: ...". Both are the same kind of ratio (lost resource encounter ÷ total encounter), sampled at the most-exposed fish size for the part of the resource being removed.
Per-species clarity in the docs. The
tolparameter documentation now states explicitly that all three checks — species biomass, smallest-fish diet, largest-fish diet — are applied separately to each species, and the warning lists the affected species.More useful precision. Lost fractions are reported with 3 significant figures (
%gofsignif(x, 3)) instead of two decimal places. With the defaulttol = 1e-6, a loss just above threshold now shows as0.0001%rather than the uninformative0.00%.Testing
testthat::test_file("tests/testthat/test-manipulate_species.R")— all 137 tests pass. The existing high-end-truncation test was updated to expect the new largest-fish diet message.🤖 Generated with Claude Code