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

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_columns = 13
        got = extractor._mfcc(self.test_signal, self.test_sr, **mfccs_kwargs)
        self.assertEqual(expected_columns, got.shape[0])

Fix spacing. Update mfcc test to check columns
Fix spacing. Update mfcc test to check columns

  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)
+     return np.pi * 2 * freq * np.arange(dur * sr) / float(sr)
+ 
  
  class TestLibrosaFeatureExtractor(TestCase):
-   @classmethod
+     @classmethod
-   def setUpClass(cls):
+     def setUpClass(cls):
-     cls.test_dur = 2
+         cls.test_dur = 2
-     cls.test_freq = 440
+         cls.test_freq = 440
-     cls.test_sr = 22050
+         cls.test_sr = 22050
-     cls.test_signal = gen_signal(cls.test_dur, cls.test_sr, cls.test_freq)
+         cls.test_signal = gen_signal(cls.test_dur, cls.test_sr, cls.test_freq)
  
-   def test_mfcc(self):
+     def test_mfcc(self):
-     extractor = LibrosaFeatureExtractor(None)
+         extractor = LibrosaFeatureExtractor(None)
  
-     num_mfccs = 13
+         num_mfccs = 13
-     mfccs_kwargs = {
+         mfccs_kwargs = {
-         'num_mfccs': num_mfccs,
+                 'num_mfccs': num_mfccs,
-         'delta_mfccs': False,
+                 'delta_mfccs': False,
-         'delta2_mfccs': False
+                 'delta2_mfccs': False
-     }
-     expected_shape = ((13, 1000))
+         }
+         expected_columns = 13
-     got = extractor._mfcc(self.test_signal, self.test_sr, **mfccs_kwargs)
+         got = extractor._mfcc(self.test_signal, self.test_sr, **mfccs_kwargs)
-     self.assertEqual(expected_shape, got.shape)  # TODO figure out num hops
+         self.assertEqual(expected_columns, got.shape[0])
  
Fix spacing. Update mfcc test to check columns
## Code Before:
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

## Instruction:
Fix spacing. Update mfcc test to check columns
## Code After:
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_columns = 13
        got = extractor._mfcc(self.test_signal, self.test_sr, **mfccs_kwargs)
        self.assertEqual(expected_columns, got.shape[0])
