Skip to content

Commit

Permalink
Try supporting no edges but failing
Browse files Browse the repository at this point in the history
Co-authored-by: Hofer-Julian <[email protected]>
  • Loading branch information
visr and Hofer-Julian committed Mar 8, 2024
1 parent 559ed6d commit 02e5c48
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 4 additions & 1 deletion 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 Series
from pandera.typing import DataFrame, Series
from pandera.typing.geopandas import GeoSeries
from shapely.geometry import LineString, MultiLineString, Point

Expand Down Expand Up @@ -49,6 +49,9 @@ class Edge(SpatialTableModel[EdgeSchema]):
Table describing the flow connections.
"""

def __init__(self):
super().__init__(df=DataFrame[EdgeSchema]())

def add(
self,
from_node: NodeData,
Expand Down
8 changes: 5 additions & 3 deletions python/ribasim/ribasim/input_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,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 All @@ -247,7 +247,8 @@ def _write_table(self, temp_path: Path) -> None:
SQLite connection to the database.
"""
table = self.tablename()
assert self.df is not None
if self.df is None:
return

# Add `fid` to all tables as primary key
# Enables editing values manually in QGIS
Expand Down Expand Up @@ -361,7 +362,8 @@ def _write_table(self, path: FilePath) -> None:
gdf.to_file(path, layer=self.tablename(), driver="GPKG", mode="a")

def sort(self):
self.df.sort_index(inplace=True)
if self.df is not None:
self.df.sort_index(inplace=True)


class ChildModel(BaseModel):
Expand Down

0 comments on commit 02e5c48

Please sign in to comment.