-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert constructor types in py structures #134
Convert constructor types in py structures #134
Conversation
…linearGrid constructor parameters to appropriate types in case the user does not specify the correct types When the user types are not convertible, asarray throws a ValueError exception
meshkernel/py_structures.py
Outdated
@@ -421,18 +423,20 @@ def __init__( | |||
check_front_collisions=0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
False
def test_contacts_invalid_input(): | ||
"""Test exceptions due to malformed input for Contacts""" | ||
with pytest.raises(ValueError): | ||
Contacts(mesh1d_indices=["0", "1", "abc"], mesh2d_indices=["0", "1", "2"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace the silly string "abc" with something more meaningful, elegant and powerful. The string "nonna" is recommended.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahaha
tests/test_py_structures_inputs.py
Outdated
assert np.array_equal( | ||
gridded_samples.x_coordinates, np.array([1.0, 2.0, 3.0], dtype=np.double) | ||
) | ||
assert np.array_equal( | ||
gridded_samples.y_coordinates, np.array([2.0, 3.0, 4.0], dtype=np.double) | ||
) | ||
assert np.array_equal( | ||
gridded_samples.values, | ||
np.array( | ||
[10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0], | ||
dtype=np.double, | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional: can use numpy.asarray
…convert_constructor_parameters
…linearGrid constructor parameters to appropriate types in case the user does not specify the correct types
When the user types are not convertible, asarray throws a ValueError exception