source: tests/python/template.py @ 038852a

feature/autosinkfeature/constantqfeature/pitchshiftfeature/pydocstringsfeature/timestretchpitchshiftsamplertimestretchyinfft+
Last change on this file since 038852a was 038852a, checked in by Paul Brossier <piem@piem.org>, 13 years ago

updated fft.py tests, added template for assertCloseEnough

  • Property mode set to 100644
File size: 750 bytes
Line 
1
2import unittest
3
4class aubio_unit_template(unittest.TestCase):
5 
6  def assertCloseEnough(self, first, second, places=5, msg=None):
7        """Fail if the two objects are unequal as determined by their
8           *relative* difference rounded to the given number of decimal places
9           (default 7) and comparing to zero.
10        """
11        if round(first, places) == 0:
12          if round(second-first, places) != 0:
13              raise self.failureException, \
14                    (msg or '%r != %r within %r places' % (first, second, places))
15        else:
16          if round((second-first)/first, places) != 0:
17              raise self.failureException, \
18                    (msg or '%r != %r within %r places' % (first, second, places))
Note: See TracBrowser for help on using the repository browser.