Skip to content

Commit

Permalink
python: Fix error message in LB nodegrid
Browse files Browse the repository at this point in the history
The np.array() casts the entire array to string if the last element
is a string, causing the assertion in LBFluidRoutines() to complain
about the first element being a string, which it is not in the user
input. The logic for the assertion in HydrodynamicInteraction() can
also be replaced by utils.check_type_or_throw_except().
  • Loading branch information
jngrad committed Oct 28, 2020
1 parent 80b7cfa commit 7af98c5
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/python/espressomd/lb.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,9 @@ cdef class HydrodynamicInteraction(Actor):
return _construct, (self.__class__, self._params), None

def __getitem__(self, key):
if isinstance(key, (tuple, list, np.ndarray)):
if len(key) == 3:
return LBFluidRoutines(np.array(key))
raise Exception(
f"{key} is not a valid key. Should be a point on the nodegrid e.g. lbf[0,0,0].")
utils.check_type_or_throw_except(
key, 3, int, "The index of an lb fluid node consists of three integers, e.g. lbf[0,0,0]")
return LBFluidRoutines(key)

# validate the given parameters on actor initialization
####################################################
Expand Down

0 comments on commit 7af98c5

Please sign in to comment.