]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
test(numpy): allow more approximation comparing float16 values
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sat, 17 Dec 2022 04:08:56 +0000 (04:08 +0000)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sat, 5 Aug 2023 14:21:30 +0000 (15:21 +0100)
    >>> numpy.float16("-0.00018227100372314453")
    -0.0001823

    >>> -0.0001823 == pytest.approx(-0.00018227100372314453, rel=1e-5)
    False

    >>> -0.0001823 == pytest.approx(-0.00018227100372314453, rel=1e-3)
    True

tests/fix_faker.py

index 95012fcd228dc93a66d469dff97462d7c5bab6ff..5f7c48c5b8fb3db1707b712076fd72dd583c5fac 100644 (file)
@@ -908,7 +908,7 @@ class Faker:
         return self.match_any(spec, int(got), want)
 
     def match_numpy_float16(self, spec, got, want):
-        return self.match_numpy_float32(spec, got, want)
+        return self.match_float(spec, got, want, approx=True, rel=1e-3)
 
     def match_numpy_float32(self, spec, got, want):
         return self.match_Float4(spec, got, want)