File skyfield-pr404-comparefloat.patch of Package python-skyfield

From 84c39cb76a2dac3755a83fe104a9e834cbae5674 Mon Sep 17 00:00:00 2001
From: Ben Greiner <code@bnavigator.de>
Date: Fri, 10 Jul 2020 13:24:37 +0200
Subject: [PATCH 1/2] use numpy to compare floats

---
 skyfield/tests/test_planetarylib.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Index: skyfield-1.24/skyfield/tests/test_planetarylib.py
===================================================================
--- skyfield-1.24.orig/skyfield/tests/test_planetarylib.py
+++ skyfield-1.24/skyfield/tests/test_planetarylib.py
@@ -43,11 +43,11 @@ def test_frame_rotation_matrices():
     ]
 
     R = frame.rotation_at(ts.tdb_jd(tdb))
-    assert (R == desired_rotation).all()  # Boom.
+    np.testing.assert_array_max_ulp(R, desired_rotation)
 
     R2, Rv = frame.rotation_and_rate_at(ts.tdb_jd(tdb))
-    assert (R == R2).all()
-    assert (Rv == desired_rate).all()  # Boom.
+    np.testing.assert_array_max_ulp(R, R2)
+    np.testing.assert_array_max_ulp(Rv, desired_rate)
 
     # Second, a moment when the angle W is more than 2500 radians.
 
@@ -66,12 +66,11 @@ def test_frame_rotation_matrices():
          -2.1589045361778893e-10],
     ]
     R = frame.rotation_at(ts.tdb_jd(tdb))
-    delta = abs(R - desired_rotation)
-    assert (delta < 2e-13).all()  # a few digits are lost in large W radians?
+    np.testing.assert_allclose(R, desired_rotation, atol=2e-13)
 
     R2, Rv = frame.rotation_and_rate_at(ts.tdb_jd(tdb))
-    assert (R == R2).all()
-    assert abs(Rv - desired_rate).max() < 4e-19  # About 13 digits precision.
+    np.testing.assert_array_max_ulp(R, R2)
+    np.testing.assert_allclose(Rv, desired_rate, atol=4e-19)
 
     # Finally, a frame which is defined by a constant rotation of
     # another frame.
@@ -92,12 +91,12 @@ def test_frame_rotation_matrices():
     ]
     frame = pc.build_frame_named('MOON_ME_DE421')
     R = frame.rotation_at(ts.tdb_jd(tdb))
-    delta = abs(R - desired_rotation)
-    assert (R == desired_rotation).all()
+    np.testing.assert_array_max_ulp(R, desired_rotation)
 
     R2, Rv = frame.rotation_and_rate_at(ts.tdb_jd(tdb))
-    assert (R == R2).all()
-    assert (Rv == desired_rate).all()
+    np.testing.assert_array_max_ulp(R, R2)
+    np.testing.assert_array_max_ulp(Rv, desired_rate)
+
 
 def test_rotating_vector_into_frame():
     et_seconds = 259056665.1855896
openSUSE Build Service is sponsored by