Skip to content

Commit

Permalink
#569: Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
priscavdsluis committed Nov 16, 2023
1 parent 1265647 commit 251ee55
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 28 deletions.
24 changes: 1 addition & 23 deletions hydrolib/core/dflowfm/net/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,32 +54,10 @@ class Mesh2d(BaseModel):
Attributes:
meshkernel (mk.MeshKernel):
The meshkernel used to manimpulate this Mesh2d.
mesh2d_node_x (np.ndarray):
The node positions on the x-axis. Defaults to np.empty(0, dtype=np.double).
mesh2d_node_y (np.ndarray):
The node positions on the y-axis. Defaults to np.empty(0, dtype=np.double).
mesh2d_node_z (np.ndarray):
The node positions on the z-axis. Defaults to np.empty(0, dtype=np.double).
mesh2d_edge_x (np.ndarray):
The edge positions on the x-axis. Defaults to np.empty(0, dtype=np.double).
mesh2d_edge_y (np.ndarray):
The edge positions on the y-axis. Defaults to np.empty(0, dtype=np.double).
mesh2d_edge_z (np.ndarray):
The edge positions on the z-axis. Defaults to np.empty(0, dtype=np.double).
mesh2d_edge_nodes (np.ndarray):
The mapping of edges to node indices. Defaults to
np.empty((0, 2), dtype=np.int32).
mesh2d_face_x (np.ndarray):
The face positions on the x-axis. Defaults to np.empty(0, dtype=np.double).
mesh2d_face_y (np.ndarray):
The face positions on the y-axis. Defaults to np.empty(0, dtype=np.double).
mesh2d_face_z (np.ndarray):
The face positions on the z-axis. Defaults to np.empty(0, dtype=np.double).
mesh2d_face_nodes (np.ndarray):
The mapping of faces to node indices. Defaults to
np.empty((0, 0), dtype=np.int32)
"""

meshkernel: mk.MeshKernel = Field(default_factory=mk.MeshKernel)
Expand Down Expand Up @@ -162,7 +140,7 @@ def mesh2d_face_nodes(self) -> np.ndarray[int, int]:
"""The node indices of the mesh faces
Returns:
np.ndarray[int, int]: A 2D integer array describing the nodes composing each mesh 2d face. A 2D integer array (nFaces, nNodesFace) containg the node indices for each face.
np.ndarray[int, int]: A 2D integer array describing the nodes composing each mesh 2d face. A 2D integer array (nFaces, maxNodesPerFace) containg the node indices for each face.
"""
mesh2d_output = self.meshkernel.mesh2d_get()
npf = mesh2d_output.nodes_per_face
Expand Down
2 changes: 1 addition & 1 deletion hydrolib/core/dflowfm/net/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from hydrolib.core.basemodel import BaseModel

if TYPE_CHECKING:
from ..dflowfm.net.models import Link1d2d, Mesh1d, Mesh2d
from hydrolib.core.dflowfm.net.models import Link1d2d, Mesh1d, Mesh2d


class UgridReader:
Expand Down
2 changes: 1 addition & 1 deletion hydrolib/core/dflowfm/net/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from hydrolib.core.basemodel import BaseModel

if TYPE_CHECKING:
from ..dflowfm.net.models import Link1d2d, Mesh1d, Mesh2d, NetworkModel
from hydrolib.core.dflowfm.net.models import Link1d2d, Mesh1d, Mesh2d, NetworkModel


class FillValueConfiguration(BaseModel):
Expand Down
7 changes: 4 additions & 3 deletions tests/dflowfm/test_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ def test_create_refine_2d():
# check fnc
fnc = mesh2d.mesh2d_face_nodes
assert fnc.shape == (100, 4)
assert (fnc == -2147483648).sum() == 12 # amount of triangles
fnc_fill_value = np.iinfo(np.int32).min
assert (fnc == fnc_fill_value).sum() == 12 # amount of triangles


cases = [
Expand Down Expand Up @@ -318,12 +319,12 @@ def test_read_write_read_compare_nodes(filepath):
# Save to temporary location
save_path = (
test_output_dir
/ "test_read_write_read_compare" # .__name__
/ "test_read_write_read_compare_nodes"
/ network1._generate_name()
)
network1.save(filepath=save_path)

# # Read a second network from this location
# Read a second network from this location
network2 = NetworkModel(filepath=network1.filepath)

network1_mesh1d_node_x = network1._mesh1d._get_mesh1d().node_x
Expand Down

0 comments on commit 251ee55

Please sign in to comment.