import numpy as np
from unittest import TestCase

from cartography.extractor import LibrosaFeatureExtractor

def gen_signal(dur, sr, freq):
  return np.pi * 2 * freq * np.arange(dur * sr) / float(sr)

class TestLibrosaFeatureExtractor(TestCase):
  @classmethod
  def setUpClass(cls):
    cls.test_dur = 2
    cls.test_freq = 440
    cls.test_sr = 22050
    cls.test_signal = gen_signal(cls.test_dur, cls.test_sr, cls.test_freq)

  def test_mfcc(self):
    extractor = LibrosaFeatureExtractor(None)

    num_mfccs = 13
    mfccs_kwargs = {
        'num_mfccs': num_mfccs,
        'delta_mfccs': False,
        'delta2_mfccs': False
    }
    expected_shape = ((13, 1000))
    got = extractor._mfcc(self.test_signal, self.test_sr, **mfccs_kwargs)
    self.assertEqual(expected_shape, got.shape)  # TODO figure out num hops

@@ -102,16 +102,17 @@
 ractor%0A%0A
+%0A
 def gen_
@@ -134,16 +134,18 @@
  freq):%0A
+  
   return
@@ -197,16 +197,17 @@
 at(sr)%0A%0A
+%0A
 class Te
@@ -243,16 +243,18 @@
 tCase):%0A
+  
   @class
@@ -260,16 +260,18 @@
 smethod%0A
+  
   def se
@@ -285,24 +285,28 @@
 s(cls):%0A    
+  
+  
 cls.test_dur
@@ -310,24 +310,28 @@
 dur = 2%0A    
+   
+ 
 cls.test_fre
@@ -338,24 +338,28 @@
 q = 440%0A    
+   
+ 
 cls.test_sr 
@@ -366,16 +366,20 @@
 = 22050%0A
+    
     cls.
@@ -446,16 +446,18 @@
 _freq)%0A%0A
+  
   def te
@@ -475,16 +475,20 @@
 f):%0A    
+  
+  
 extracto
@@ -522,16 +522,20 @@
 (None)%0A%0A
+    
     num_
@@ -549,16 +549,20 @@
  13%0A    
+  
+  
 mfccs_kw
@@ -578,16 +578,24 @@
         
+       
+ 
 'num_mfc
@@ -614,24 +614,32 @@
 cs,%0A        
+       
+ 
 'delta_mfccs
@@ -648,16 +648,24 @@
  False,%0A
+        
         
@@ -694,10 +694,18 @@
     
-%7D%0A
+    %7D%0A    
     
@@ -717,29 +717,25 @@
 ted_
-shape = ((13, 1000))%0A
+columns = 13%0A    
     
@@ -804,16 +804,20 @@
 kwargs)%0A
+    
     self
@@ -838,21 +838,23 @@
 xpected_
-shape
+columns
 , got.sh
@@ -860,34 +860,9 @@
 hape
-)  # TODO figure out num hops
+%5B0%5D)
 %0A

Fix spacing. Update mfcc test to check columns