Skip to content

Commit

Permalink
use np.int32 instead of int
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacarniato committed Jan 30, 2024
1 parent 447d073 commit 6b99a1f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions meshkernel/py_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,8 @@ class Contacts:
"""

def __init__(self, mesh1d_indices, mesh2d_indices):
self.mesh1d_indices: ndarray = np.asarray(mesh1d_indices, dtype=int)
self.mesh2d_indices: ndarray = np.asarray(mesh2d_indices, dtype=int)
self.mesh1d_indices: ndarray = np.asarray(mesh1d_indices, dtype=np.int32)
self.mesh2d_indices: ndarray = np.asarray(mesh2d_indices, dtype=np.int32)

def plot_edges(self, ax, mesh1d, mesh2d, *args, **kwargs):
"""Plots the edges at a given axes.
Expand Down
28 changes: 14 additions & 14 deletions tests/test_py_structures_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def test_mesh2d_implicit_int_conversions():
"""Test implicit conversion from int to double for Mesh2d works"""
mk = MeshKernel()

edge_nodes = np.array([0, 1, 1, 2, 2, 3, 3, 0], dtype=int)
node_x = np.array([0, 1, 1, 0], dtype=int)
node_y = np.array([0, 0, 1, 1], dtype=int)
edge_nodes = np.array([0, 1, 1, 2, 2, 3, 3, 0], dtype=np.int32)
node_x = np.array([0, 1, 1, 0], dtype=np.int32)
node_y = np.array([0, 0, 1, 1], dtype=np.int32)

input_mesh2d = Mesh2d(node_x, node_y, edge_nodes)
mk.mesh2d_set(input_mesh2d)
Expand Down Expand Up @@ -75,15 +75,15 @@ def test_mesh2d_implicit_string_conversions():

assert_array_equal(mesh_2d.node_x, np.array([1.0, 2.0, 3.0], dtype=np.double))
assert_array_equal(mesh_2d.node_y, np.array([4.0, 5.0, 6.0], dtype=np.double))
assert_array_equal(mesh_2d.edge_nodes, np.array([0, 1, 1, 2], dtype=int))
assert_array_equal(mesh_2d.face_nodes, np.array([0, 1, 2], dtype=int))
assert_array_equal(mesh_2d.nodes_per_face, np.array([3, 4, 5], dtype=int))
assert_array_equal(mesh_2d.edge_nodes, np.array([0, 1, 1, 2], dtype=np.int32))
assert_array_equal(mesh_2d.face_nodes, np.array([0, 1, 2], dtype=np.int32))
assert_array_equal(mesh_2d.nodes_per_face, np.array([3, 4, 5], dtype=np.int32))
assert_array_equal(mesh_2d.edge_x, np.array([1.5, 2.5], dtype=np.double))
assert_array_equal(mesh_2d.edge_y, np.array([4.5, 5.5], dtype=np.double))
assert_array_equal(mesh_2d.face_x, np.array([2.0, 3.0], dtype=np.double))
assert_array_equal(mesh_2d.face_y, np.array([5.0, 6.0], dtype=np.double))
assert_array_equal(mesh_2d.edge_faces, np.array([0, 1], dtype=int))
assert_array_equal(mesh_2d.face_edges, np.array([2, 3], dtype=int))
assert_array_equal(mesh_2d.edge_faces, np.array([0, 1], dtype=np.int32))
assert_array_equal(mesh_2d.face_edges, np.array([2, 3], dtype=np.int32))


def test_mesh2d_invalid_input():
Expand All @@ -101,9 +101,9 @@ def test_mesh2d_invalid_input():
def test_geometrylist_implicit_int_conversions():
"""Test implicit conversion from int to double for GeometryList works"""

x_coordinates = np.array([2, 5, 3, 0, 2], dtype=int)
y_coordinates = np.array([5, 3, 5, 2, 0], dtype=int)
values = np.array([0, 0, 1, 1, 1], dtype=int)
x_coordinates = np.array([2, 5, 3, 0, 2], dtype=np.int32)
y_coordinates = np.array([5, 3, 5, 2, 0], dtype=np.int32)
values = np.array([0, 0, 1, 1, 1], dtype=np.int32)

geometry_list = GeometryList(
x_coordinates=x_coordinates, y_coordinates=y_coordinates, values=values
Expand Down Expand Up @@ -417,7 +417,7 @@ def test_mesh1d_implicit_string_conversions():

assert np.array_equal(mesh_1d.node_x, np.array([1.0, 2.0, 3.0], dtype=np.double))
assert np.array_equal(mesh_1d.node_y, np.array([4.0, 5.0, 6.0], dtype=np.double))
assert np.array_equal(mesh_1d.edge_nodes, np.array([0, 1, 1, 2], dtype=int))
assert np.array_equal(mesh_1d.edge_nodes, np.array([0, 1, 1, 2], dtype=np.int32))


def test_mesh1d_invalid_input():
Expand All @@ -444,8 +444,8 @@ def test_contacts_implicit_string_conversions():

contacts = Contacts(mesh1d_indices=mesh1d_indices, mesh2d_indices=mesh2d_indices)

assert np.array_equal(contacts.mesh1d_indices, np.array([0, 1, 2], dtype=int))
assert np.array_equal(contacts.mesh2d_indices, np.array([0, 1, 2], dtype=int))
assert np.array_equal(contacts.mesh1d_indices, np.array([0, 1, 2], dtype=np.int32))
assert np.array_equal(contacts.mesh2d_indices, np.array([0, 1, 2], dtype=np.int32))


def test_contacts_invalid_input():
Expand Down

0 comments on commit 6b99a1f

Please sign in to comment.