diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3ca7d3efd..b41824a4c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: rev: v0.0.286 hooks: - id: ruff - args: [--fix, --exit-non-zero-on-fix] + args: [--fix, --exit-non-zero-on-fix, --ignore=PD002] - repo: https://github.com/psf/black rev: 23.7.0 hooks: diff --git a/python/ribasim/ribasim/input_base.py b/python/ribasim/ribasim/input_base.py index f4acc07d6..17a5f808c 100644 --- a/python/ribasim/ribasim/input_base.py +++ b/python/ribasim/ribasim/input_base.py @@ -197,5 +197,5 @@ def sort(self): if dataframe is None: continue else: - dataframe = dataframe.sort_values("node_id", ignore_index=True) + dataframe.sort_values("node_id", ignore_index=True, inplace=True) return diff --git a/python/ribasim/ribasim/node_types/basin.py b/python/ribasim/ribasim/node_types/basin.py index 3f7f00537..d46600d44 100644 --- a/python/ribasim/ribasim/node_types/basin.py +++ b/python/ribasim/ribasim/node_types/basin.py @@ -60,12 +60,12 @@ class Basin(TableModel): state: Optional[DataFrame[StateSchema]] = None def sort(self): - self.profile = self.profile.sort_values(["node_id", "level"], ignore_index=True) + self.profile.sort_values(["node_id", "level"], ignore_index=True, inplace=True) if self.static is not None: - self.static = self.static.sort_values("node_id", ignore_index=True) + self.static.sort_values("node_id", ignore_index=True, inplace=True) if self.forcing is not None: - self.forcing = self.forcing.sort_values( - ["time", "node_id"], ignore_index=True + self.forcing.sort_values( + ["time", "node_id"], ignore_index=True, inplace=True ) if self.state is not None: - self.state = self.state.sort_values("node_id", ignore_index=True) + self.state.sort_values("node_id", ignore_index=True, inplace=True) diff --git a/python/ribasim/ribasim/node_types/fractional_flow.py b/python/ribasim/ribasim/node_types/fractional_flow.py index d86d5e40e..46d2da516 100644 --- a/python/ribasim/ribasim/node_types/fractional_flow.py +++ b/python/ribasim/ribasim/node_types/fractional_flow.py @@ -28,4 +28,4 @@ class FractionalFlow(TableModel): static: DataFrame[StaticSchema] def sort(self): - self.static = self.static.sort_values("node_id", ignore_index=True) + self.static.sort_values("node_id", ignore_index=True, inplace=True) diff --git a/python/ribasim/ribasim/node_types/tabulated_rating_curve.py b/python/ribasim/ribasim/node_types/tabulated_rating_curve.py index cded2f9f1..32b831c78 100644 --- a/python/ribasim/ribasim/node_types/tabulated_rating_curve.py +++ b/python/ribasim/ribasim/node_types/tabulated_rating_curve.py @@ -42,8 +42,11 @@ class TabulatedRatingCurve(TableModel): time: Optional[DataFrame[TimeSchema]] = None def sort(self): - self.static = self.static.sort_values(["node_id", "level"], ignore_index=True) + if self.static: + self.static.sort_values( + ["node_id", "level"], ignore_index=True, inplace=True + ) if self.time is not None: - self.time = self.time.sort_values( - ["time", "node_id", "level"], ignore_index=True + self.time.sort_values( + ["time", "node_id", "level"], ignore_index=True, inplace=True )