1. pygame
  2. pygame
  3. pygame
  4. Issues

Issues

Issue #52 resolved

math module fails some unit tests on Linux PC

René Dudfield
created an issue

== Lenard Lindstrom, 2010-08-23 16:10:26 -0700

{{{ math module Pygame r2883 Python 2.5 - 3.1 gcc (Debian 4.4.4-8) 4.4.5 20100728 (prerelease) Kernel Linux 2.6.32-5-686 Processor: AMD Athlon

math_test.py displays the following fails:

FAIL: Vector2TypeTest.test_distance_squared_to

Traceback (most recent call last): File "/home/lenard/.local/lib/python2.5/site-packages/pygame/tests/math_test.py", line 434, in test_distance_squared_to diff.x * diff.x + diff.y * diff.y) AssertionError: 38.719999999999992 != 38.719999999999999

====================================================================== FAIL: Vector2TypeTest.test_distance_to


Traceback (most recent call last): File "/home/lenard/.local/lib/python2.5/site-packages/pygame/tests/math_test.py", line 425, in test_distance_to math.sqrt(diff.x * diff.x + diff.y * diff.y)) AssertionError: 6.2225396744416175 != 6.2225396744416184

====================================================================== FAIL: Vector2TypeTest.test_dot


Traceback (most recent call last): File "/home/lenard/.local/lib/python2.5/site-packages/pygame/tests/math_test.py", line 365, in test_dot self.v1.x * self.v2.x + self.v1.y * self.v2.y) AssertionError: 33.239999999999995 != 33.240000000000002

====================================================================== FAIL: Vector3TypeTest.test_distance_squared_to


Traceback (most recent call last): File "/home/lenard/.local/lib/python2.5/site-packages/pygame/tests/math_test.py", line 1295, in test_distance_squared_to diff.x * diff.x + diff.y * diff.y + diff.z * diff.z) AssertionError: 94.969999999999985 != 94.969999999999999

This has been traced to _vector_distance_helper in math.c, and happens when gcc optimizes. The tests pass when no optimization is used or the -ffloat-store optimization flag is added. These errors do not occur on Windows with VC and mingw gcc 4.5.0.

Solution: Add the 'optimize ("float-store")' attribute to _vector_distance_helper when compiled with gcc 4 on a x86 running gnu/linux.

I will apply the fix. }}}


== Lenard Lindstrom, 2010-08-26 21:52:11 -0700

{{{ fixed revision 2885 }}}


Comments (0)

  1. Log in to comment