Generalize types to create NetworkModelResults#589
Draft
jpalm3r wants to merge 31 commits intojapr/network-supportfrom
Draft
Generalize types to create NetworkModelResults#589jpalm3r wants to merge 31 commits intojapr/network-supportfrom
jpalm3r wants to merge 31 commits intojapr/network-supportfrom
Conversation
- Updated NodeObservation class to allow creation of multiple observations by passing lists for node and item parameters. - Implemented auto-assignment of item indices when only nodes are provided and their count matches the number of data columns. - Added validation to ensure that the lengths of node, item, and name lists match when provided. - Enhanced documentation for NodeObservation to reflect new functionality. - Added unit tests to verify the new behavior, including auto-assignment and error handling for mismatched lengths.
…error handling for node input
Draft
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.
This pull request improves the flexibility and robustness of the network model input handling by allowing both
pandas.DataFrameandxarray.Datasettypes as input toNetworkModelResult, and by adding thorough validation and conversion logic. The changes primarily focus on input validation, error messaging, and making the codebase more extensible for future enhancements.Key changes:
Input validation and conversion:
_to_network_datasetfunction innetwork.pythat validates and converts inputs of typeNetworkType(eitherpd.DataFrameorxr.Dataset) to anxr.Dataset, with detailed type and structure checks for DataFrame inputs. This function raises clear errors for invalid input types or structures.Constructor enhancements:
NetworkModelResultconstructor to accept aNetworkType(instead of onlyxr.Dataset), using the new_to_network_datasetfunction to ensure the input is properly validated and converted before further processing.Notebook demonstration:
Collection_systems_network.ipynbto display the node values from the network model, likely as part of demonstrating or testing the improved input handling.