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
|
Line | |
---|
1 | import unittest |
---|
2 | from numpy import array |
---|
3 | |
---|
4 | class aubio_unit_template(unittest.TestCase): |
---|
5 | """ a class derivated from unittest.TestCase """ |
---|
6 | |
---|
7 | def assertCloseEnough(self, first, second, places=5, msg=None): |
---|
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)) |
---|
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.