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 model plotting while still ensuring that Edge tables are written #1241

Closed
wants to merge 3 commits into from
Closed
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
6 changes: 1 addition & 5 deletions python/ribasim/ribasim/geometry/edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from geopandas import GeoDataFrame
from matplotlib.axes import Axes
from numpy.typing import NDArray
from pandera.typing import DataFrame, Series
from pandera.typing import Series
from pandera.typing.geopandas import GeoSeries
from shapely.geometry import LineString, MultiLineString, Point

Expand Down Expand Up @@ -42,10 +42,6 @@ class Config:
class EdgeTable(SpatialTableModel[EdgeSchema]):
"""Defines the connections between nodes."""

def __init__(self, **kwargs):
kwargs.setdefault("df", DataFrame[EdgeSchema]())
super().__init__(**kwargs)

def add(
self,
from_node: NodeData,
Expand Down
2 changes: 1 addition & 1 deletion python/ribasim/ribasim/geometry/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


class NodeSchema(pa.SchemaModel):
node_id: Series[int]
node_id: Series[int] = pa.Field(nullable=False, default=0)
name: Series[str] = pa.Field(default="")
node_type: Series[str] = pa.Field(default="")
subnetwork_id: Series[pd.Int64Dtype] = pa.Field(
Expand Down
6 changes: 3 additions & 3 deletions python/ribasim/ribasim/input_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def _save(
if self.df is not None and self.filepath is not None:
self.sort()
self._write_arrow(self.filepath, directory, input_dir)
elif self.df is not None and db_path is not None:
elif db_path is not None:
self.sort()
self._write_table(db_path)

Expand Down Expand Up @@ -358,8 +358,8 @@ def _write_table(self, path: FilePath) -> None:
----------
path : FilePath
"""

gdf = gpd.GeoDataFrame(data=self.df)
df = DataFrame[self.tableschema()]() if self.df is None else self.df # type:ignore
gdf = gpd.GeoDataFrame(data=df)
gdf = gdf.set_geometry("geometry")
gdf.to_file(path, layer=self.tablename(), driver="GPKG", mode="a")

Expand Down
Loading