From e8570494e603aeea8769ae4bed7929571d8b3d0a Mon Sep 17 00:00:00 2001
From: Ronan Hamon <ronan.hamon@lis-lab.fr>
Date: Wed, 25 Apr 2018 22:00:09 +0200
Subject: [PATCH] pep8 formatting

---
 madarrays/tests/test_waveform.py | 20 ++++++++++++++++----
 madarrays/waveform.py            |  6 +++---
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/madarrays/tests/test_waveform.py b/madarrays/tests/test_waveform.py
index c536350..1e565d5 100644
--- a/madarrays/tests/test_waveform.py
+++ b/madarrays/tests/test_waveform.py
@@ -109,7 +109,8 @@ def assert_clipping(x_clipped, x_ref, min_value, max_value):
 def get_data(request):
 
     request.cls.fs = np.random.choice(FS)
-    request.cls.length = np.random.randint(request.cls.fs*2, request.cls.fs * 3)
+    request.cls.length = np.random.randint(
+        request.cls.fs*2, request.cls.fs * 3)
 
     request.cls.x_mono = np.random.rand(request.cls.length)
     request.cls.x_mono_2 = np.random.rand(request.cls.length, 1)
@@ -571,7 +572,7 @@ class TestWaveform:
 
                     with warnings.catch_warnings(record=True):
                         w2 = Waveform.from_wavfile(tmp_file.name).astype(dtype)
-                    np.testing.assert_almost_equal(w2.to_np_array(),
+                    np.testing.assert_almost_equal(w2.to_np_array(0),
                                                    w.to_np_array(0),
                                                    decimal=3)
                     assert w.fs == w2.fs
@@ -978,7 +979,7 @@ class TestWaveform:
         w3 = Waveform(x, fs=1 if self.fs > 1 else 44100)
         ma = MadArray(x)
 
-        for operator in ['-', '-', '*', '/', '//']:
+        for operator in ['+', '-', '*', '/', '//']:
             print('Operation: {}'.format(operator))
 
             xs = eval('x {} x'.format(operator))
@@ -986,7 +987,7 @@ class TestWaveform:
             assert isinstance(ws, Waveform)
             np.testing.assert_equal(ws, xs)
 
-            match='Waveforms do not have the same fs: \d+ and \d+'
+            match = 'Waveforms do not have the same fs: \d+ and \d+'
             with pytest.raises(ValueError, match=match):
                 eval('w1 {} w3'.format(operator))
 
@@ -994,10 +995,21 @@ class TestWaveform:
             assert isinstance(ws, Waveform)
             np.testing.assert_equal(ws, xs)
 
+    def test_eq(self):
+
+        x = self.x_mono
+
+        w1 = Waveform(x, fs=self.fs)
+        w2 = Waveform(x, fs=self.fs)
+        w3 = Waveform(x, fs=1 if self.fs > 1 else 44100)
+
+        assert np.all(w1 == w2)
 
+        match = 'Waveforms do not have the same fs: \d+ and \d+'
         with pytest.raises(ValueError, match=match):
             w1 == w3
 
+        assert w2.is_equal(w2)
         assert not w1.is_equal(w3)
 
     def test_fade(self):
diff --git a/madarrays/waveform.py b/madarrays/waveform.py
index c4b357e..59613d7 100644
--- a/madarrays/waveform.py
+++ b/madarrays/waveform.py
@@ -162,9 +162,9 @@ class Waveform(MadArray):
 
         if isinstance(output, MadArray):
             if len(inputs) == 2:
-                if (isinstance(inputs[0], Waveform) and 
-                    isinstance(inputs[1], Waveform) and 
-                    inputs[0].fs != inputs[1].fs):
+                if (isinstance(inputs[0], Waveform) and
+                    isinstance(inputs[1], Waveform) and
+                        inputs[0].fs != inputs[1].fs):
                     errmsg = 'Waveforms do not have the same fs: {} and {}'
                     raise ValueError(errmsg.format(inputs[0].fs, inputs[1].fs))
 
-- 
GitLab