Skip to content

Commit

Permalink
#569: Add docs and remove code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
priscavdsluis committed Nov 16, 2023
1 parent deaec8c commit 22037a0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
19 changes: 14 additions & 5 deletions hydrolib/core/dflowfm/net/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1151,13 +1151,17 @@ def to_file(self, file: Path) -> None:
writer.write(self, file)

@property
def is_geographic(self):
def is_geographic(self) -> bool:
"""Whether or not this network has a geographic projection.
Returns:
bool: True if this network is geographic; otherwise, False.
"""
projection = self.meshkernel.get_projection()
if projection == mk.ProjectionType.CARTESIAN:
is_geographic = False
return False
else:
is_geographic = True
return is_geographic
return True

def link1d2d_from_1d_to_2d(
self, branchids: List[str] = None, polygon: GeometryList = None
Expand Down Expand Up @@ -1218,8 +1222,13 @@ def mesh1d_add_branch(
return name

def plot(self, ax=None):
import matplotlib.pyplot as plt
"""Create a plot of the 1d2d links and edges within this network.
Args:
ax (matplotlib.pyplot.Axes, optional): The axes where to plot the edges. Defaults to None.
"""
import matplotlib.pyplot as plt

if ax is None:
_, ax = plt.subplots()
mesh2d_output = self._mesh2d.get_mesh2d()
Expand Down
3 changes: 1 addition & 2 deletions tests/dflowfm/test_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ def test_create_1d_2d_1d2d():
# read from written file
network2 = NetworkModel(file_out)

mesh2d_output = network2._mesh2d.get_mesh2d()
assert len(network2._mesh2d.mesh2d_face_x) == 152
mesh1d_output = network2._mesh1d._get_mesh1d()
assert len(mesh1d_output.node_x) == 110
Expand All @@ -169,7 +168,7 @@ def test_create_1d_2d_1d2d():
# plot both networks
import matplotlib.pyplot as plt

fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(8, 4))
_, (ax1, ax2) = plt.subplots(1, 2, figsize=(8, 4))
network.plot(ax=ax1)
network2.plot(ax=ax2)

Expand Down

0 comments on commit 22037a0

Please sign in to comment.