For example, I have function:
f1 = lambda x: x % 2
If I want to modify array = np.linspace(0, 5, 6) I can do f1(array). Everything works as expected:
[0. 1. 0. 1. 0. 1.]
If I change function to:
f2 = lambda x: 0
print(f2(array))
gives me 0 while I expected [0. 0. 0. 0. 0. 0.]. How to achieve consistency?
f2is not an array. Nothing unexpected happening here.f2 = lambda x: x-xf2will iterate overarrayand evaluate every element then store it to a resulting array.x % 2does (whenxis annp.array).