The arrays are of following dimensions:
dists
: (500,5000)
train
: (5000,)
test
:(500,)
Why does the first two statements throw an error whereas the third one works fine?
dists += train + test
Error: ValueError: operands could not be broadcast together with shapes (5000,) (500,)
dists += train.reshape(-1,1) + test.reshape(-1,1)
Error: ValueError: operands could not be broadcast together with shapes (5000,1) (500,1)
dists += train + test.reshape(-1,1)
This works fine!
Why does this happen?