From 251ee55ae14d5ce3dc5864c2c67e46b71d8822c2 Mon Sep 17 00:00:00 2001 From: Prisca van der Sluis Date: Thu, 16 Nov 2023 11:36:04 +0100 Subject: [PATCH] #569: Clean up --- hydrolib/core/dflowfm/net/models.py | 24 +----------------------- hydrolib/core/dflowfm/net/reader.py | 2 +- hydrolib/core/dflowfm/net/writer.py | 2 +- tests/dflowfm/test_net.py | 7 ++++--- 4 files changed, 7 insertions(+), 28 deletions(-) diff --git a/hydrolib/core/dflowfm/net/models.py b/hydrolib/core/dflowfm/net/models.py index 67f9514d9..99d98fe98 100644 --- a/hydrolib/core/dflowfm/net/models.py +++ b/hydrolib/core/dflowfm/net/models.py @@ -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) @@ -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 diff --git a/hydrolib/core/dflowfm/net/reader.py b/hydrolib/core/dflowfm/net/reader.py index f1dd3f5a1..aa17fb67e 100644 --- a/hydrolib/core/dflowfm/net/reader.py +++ b/hydrolib/core/dflowfm/net/reader.py @@ -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: diff --git a/hydrolib/core/dflowfm/net/writer.py b/hydrolib/core/dflowfm/net/writer.py index 9e5336f9c..6903a24e8 100644 --- a/hydrolib/core/dflowfm/net/writer.py +++ b/hydrolib/core/dflowfm/net/writer.py @@ -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): diff --git a/tests/dflowfm/test_net.py b/tests/dflowfm/test_net.py index afd2df0e6..b8687cd65 100644 --- a/tests/dflowfm/test_net.py +++ b/tests/dflowfm/test_net.py @@ -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 = [ @@ -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