2

I have a probability matrix, should be adding up to 1. Then have this assertion in my code which makes no sense to me:

assert np.sum(space) == 1.0

This gives me an assertion error. When I add these lines:

print np.sum(space)
print np.sum(space).__class__
print np.sum(space) == 1.0
print int(np.sum(space)) == 1

This gives me:

1.0
<type 'numpy.float64'>
False
False

Why is this numpy float not equal to 1.0? This makes absolutely no sense to me. When I put this in the plain python terminal:

np.float64(1) == 1.0

This gives me:

True

WTF?

Sander
  • 591
  • 6
  • 16

0 Answers0