Refactor layeringMod.py - #224
Open
mxkpp wants to merge 66 commits into
Open
Conversation
…tarting with _values dict
…fix namespace error, remove call to `validate_config` (validation occurs automatically in new design)
…ly if rqiMethod is 0 (unused) then rqiThresh property now resolves to None regardless of the value of the RqiThresh key in the config file.
…s tests relative to refactored class structures and new key exclusions in test utils
…scretization type
… by discretization type
Author
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.
layeringMod.pyfunctionslayer_final_forcingsandlayer_supplemental_forcingeach have been refactored into 1 abstract parent class, each implemented by a child class for each discretization type: "gridded", "unstructured", "hydrofabric".Note on review and testing: the "hydrofabric" case is covered by the ngen-forcing pytest suite, and it was tested. However the "gridded" and "unstructured" cases are not covered by the ngen-forcing pytest suite. For those 2 types, their before-and-after logic was reviewed without testing.
Benefits of This Improvement:
Clearly separate the variations in how the different discretization types are handled: "gridded", "unstructured", "hydrofabric". Previously the logic branching had been implemented via large
if/elif/elifblocks.DRYify repeated logic into shared methods, improving readability and allowing future changes to be done more easily and safely with minimal copy-pasting.
For the "unstructured" case, which interacts with the "*_elem" (element) variants of various forcing engine attributes, the original implementation of those _elem interactions was further copy-pasted blocks of the non-_elem attr handling. In the refactored code, the attr suffix is parameterized to further DRYify and avoid needing an
ifconditional for the "unstructured" case.New Classes
_LayeringMod: abstract parent for performinglayer_final_forcingsoperations. Implemented by children:_LayeringMod_Gridded_LayeringMod_Unstructured_LayeringMod_Hydrofabric_LayeringModSupplemental: abstract parent for performinglayer_supplemental_forcingoperations. Implemented by children:_LayeringModSupplemental_Gridded_LayeringModSupplemental_Unstructured_LayeringModSupplemental_HydrofabricAdditions
Removals
Changes
Testing
The ngen-forcing pytests ran successfully, confirming that the particular configurations covered by those tests are producing the same numerical and classification outputs as before the refactor. Note that these tests do not cover every possible way of running the forcing engine, and for the choices of discretization types, they only cover the "hydrofabric" case. The tests do not cover the "gridded" case nor the "unstructured" case.
Screenshots
Notes
Todos
Checklist
Testing checklist
Target Environment support