1

When I run

import numpy as np

# Create small random numbers
a = np.random.rand(10)

# Check whether their sum and their flipped sum is the same
print(np.sum(a) == np.sum(a))
print(np.sum(np.flipud(a)) == np.sum(a))

the first statement is always true, whereas the second statement sometimes returns false, depending on the random numbers, and I have no idea why. I see this in both, Python 2.7 and Python 3.6. Interestingly, if I apply flipud twice like so:

print(np.sum(np.flipud(np.flipud(a))) == np.sum(a))

I always get True.

Edit: Some useful info on a related issue from the docs.

lhcgeneva
  • 1,981
  • 2
  • 21
  • 29

0 Answers0