Repository navigation
[com4FlowPy] Fix issue #1344 - #1348
Merged
Merged
Conversation
Contributor
fso42
requested changes
Nov 9, 2026
fso42
left a comment
Contributor
There was a problem hiding this comment.
This adds backwards incompatible code (checkInputParameterValues now takes an extra argument). Please highlight this in the PR summary, as external calles must update this
PaulaSp3
requested changes
Nov 9, 2026
ahuber-bfw
force-pushed
the
AH_com4FlowPy_issue1344
branch
from
November 10, 2026 10:58
e6dc6bc to
b0628b0
Compare
PaulaSp3
approved these changes
Nov 10, 2026
fso42
approved these changes
Nov 10, 2026
added forest input parameter checks in com4FlowPy.py deleted main entryPoints from com4 pytests and added tests for forest input parameter checks linting issues addressed comments FSO addressing review comments PS
fso42
force-pushed
the
AH_com4FlowPy_issue1344
branch
from
November 10, 2026 12:36
b0628b0 to
07a2647
Compare
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.
PR Summary
com4FlowPy.checkInputParameterValues()for external callers, since the updated function now expects an additional inputforestParamsifmodelParams['forestBool']- ifmodelParams['forestBool'] == Falsethen the legacy behaviour is unchanged.This PR fixes issue #1344 and also applies a Bugfix previously applied in the python engine (PR #1342) to the numba engine (fixed typo in calculation of 3D distances).
Summary of Changes
orig PR
684ea5cbef93b3afc9c8a69dPR review
40c91e90b2e3932b0628b0eChanged files:
avaframe/com4FlowPy/com4FlowPy.pyavaframe/com4FlowPy/flowCoreNumba.pyavaframe/tests/test_com4FlowPy.pyavaframe/tests/test_com4FlowPyNumba.py1. Forest input parameter checks (
com4FlowPy.py)added new input data checks for forestModule related input parameters and data to
com4FlowPy.checkInputParameterValues(), that is triggered when 'forestBool' is set.added checks - grouped by
forestModule:skipForestDist >= 0.alphaMaxis taken from the globalalpha, or — whenvarAlphaBoolis true — as themaximum of the variable-alpha raster inside the release-area mask.
forestModulemust be in['forestFriction', 'forestDetrainment', 'forestFrictionLayer']forestFriction/forestDetrainment[0, 1](cells withFSI <= 0are masked out, matching theexisting
flowClass.pyconvention).alphaMax + maxAddedFriction < 90(total friction must not reach 90°).velThForFriction >= 0.minAddedFriction <= maxAddedFriction.velThForDetrain >= 0,minDetrainment <= maxDetrainment, and bothdetrainment bounds within
[0, 1].forestFrictionLayervelThForFriction >= 0.forestFrictionLayerType == "absolute": layer values within[0, 90].forestFrictionLayerType == "relative":0 <= alphaMax + max(layer) < 90.ValueError.All failures raise
ValueErrorwith a message naming the offending parameter and config key.On success, a short summary is written to the log.
2. Numba engine bug fix (
flowCoreNumba.py)The 3D minimum-distance calculation in the numba engine
flowCoreNumba.py-_bfs_single()useddytwice(
sqrt(dy² + dy² + dz²)), replicating an upstream Bug offlowClass.calcDistMin().It now uses
sqrt(dx² + dy² + dz²), mirroring the fix already onmasterinflowClass.py(issue #1341). This affects the
skipForestDistgate in the Numba engine.3. Tests (
test_com4FlowPy.py,test_com4FlowPyNumba.py)test_com4FlowPy.pymakeForestParameters(),makeForestModelPaths()and_makeForestReadRaster()to build valid inputs and fakeIOf.readRaster.checkForestInputParameters()covering all three forest modules, bothglobal and variable alpha, all valid branches, and the invalid cases (out-of-range FSI,
friction/detrainment limits, unknown layer type, negative thresholds), using
pytest.mark.parametrize.if __name__ == "__main__":block that re-ran a hand-picked subset of tests.pytesttest_com4FlowPyNumba.pyif __name__ == "__main__":block.pytest4. Main Changes
ValueError()instead of failing silently or producing unintended results.PR Checklist
Please confirm before requesting review:
pytestlocally without failsConfirm before the final merge/rebase into master