Following up from here: Conditional calculation in python
I'm editing this line:
out = log(sum(exp(a - a_max), axis=0))
from line 85 here: https://github.com/scipy/scipy/blob/v0.14.0/scipy/misc/common.py#L18
to this:
out = log(sum(exp(threshold if a - a_max < threshold else a - a_max), axis = 0))
But I'm getting the following error:
out = log(sum(exp(threshold if a - a_max < threshold else a - a_max), axis=0)) ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
I can see from this answer that the error can be fixed using a for-loop to go through each value... but is there any way to incorporate it into quicker code? My arrays have tens of thousands of elements.