Changeset f91737d for python/tests


Ignore:
Timestamp:
Oct 3, 2016, 11:46:37 AM (8 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, sampler, yinfft+
Children:
eacc55c
Parents:
80d0083
Message:

python/tests/test_source.py: check the tail of the file is non-zero on non silent test files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/tests/test_source.py

    r80d0083 rf91737d  
    33from nose2 import main
    44from nose2.tools import params
    5 from numpy.testing import TestCase
     5from numpy.testing import TestCase, assert_equal
    66from aubio import source
    77from utils import list_all_sounds
     8import numpy as np
    89
    910import warnings
     
    5253        total_frames = 0
    5354        while True:
    54             _ , read = f()
     55            samples , read = f()
    5556            total_frames += read
    56             if read < f.hop_size: break
     57            if read < f.hop_size:
     58                assert_equal(samples[read:], 0)
     59                if 'silence' not in f.uri:
     60                    self.assertEquals(np.count_nonzero(samples[:read]), read)
     61                break
    5762        #result_str = "read {:.2f}s ({:d} frames in {:d} blocks at {:d}Hz) from {:s}"
    5863        #result_params = total_frames / float(f.samplerate), total_frames, total_frames//f.hop_size, f.samplerate, f.uri
     
    150155        total_frames = 0
    151156        while True:
    152             _, read = f.do_multi()
     157            samples, read = f.do_multi()
    153158            total_frames += read
    154             if read < f.hop_size: break
     159            if read < f.hop_size:
     160                assert_equal(samples[:,read:], 0)
     161                if 'silence' not in f.uri:
     162                    self.assertEquals(np.count_nonzero(samples[:,:read]), read)
     163                break
    155164        #result_str = "read {:.2f}s ({:d} frames in {:d} channels and {:d} blocks at {:d}Hz) from {:s}"
    156165        #result_params = total_frames / float(f.samplerate), total_frames, f.channels, int(total_frames/f.hop_size), f.samplerate, f.uri
Note: See TracChangeset for help on using the changeset viewer.