Imath icon indicating copy to clipboard operation
Imath copied to clipboard

testQuatArrays tests fail on some arches

Open sertonix opened this issue 3 months ago • 2 comments

Hi, I noticed that in the Alpine Linux CI the testQuatArrays test fails on some arches (aarch64/loongarch64/ppc64le/riscv64/s390x) and works fine on others (armv7/armhf/x86/x86_64).

I added a print .__repr__() for the values used in the assert that fails:

Running testQuatArrays
Quatf(-4.03840588e-08, 0.923879564, -0.382683426, -1.67276255e-08) == Quatf(-4.03840623e-08, 0.923879564, -0.382683456, -1.67276273e-08)
Traceback (most recent call last):
  File "/tmp/src/Imath-3.2.1/src/python/PyImathTest/pyImathTest.py", line 10815, in <module>
    test[1]()
  File "/tmp/src/Imath-3.2.1/src/python/PyImathTest/pyImathTest.py", line 10630, in testQuatArrays
    assert (q4[i] == q3[i].slerpShortestArc (q1[i], 0.5))
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

It looks like there are small differences in the resulting floats. Does Imath need the values to be exactly the same or can the equality check be replaced with a check that ensures a small distance between points?

sertonix avatar Sep 05 '25 12:09 sertonix

same here for aarch64

fundawang avatar Nov 01 '25 18:11 fundawang

Potential patch to fix the issue by reducing the precision of the comparison to match the other test assertions:

diff --git a/src/python/PyImathTest/pyImathTest.py b/src/python/PyImathTest/pyImathTest.py
index 6b8c4ac..6c98626 100644
--- a/src/python/PyImathTest/pyImathTest.py
+++ b/src/python/PyImathTest/pyImathTest.py
@@ -10626,7 +10626,8 @@ def testQuatArrays():
     q4 = q1.slerp (q3, 0.5)
     for i in range(5):
         assert (q4[i] == q1[i].slerpShortestArc (q3[i], 0.5))
-        assert (q4[i] == q3[i].slerpShortestArc (q1[i], 0.5))
+        assert equalWithAbsError(q4[i].r(), q3[i].slerpShortestArc(q1[i], 0.5).r(), 1e-5)
+        assert q4[i].v().equalWithAbsError(q3[i].slerpShortestArc(q1[i], 0.5).v(), 1e-5)
         
     tmp[:] = q4
     q4 *= q3.inverse()

strophy avatar Nov 27 '25 17:11 strophy