Skip to content

Commit f5fcaca

Browse files
committed
[Test] unittest.TestCase.assertAlmostEqual rounds the figure, which is not what is intended. Intead, use a method that evaluates sigfig.
1 parent 7a4dd3f commit f5fcaca

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

ar_track_alvar/test/test_ar.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3535
# POSSIBILITY OF SUCH DAMAGE.
3636

37+
import numpy
3738
import math
3839
import unittest
3940

@@ -91,10 +92,13 @@ def test_markers(self):
9192
continue
9293
# Compare each translation element (x, y, z)
9394
for v_ret, v_expected in zip(trans, tf_expected[i][0]):
94-
self.assertAlmostEqual(v_ret, v_expected, 2)
95+
# Given that sigfig ignores the leading zero, we only compare the first sigfig.
96+
numpy.testing.assert_approx_equal(
97+
v_ret, v_expected, significant=1)
9598
# Compare each orientation element (x, y, z, w)
9699
for v_ret, v_expected in zip(rot, tf_expected[i][1]):
97-
self.assertAlmostEqual(v_ret, v_expected, 2)
100+
numpy.testing.assert_approx_equal(
101+
v_ret, v_expected, significant=1)
98102

99103
if __name__ == '__main__':
100104
import rostest

0 commit comments

Comments
 (0)