Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Edge duplication validation #1857

Open
visr opened this issue Oct 1, 2024 · 1 comment
Open

Improve Edge duplication validation #1857

visr opened this issue Oct 1, 2024 · 1 comment
Labels
python Relates to one of the Ribasim python packages ribasim-nl Related to Ribasim NL project validation Related to model validation

Comments

@visr
Copy link
Member

visr commented Oct 1, 2024

This edge validation error is not correct:

image

It states a certain edge already exists, but it doesn't. There is another duplicate edge that is already present.
If a user only adds edges with the add API in the current version you cannot get here, but this is an existing model with duplicate edges.
We should amend #1765 for this case.

Found by @DanielTollenaar.

@visr visr added python Relates to one of the Ribasim python packages validation Related to model validation labels Oct 1, 2024
@evetion evetion added the ribasim-nl Related to Ribasim NL project label Oct 8, 2024
@visr
Copy link
Member Author

visr commented Oct 14, 2024

In AmstelGooienVecht_parametrized_2024_10_1 this error in the validation code also popped up:

File D:\repo\ribasim\Ribasim\python\ribasim\ribasim\model.py:402, in Model._has_valid_neighbor_amount(self, df_graph, edge_amount, edge_type, nodes)
    [400](file:///D:/repo/ribasim/Ribasim/python/ribasim/ribasim/model.py:400) # loop over all the "to_node" and check if they have enough inneighbor
    [401](file:///D:/repo/ribasim/Ribasim/python/ribasim/ribasim/model.py:401) for _, row in to_node_info.iterrows():
--> [402](file:///D:/repo/ribasim/Ribasim/python/ribasim/ribasim/model.py:402)     if row["to_node_count"] < edge_amount[row["to_node_type"]][0]:
    [403](file:///D:/repo/ribasim/Ribasim/python/ribasim/ribasim/model.py:403)         is_valid = False
    [404](file:///D:/repo/ribasim/Ribasim/python/ribasim/ribasim/model.py:404)         logging.error(
    [405](file:///D:/repo/ribasim/Ribasim/python/ribasim/ribasim/model.py:405)             f"Node {row['to_node_id']} must have at least {edge_amount[row['to_node_type']][0]} inneighbor(s) (got {row['to_node_count']})"
    [406](file:///D:/repo/ribasim/Ribasim/python/ribasim/ribasim/model.py:406)         )

KeyError: nan

The node_id 0 doesn't exist in Node, so gets a to_node_type value of NaN:

row=to_node_id         0
to_node_count     80
to_node_type     NaN
Name: 888, dtype: object

That should be handled as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python Relates to one of the Ribasim python packages ribasim-nl Related to Ribasim NL project validation Related to model validation
Projects
Status: To do
Development

No branches or pull requests

2 participants