Skip to content
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

Merged
merged 21 commits into from
Feb 19, 2024

Conversation

lucacarniato
Copy link
Contributor

…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

…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
@lucacarniato lucacarniato changed the title Convert Mesh2d, GeometryList, Mesh1d, Contacts, GriddedSamples, Curvi… Convert constructor types in py structures Jan 19, 2024
@ahmad-el-sayed ahmad-el-sayed marked this pull request as ready for review January 22, 2024 13:12
meshkernel/py_structures.py Outdated Show resolved Hide resolved
@@ -421,18 +423,20 @@ def __init__(
check_front_collisions=0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False

meshkernel/py_structures.py Outdated Show resolved Hide resolved
meshkernel/py_structures.py Outdated Show resolved Hide resolved
meshkernel/py_structures.py Outdated Show resolved Hide resolved
tests/test_py_structures_inputs.py Outdated Show resolved Hide resolved
tests/test_py_structures_inputs.py Outdated Show resolved Hide resolved
tests/test_py_structures_inputs.py Outdated Show resolved Hide resolved
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"])
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahaha

Comment on lines 501 to 512
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,
),
Copy link
Contributor

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

@lucacarniato lucacarniato merged commit 8246c5c into main Feb 19, 2024
9 checks passed
@lucacarniato lucacarniato deleted the feature/GRIDEDIT-846_convert_constructor_parameters branch February 19, 2024 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants