Telecominfraproject / oopt-gnpy

Optical Route Planning Library, Based on a Gaussian Noise Model
http://telecominfraproject.com
BSD 3-Clause "New" or "Revised" License
198 stars 87 forks source link

tests: do not compare floating point numbers for equality #458

Closed jktjkt closed 1 year ago

jktjkt commented 1 year ago

GitHub CI started failing with the following error:

assert (watt2dbm(si.signal) == target - correction).all()
assert False
 +  where False = <built-in method all of numpy.ndarray object at 0x7f01c0ca94d0>()
 +    where <built-in method all of numpy.ndarray object at 0x7f01c0ca94d0> = array([-25.5, -24.5, -22.5, -25. , -27.5]) == array([-25.5, -24.5, -22.5, -25. , -27.5])
+array([-25.5, -24.5, -22.5, -25. , -27.5])
-array([-25.5, -24.5, -22.5, -25. , -27.5])

This is with code which has passed in the Zuul/Vexxhost CI.

It looks very similar to a regression that hit numpy 1.24.0, but the GitHub action log shows that this happens with numpy 1.24.1. Weird, and I'm not getting these differences locally, and also not on an ARM64 cloud VM.

Anyway, comparing floating point numbers for strict equality is futile, so let's use this opportunity to use a proper check for these.