From 54b18005970852e3c3425a784bdc653ce0d10965 Mon Sep 17 00:00:00 2001 From: OBi <38684453+OleBialas@users.noreply.github.com> Date: Thu, 21 Apr 2022 18:32:48 +0200 Subject: [PATCH] bugfix (#52) * ignore soundfile for pytest * fix bu in test routine * don't check sound level * add testing for filters * change filter documentation * import re * change filters to filter in documentation * change f_lower to low_cutoff * remove brownnoise * ignore build * adding filter doc * ignore build * ignore build * ignore build * removing _build folder * convert tabs to spaces * debug calibrate * remove time_windows from test * remove matlabdoc builder * add matlabdoc builder to requirements * remove matlabdoc * resolve some warnings * syntax fixes * . * test recording * add play method * do test * move test folder one level up * addplotting code in the .rst file * one mire plotting example * add filter docu * add example for equalization filter * fix plotting * fix plotting * remove pyplots folder * debug plotting * ignoring cached scripts * simplify plot_tf * change header * remake intro * add reference for spectral features * move audiogram to examples * add some references * add fft filter test * chnage header * merge * fix reference * add psychoacoustics test * integrate mmn in Trialsequence class * for mmn sequence n_reps = n_trials * condition numbers start at 1 * condtions start at 1 * rename function to oddball, encode deviant as 0 * change oddball to deviant_indices * deviants should work now * make random permutation if n_conds = 1 * give correct trialnr * write response in list of lists * make list of None elementrs fro response * make list of None for response * add deviants to n conditions * fix bug * trial sequence should always be a list * dont insert empty array to avoid warning * add test routines * more tests * fix bug when loading sequence * fix import order * copy _init_ from upstream * all functions except curses now tested * fix syntax error * use uniform syntax for plotting * add hrtf tests * add h5netcdf * add SoundFile * add sudo apt-get install sndfile-tools * fix syntax * separate system and python dependencies * fix syntax error * return condition in __next__ * fix bug in deviant list generation * in self.data change None to -999 to avoid error when writing json files * make triallist python int * syntax error * return 0 in __next__() when trial is deviant * resolve type error * never modify anything in place, remove copy_channel * fix syntax error * remove copychannel, add am method * changing doku * overhaul of the psychoacoustics documentation * fix flake8 error * fix syntax error * fix assertion error * remove redundant function * writing stuff * add bibliography * change paper * new paper version * new unittests for Trialsequence + debugging * debug variable name * convert trials to list * raise error when condition is a string but not a file * add method for saving and loading pickle files and rename to LoadSave_mixin * when writing JSON, catch value AND type errors * when making a Trialsequence instance from a file, try to load JSON, catch exception and then load pickle * catch JSONDecodeError when loading trialsequence from file * JSON decode error is part of json module * fix indentation error * change class names and add docstrings * rename classes according to python conventions * removing attributes this_trial_n and this_rep_n from trialsequence * adding docstrings * add docstrings * adding docstrings * docstrings * move simulate_response to mixin * refactoring docstrings * debug test_psychoacoustics * avoid endless loop when computing deviant indices * enable plotting to axis when plotting an "image" * change plotting routine to avoid timeout when pytesting * add docstrings * change nchannels to n_channels and nsamples to n_samples * change Signal.resize to return a new instance * changed the crossfade function to deal with multiple inputs (still a BUG) * dont transpose array if data array is empty * add unit test for crossfading * docstrings * add test for frames and frametimes * finished docstring overhaul * add tests for signal.py * add test routine for generating and reading/writing sound * add test for power law noise * add tests for binaural cues * pack get and set envelope into one function * change envelope and itd/ild to get/set scheme * add docstrings for binaural generator functions * adding tests for band filters * finish filter class refractor * dont use unittest class * debug test_tone * add type in docstring * negative ild means sound to the left * add test for loading/saving filters * add test routines for externalize and interaural level spectrum * add the interaural level spectrum file to gitignore * add test for making HRTF instances * overhaul hrtf docstrings & tests * resolve some TODOs * remove normalise argument * debuging tests * debug endless loop * debig test_envelope * debug assertion errors * debug assertion errors * change filter n_samples * debug assertion error * renamed the n_ parameters * debug sound docs * implement writing objects to resultsfile * debugging docs * debug save results file * add import statements to docs * debug tests * debug test frames * add default level, changel handling of default sampling rate * hide default level and samplerate variables * remove conditions from setup dependencies * remove level argument from all functions * add SoudCard * remove soundfile * remove soundcard from setup.py * install pulseaudio * debug * remove SounCard from pipeline * debug test * debug * debug get_future_trial * improve documentation * uninstall soundcard after setup.py * add soundcard to requirements * say yes to pip uninstall * fix some warnings from pytest * add error message if libsndfile is not installed * add data_path function * change usage of data_path in docs * Update paper.bib * Update paper.bib * dont print every iteration in Trialsequence.transitions * some small fixes in psychoacoustics docs * catch h5py warning when loading sofa file * change docstrings for proper sphinx rendering * add level argument to generator methods * add kemar * remove all plot kwargs and add kwargs to spectrogram * debug binaural.externalize * debug hrtf plot_tf * make assert condition more liberal * add example for sequential application of filters * counts vs probabilities * debug setting 'length' in equalizing_filterbank * debug syntax Co-authored-by: Marc --- slab/filter.py | 2 +- tests/test_filter.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/slab/filter.py b/slab/filter.py index 3e7412b..05f66ee 100644 --- a/slab/filter.py +++ b/slab/filter.py @@ -457,7 +457,7 @@ def equalizing_filterbank(reference, sound, length=1000, bandwidth=1/8, low_cuto filts = numpy.zeros((length, sound.n_channels)) for chan in range(sound.n_channels): gain = [1] + list(amp_diffs[:, chan]) - filt = Filter.band(frequency=list(center_freqs), gain=gain, samplerate=reference.samplerate, fir=True) + filt = Filter.band(frequency=list(center_freqs), gain=gain, samplerate=reference.samplerate, fir=True, length=length) filts[:, chan] = filt.data.flatten() return Filter(data=filts, samplerate=reference.samplerate, fir=True) diff --git a/tests/test_filter.py b/tests/test_filter.py index a3dec45..175fb37 100644 --- a/tests/test_filter.py +++ b/tests/test_filter.py @@ -101,6 +101,9 @@ def test_center_freqs(): def test_equalization(): for i in range(10): + length = numpy.random.randint(1000, 5000) + low_cutoff = numpy.random.randint(20, 2000) + high_cutoff = numpy.random.randint(10000, 20000) sound = slab.Sound.pinknoise(samplerate=44100) filt = slab.Filter.band(frequency=[100., 800., 2000., 4300., 8000., 14500., 18000.], gain=[0., 1., 0., 1., 0., 1., 0.], samplerate=sound.samplerate)