[py] [test] expect a small rounding error when using double precision
authorPaul Brossier <piem@piem.org>
Tue, 30 Oct 2018 09:15:10 +0000 (10:15 +0100)
committerPaul Brossier <piem@piem.org>
Tue, 30 Oct 2018 09:15:10 +0000 (10:15 +0100)
python/tests/test_note2midi.py

index 37c9db4..3bbf1c8 100755 (executable)
@@ -3,7 +3,7 @@
 
 from __future__ import unicode_literals
 
-from aubio import note2midi, freq2note, note2freq
+from aubio import note2midi, freq2note, note2freq, float_type
 from nose2.tools import params
 import unittest
 
@@ -127,7 +127,10 @@ class note2freq_simple_test(unittest.TestCase):
 
     def test_note2freq_under(self):
         " make sure note2freq(A4) == 440"
-        self.assertEqual(440, note2freq("A4"))
+        if float_type == 'float32':
+            self.assertEqual(440, note2freq("A4"))
+        else:
+            self.assertLess(abs(note2freq("A4")-440), 1.e-12)
 
 if __name__ == '__main__':
     import nose2