Mercurial > hg > auditok
changeset 191:94d2f7560a8e
Fix bug in test AudioRegion concatenation
author | Amine Sehili <amine.sehili@gmail.com> |
---|---|
date | Thu, 18 Apr 2019 20:30:49 +0100 |
parents | 4d60f490bb5d |
children | 8e63fc5d1af6 |
files | auditok/core.py tests/test_core.py |
diffstat | 2 files changed, 5 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/auditok/core.py Mon Apr 15 22:32:47 2019 +0100 +++ b/auditok/core.py Thu Apr 18 20:30:49 2019 +0100 @@ -322,13 +322,15 @@ """ if isinstance(file, str): file = file.format( - start=self.start, end=self.end, duration=self.duration + start=round(self.start, 6), + end=round(self.end, 6), + duration=round(self.duration, 6) ) if not exists_ok and os.path.exists(file): - raise IOError("file '{file}' exists".format(file=file)) + raise FileExistsError("file '{file}' exists".format(file=file)) to_file( + self._data, file, - self._data, format, sr=self.sr, sw=self.sw,
--- a/tests/test_core.py Mon Apr 15 22:32:47 2019 +0100 +++ b/tests/test_core.py Thu Apr 18 20:30:49 2019 +0100 @@ -231,16 +231,6 @@ concat_region.duration, expected_duration, places=6 ) self.assertEqual(bytes(concat_region), expected_data) - # due to the behavior of `round` len(concat_region) does not always - # equal len(region_1) + len(region_2) - # Exmaple if both regions are 1.0005 seconds long, then: - # len(region_1) == len(region_2) == round(1.0005) == 1000 - # and: - # region_1.duration + region_2.duration == 1.0005 * 2 = 2.001 - # and: - # len(region_3) == round(2.001 * 1000) = 2001 - # != len(region_1) + len(region_2) - self.assertEqual(len(concat_region), round(expected_duration * 1000)) @genty_dataset( simple=(8000, 1, 1), @@ -264,8 +254,6 @@ concat_region.duration, expected_duration, places=6 ) self.assertEqual(bytes(concat_region), expected_data) - # see test_concatenation - self.assertEqual(len(concat_region), round(expected_duration * 1000)) def test_concatenation_different_sampling_rate_error(self):