You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When passing a node_x array of a wrong type to meshkernel.Mesh2d there is no error raised. However, when passing the resulting Mesh2d instance to meshkernel.MeshKernel.mesh2d_set, there is type checking. Also, I would say int/float32 could be converted to float64 by meshkernel.
To Reproduce
importmeshkernelimportnumpyasnpnode_x=np.array([1,2,3])
node_y=np.array([1,2,1])
edge_nodes=np.array([[0,1],[1,2],[2,0]])
mesh2d=meshkernel.Mesh2d(
node_x=node_x.astype(np.float32), # deliberately using false type (this can come from an array like this)node_y=node_y.astype(np.float64),
edge_nodes=edge_nodes.ravel().astype(np.int32),
)
mk=meshkernel.MeshKernel()
mk.mesh2d_set(mesh2d) # type checking only happens upon mesh2d_set, not upon Mesh2d.__init__. Also, these types can be converted into each other
Expected behavior
type checking in an earlier stage (upon Mesh2d init). Also, accepting types that can be converted, or catching them in/before mesh2d_set
Version info (please complete the following information):
OS: Windows
Version 3.0.0
The text was updated successfully, but these errors were encountered:
This is not a bug. The wrong data type is used. mesh2d_set fails because the data type is enforced in class Mesh via type_enforced decorator. Types are not enforced elsewhere including in class Mesh2D.
A decision will be made if type enforcement is to be retained. The data type hints and the doc should suffice.
Describe the bug
When passing a
node_x
array of a wrong type tomeshkernel.Mesh2d
there is no error raised. However, when passing the resultingMesh2d
instance tomeshkernel.MeshKernel.mesh2d_set
, there is type checking. Also, I would say int/float32 could be converted to float64 by meshkernel.To Reproduce
mk.mesh2d_set(mesh2d)
raisesTypeError: incompatible types, c_long_Array_3 instance instead of LP_c_double instance
Expected behavior
type checking in an earlier stage (upon
Mesh2d
init). Also, accepting types that can be converted, or catching them in/beforemesh2d_set
Version info (please complete the following information):
The text was updated successfully, but these errors were encountered: