Ambiguous Evaluation of Lambda Expression on Array
- by Joe
I would like to use a lambda that adds one to x if x is equal to zero. I have tried the following expressions:
t = map(lambda x: x+1 if x==0 else x, numpy.array)
t = map(lambda x: x==0 and x+1 or x, numpy.array)
t = numpy.apply_along_axis(lambda x: x+1 if x==0 else x, 0, numpy.array)
Each of these expressions returns the following error:
…