From 9637b0f1d9e798fd49095d72d0e6ae3d648b5ec8 Mon Sep 17 00:00:00 2001 From: Ronan Hamon <ronan.hamon@lis-lab.fr> Date: Wed, 18 Apr 2018 15:15:50 +0200 Subject: [PATCH] fix parameter order in test_waveform --- madarrays/tests/test_waveform.py | 44 +++++++++++++++++--------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/madarrays/tests/test_waveform.py b/madarrays/tests/test_waveform.py index 3348fe8..fb57bb1 100644 --- a/madarrays/tests/test_waveform.py +++ b/madarrays/tests/test_waveform.py @@ -148,7 +148,7 @@ class TestWaveform: def test_init_mono(self): - w = Waveform(self.x_mono, self.m_mono) + w = Waveform(self.x_mono, mask=self.m_mono) assert w.fs == 1 assert w.length == self.length @@ -172,7 +172,7 @@ class TestWaveform: def test_init_stereo(self): - w = Waveform(self.x_stereo, self.m_stereo) + w = Waveform(self.x_stereo, mask=self.m_stereo) assert w.fs == 1 assert w.length == self.length @@ -211,7 +211,7 @@ class TestWaveform: def test_init_from_waveform(self): - w = Waveform(self.x_mono, self.m_mono, fs=self.fs) + w = Waveform(self.x_mono, mask=self.m_mono, fs=self.fs) w2 = Waveform(w) assert w2.fs == self.fs @@ -255,7 +255,7 @@ class TestWaveform: w.resample(fs=0) # Masked data - w = Waveform(self.x_mono, self.m_mono, fs=self.fs) + w = Waveform(self.x_mono, mask=self.m_mono, fs=self.fs) with pytest.raises(ValueError, match='Waveform has missing entries.'): w.resample(fs=fs) @@ -553,7 +553,7 @@ class TestWaveform: for dtype in (INT_DTYPES + FLT_DTYPES + CPX_DTYPES): print('Fs: {:d}, dtype: {}]'.format(fs, dtype)) - w = Waveform(self.x_mono, self.m_mono, fs=self.fs) + w = Waveform(self.x_mono, mask=self.m_mono, fs=self.fs) with warnings.catch_warnings(record=True): w = w.astype(dtype) @@ -577,7 +577,7 @@ class TestWaveform: for dtype_targ in FLT_DTYPES: print('dtype: {}, dtype_targ: {}]'.format(dtype, dtype_targ)) - w = Waveform(self.x_mono, self.m_mono, fs=self.fs) + w = Waveform(self.x_mono, mask=self.m_mono, fs=self.fs) with warnings.catch_warnings(record=True): w = w.astype(dtype) @@ -606,7 +606,7 @@ class TestWaveform: for dtype in (INT_DTYPES + FLT_DTYPES + CPX_DTYPES): print('Fs: {:d}, dtype: {}]'.format(fs, dtype)) - w = Waveform(self.x_stereo, self.m_stereo, fs=self.fs) + w = Waveform(self.x_stereo, mask=self.m_stereo, fs=self.fs) with warnings.catch_warnings(record=True): w = w.astype(dtype) @@ -630,7 +630,7 @@ class TestWaveform: for dtype_targ in FLT_DTYPES: print('dtype: {}, dtype_targ: {}]'.format(dtype, dtype_targ)) - w = Waveform(self.x_mono, self.m_mono, fs=self.fs) + w = Waveform(self.x_mono, fs=self.fs, mask=self.m_mono) with warnings.catch_warnings(record=True): w = w.astype(dtype) @@ -745,7 +745,7 @@ class TestWaveform: for x, m in zip([self.x_mono, self.x_stereo], [self.m_mono, self.m_stereo]): - w = Waveform(x, m, fs=self.fs) + w = Waveform(x, mask=m, fs=self.fs) lines = w.plot(fill_value=None) assert type(lines[0]) == plt.matplotlib.lines.Line2D @@ -754,7 +754,8 @@ class TestWaveform: w.plot_mask() def test_plot_complex(self): - w = Waveform(self.x_mono + 1j * self.x_mono, self.m_mono, fs=self.fs) + w = Waveform(self.x_mono + 1j * self.x_mono, + mask=self.m_mono, fs=self.fs) lines = w.plot() assert type(lines[0]) == plt.matplotlib.lines.Line2D @@ -772,7 +773,7 @@ class TestWaveform: def test_copy(self): - w = Waveform(self.x_mono, self.m_mono, fs=self.fs) + w = Waveform(self.x_mono, mask=self.m_mono, fs=self.fs) w_copy = w.copy() assert w.is_equal(w_copy) @@ -781,7 +782,7 @@ class TestWaveform: def test_str_repr(self): - w = Waveform(self.x_mono, self.m_mono, fs=self.fs) + w = Waveform(self.x_mono, mask=self.m_mono, fs=self.fs) x = np.copy(self.x_mono) x[self.m_mono] = np.nan @@ -799,12 +800,12 @@ class TestWaveform: def test_show_player(self, capsys): - w = Waveform(self.x_mono, self.m_mono, fs=self.fs) + w = Waveform(self.x_mono, mask=self.m_mono, fs=self.fs) player = w.show_player() assert isinstance(player, Audio) - w = Waveform(self.x_mono, self.m_mono, + w = Waveform(self.x_mono, mask=self.m_mono, fs=self.fs).astype(np.complex128) with pytest.warns(UserWarning, match='Only the real part is played.'): @@ -812,7 +813,7 @@ class TestWaveform: assert isinstance(player, Audio) # Wrong frequency sampling - w = Waveform(self.x_mono, self.m_mono, fs=1) + w = Waveform(self.x_mono, mask=self.m_mono, fs=1) with pytest.raises(ValueError, match='Invalid sampling frequency: \d+Hz'): w.show_player() @@ -943,7 +944,7 @@ class TestWaveform: [self.m_mono, self.m_stereo]): with pytest.raises(TypeError, match='Waveform has missing samples'): - Waveform(x, m, fs=self.fs).get_analytic_signal() + Waveform(x, mask=m, fs=self.fs).get_analytic_signal() w = Waveform(x, fs=self.fs) np.testing.assert_array_almost_equal( @@ -1007,9 +1008,10 @@ class TestWaveform: print('fade_length={}, mode={}, fs={}'.format( fade_len, mode, self.fs)) - w[mode] = Waveform(self.x_mono, self.m_mono, fs=self.fs) + w[mode] = Waveform(self.x_mono, mask=self.m_mono, fs=self.fs) w[mode].fade(mode=mode, fade_length=fade_len) - w_with_dur = Waveform(self.x_mono, self.m_mono, fs=self.fs) + w_with_dur = Waveform( + self.x_mono, mask=self.m_mono, fs=self.fs) w_with_dur.fade(mode=mode, fade_duration=fade_dur) np.testing.assert_array_equal(w[mode], w_with_dur) @@ -1043,7 +1045,7 @@ class TestWaveform: self.x_mono[fade_len:], err_msg='Samples in the fade-out area greater') - w = Waveform(self.x_mono, self.m_mono, fs=self.fs) + w = Waveform(self.x_mono, mask=self.m_mono, fs=self.fs) w.fade(mode='both', fade_length=0) np.testing.assert_array_equal(np.array(w), self.x_mono) @@ -1053,7 +1055,7 @@ class TestWaveform: fade_dur = fade_len / self.fs w = dict() for mode in all_modes: - w[mode] = Waveform(self.x_mono, self.m_mono, fs=self.fs) + w[mode] = Waveform(self.x_mono, mask=self.m_mono, fs=self.fs) match = 'Either `fade_duration` or `fade_length` must be given.' with pytest.raises(ValueError, match=match): w[mode].fade(mode=mode) @@ -1082,7 +1084,7 @@ class TestWaveform: def test_pickle(self): - w = Waveform(self.x_mono, self.m_mono, fs=self.fs) + w = Waveform(self.x_mono, mask=self.m_mono, fs=self.fs) with tempfile.NamedTemporaryFile() as tmp_file: with open(tmp_file.name, 'wb') as fout: -- GitLab