Skip to content

Commit

Permalink
Remove deprecations for ResultNode
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-kipawa committed Dec 19, 2024
1 parent 5f2e324 commit 602b4e3
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 32 deletions.
4 changes: 3 additions & 1 deletion mikeio1d/geometry/geopandas/geopandas_nodes_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def __init__(self):
def _create_dataframe_data_dict(self, nodes: ResultNodes) -> dict[str, tuple]:
"""Create a dictionary with the data needed to create a GeoDataFrame."""
names = [node.id for node in nodes.values()]
geometries = [NodePoint.from_res1d_node(node.node).to_shapely() for node in nodes.values()]
geometries = [
NodePoint.from_res1d_node(node.res1d_node).to_shapely() for node in nodes.values()
]
data = {
"group": TimeSeriesIdGroup.NODE,
"name": names,
Expand Down
14 changes: 0 additions & 14 deletions mikeio1d/result_network/result_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,6 @@ def __repr__(self) -> str:
"""Return a string representation of the object."""
return f"<{self.type}: {self.id}>"

def __getattr__(self, name: str):
"""Warn if accessing deprecated attributes."""
# TODO: Remove this in 1.0.0
if name == "node":
warn("Accessing IRes1DNode attribute via .node is deprecated. Use ._node.")
return self.res1d_node
elif hasattr(self.res1d_node, name):
warn(
f"Accessing IRes1DNode attribute {name} directly is deprecated. Use static attributes instead, or ._node.{name}."
)
return getattr(self.res1d_node, name)
else:
object.__getattribute__(self, name)

@property
def res1d_node(self) -> IRes1DNode:
"""DHI.Mike1D.ResultDataAccess.IRes1DNode corresponding to this result location."""
Expand Down
4 changes: 2 additions & 2 deletions tests/test_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def test_reaches_point_interpolation_matches_mikeplus(self, river_reach):


def test_geometry_from_node(node):
node = NodePoint.from_res1d_node(node.node)
node = NodePoint.from_res1d_node(node.res1d_node)
g = node.to_shapely()
assert isinstance(g, shapely.Point)
assert g.x == pytest.approx(-687934.6000976562)
Expand All @@ -149,7 +149,7 @@ def test_geometry_from_catchment(many_catchments):

def test_geometry_from_nodes_runs(many_nodes):
for node in many_nodes:
node = NodePoint.from_res1d_node(node.node)
node = NodePoint.from_res1d_node(node.res1d_node)
g = node.to_shapely()
assert isinstance(g, shapely.Point)

Expand Down
15 changes: 0 additions & 15 deletions tests/test_res1d_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,21 +451,6 @@ def test_structure_reach_maintains_backweards_compatibility(res1d_network):
assert structures.s_119w1.structure_id == structures.s_119w1.id


def test_nodes_dict_access_maintains_backwards_compatibility(res1d_network):
with pytest.warns(UserWarning):
node = res1d_network.nodes["1"]
assert node.GroundLevel == pytest.approx(197.07000732421875)
assert node.BottomLevel == pytest.approx(195.0500030517578)
assert node.XCoordinate == pytest.approx(-687934.6000976562)


def test_node_node_property_maintains_backwards_compatibility(res1d_network):
node = res1d_network.nodes.n_1
assert node.node.GroundLevel == pytest.approx(197.07000732421875)
assert node.node.BottomLevel == pytest.approx(195.0500030517578)
assert node.node.XCoordinate == pytest.approx(-687934.6000976562)


def test_reaches_dict_access_maintains_backwards_compatibility(res1d_network, res1d_river_network):
with pytest.warns(UserWarning):
# Indexing reaches could return a single dotnet reach
Expand Down

0 comments on commit 602b4e3

Please sign in to comment.