feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change
on this file since 41f4c5b was
f603b57,
checked in by Paul Brossier <piem@piem.org>, 15 years ago
|
tests/python: update template.py
|
-
Property mode set to
100644
|
File size:
914 bytes
|
Rev | Line | |
---|
[038852a] | 1 | import unittest |
---|
[f603b57] | 2 | from numpy import array |
---|
[038852a] | 3 | |
---|
| 4 | class aubio_unit_template(unittest.TestCase): |
---|
[f603b57] | 5 | """ a class derivated from unittest.TestCase """ |
---|
[038852a] | 6 | |
---|
| 7 | def assertCloseEnough(self, first, second, places=5, msg=None): |
---|
[8987df1] | 8 | """Fail if the two objects are unequal as determined by their |
---|
| 9 | *relative* difference rounded to the given number of decimal places |
---|
| 10 | (default 7) and comparing to zero. |
---|
| 11 | """ |
---|
| 12 | if round(first, places) == 0: |
---|
| 13 | if round(second-first, places) != 0: |
---|
| 14 | raise self.failureException, \ |
---|
| 15 | (msg or '%r != %r within %r places' % (first, second, places)) |
---|
| 16 | else: |
---|
| 17 | if round((second-first)/first, places) != 0: |
---|
| 18 | raise self.failureException, \ |
---|
| 19 | (msg or '%r != %r within %r places' % (first, second, places)) |
---|
[f603b57] | 20 | |
---|
| 21 | def array_from_text_file(filename, dtype = 'float'): |
---|
| 22 | return array([line.split() for line in open(filename).readlines()], |
---|
| 23 | dtype = dtype) |
---|
Note: See
TracBrowser
for help on using the repository browser.