Fixing behaviour of T Model with zero DBH values #525
+485
−100
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.
Description
Tip
OK - this is ready for review now.
Currently, if the DBH ($D$ ) of a stem is zero, then in the
StemAllometry
class:And in the
StemAllocation
class:That leads to all sorts of unexpected behaviour. We could make more sensible predictions when$D=0$ - which is what the first iteration of this PR did - but it basically doesn't make sense to make predictions when $D=0$ . That's actually a bit more work because we currently allow zero so this PR:
_enforce_positive_sizes
helper function topyrealm.demography.tmodel
The PR also:
StemAllometry
orCohorts
with negative DBH - this guarantees positive sizes and allows the per function validation to be skipped.Cohorts.dbh_values
a property raises ValueError when set with negative DBH values.Fixes #524
Type of change
Key checklist
pre-commit
checks:$ pre-commit run -a
$ poetry run pytest
Further checks