isolver/psychopy — pull request #27 by hoechenberger (2014-12-30 12:55:25+00:00)
Title: BF: Convert return data to list

Checking if `r` is an empty list will natuarlly fail if, for example, `r` is a NumPy array:

----------
>>> l = [1, 2,3]
>>> if l:
... print "YUP!"
...
YUP!
>>> import numpy as np
>>> a = np.array(l)
>>> if a:
... print "YUP!"
...
Traceback (most recent call last):
File "", line 1, in
if a:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
----------

Therefore, we should try to (temporarily) convert the return data to a list before checking the truth value:
----------
>>> if list(a):
... print "YUP!"
...
YUP!
>>>
----------

This bug was discovered when trying to change existing code to take advantage of msgpack-numpy.