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

Fix Primod tests #324

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pre-processing/primod/driver_coupling/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def _validate_node_ids(
dataframe: pd.DataFrame, definition: gpd.GeoDataFrame
) -> pd.Series:
# Validate
if ("node_id" not in definition.columns) or (definition.index.name == "node_id"):
if "node_id" not in definition.columns:
raise ValueError(
'Definition must contain "node_id" column.'
f"Columns in dataframe: {definition.columns}"
Expand Down
13 changes: 8 additions & 5 deletions tests/test_primod/test_preprocessing_ribamod.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,13 @@ def test_nullify_on_write(

# This basin definition is still a point geometry.
# This mean it will be rasterized to just two pixels.
gdf = ribasim_two_basin_model.basin.node.df
basin_definition = ribasim_two_basin_model.basin.node.df.copy()
if basin_definition.index.name == "node_id":
basin_definition["node_id"] = basin_definition.index

driver_coupling = RibaModActiveDriverCoupling(
mf6_model=mf6_modelname,
ribasim_basin_definition=gdf,
ribasim_basin_definition=basin_definition,
mf6_packages=mf6_river_packages,
)

Expand All @@ -272,14 +275,14 @@ def test_nullify_on_write(
ribasim_dll_dependency="c",
)
# check if columns will be nullified correctly
node_id = coupled_models.ribasim_model.basin.node.df["node_id"].to_numpy()
node_id = coupled_models.ribasim_model.basin.node.df.index.to_numpy()
df = pd.DataFrame.from_dict(
{
"node_id": node_id,
"fid": node_id,
"drainage": np.ones_like(node_id),
"infiltration": np.ones_like(node_id),
}
)
).set_index("fid")
coupled_models.ribasim_model.basin.static.df = df
coupled_models.write(
directory=tmp_path,
Expand Down
Loading