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

testsuite: add test for is_valid_type. #3080

Merged
merged 8 commits into from
Aug 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/python/espressomd/particle_data.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ cdef class ParticleHandle:

def __set__(self, _pos):
cdef double mypos[3]
if np.isnan(_pos).any() or np.isinf(_pos).any():
raise ValueError("invalid particle position")
check_type_or_throw_except(
_pos, 3, float, "Position must be 3 floats")
for i in range(3):
Expand Down
3 changes: 2 additions & 1 deletion src/python/espressomd/utils.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ def is_valid_type(value, t):
Extended checks for numpy int and float types.

"""

if value is None:
return False
if t == int:
return isinstance(value, (int, np.integer, np.long))
elif t == float:
Expand Down