Skip to content

Commit

Permalink
update sorting methods
Browse files Browse the repository at this point in the history
  • Loading branch information
visr committed Sep 14, 2023
1 parent 03d2eb7 commit dc0c288
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
6 changes: 6 additions & 0 deletions python/ribasim/ribasim/node_types/flow_boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,9 @@ class FlowBoundary(TableModel):

static: Optional[DataFrame[FlowBoundaryStaticSchema]] = None
time: Optional[DataFrame[FlowBoundaryTimeSchema]] = None

def sort(self):
if self.static is not None:
self.static.sort_values("node_id", ignore_index=True, inplace=True)
if self.time is not None:
self.time.sort_values(["time", "node_id"], ignore_index=True, inplace=True)

Check warning on line 33 in python/ribasim/ribasim/node_types/flow_boundary.py

View check run for this annotation

Codecov / codecov/patch

python/ribasim/ribasim/node_types/flow_boundary.py#L33

Added line #L33 was not covered by tests
3 changes: 0 additions & 3 deletions python/ribasim/ribasim/node_types/fractional_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,3 @@ class FractionalFlow(TableModel):
"""

static: DataFrame[FractionalFlowStaticSchema]

def sort(self):
self.static.sort_values("node_id", ignore_index=True, inplace=True)
6 changes: 6 additions & 0 deletions python/ribasim/ribasim/node_types/level_boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@ class LevelBoundary(TableModel):

static: Optional[DataFrame[LevelBoundaryStaticSchema]] = None
time: Optional[DataFrame[LevelBoundaryTimeSchema]] = None

def sort(self):
if self.static is not None:
self.static.sort_values("node_id", ignore_index=True, inplace=True)
if self.time is not None:
self.time.sort_values(["time", "node_id"], ignore_index=True, inplace=True)

Check warning on line 31 in python/ribasim/ribasim/node_types/level_boundary.py

View check run for this annotation

Codecov / codecov/patch

python/ribasim/ribasim/node_types/level_boundary.py#L31

Added line #L31 was not covered by tests
6 changes: 6 additions & 0 deletions python/ribasim/ribasim/node_types/pid_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ class PidControl(TableModel):

class Config:
validate_assignment = True

def sort(self):
if self.static is not None:
self.static.sort_values("node_id", ignore_index=True, inplace=True)
if self.time is not None:
self.time.sort_values(["time", "node_id"], ignore_index=True, inplace=True)

Check warning on line 34 in python/ribasim/ribasim/node_types/pid_control.py

View check run for this annotation

Codecov / codecov/patch

python/ribasim/ribasim/node_types/pid_control.py#L31-L34

Added lines #L31 - L34 were not covered by tests

0 comments on commit dc0c288

Please sign in to comment.