def test_aggregate(): test_feature = Feature(test_dataframe, aggregate=np.median) assert (test_feature.aggregate == np.median)
from amen.audio import Audio from amen.feature import Feature from amen.feature import FeatureCollection from amen.timing import TimeSlice from amen.utils import example_audio_file from amen.exceptions import FeatureError EXAMPLE_FILE = example_audio_file() audio = Audio(EXAMPLE_FILE) test_times = np.linspace(0, 10, num=1000) test_index = pd.to_timedelta(test_times, unit='s') test_dataframe = pd.DataFrame(data=audio.analysis_samples[:1000], index=test_index) test_feature = Feature(test_dataframe) # Test init def test_data_validation(): # Makes sure that we can't pass lousy data. assert_raises(AssertionError, Feature, [1, 2, 3]) def test_data(): assert_frame_equal(test_feature.data, test_dataframe) def test_default_aggregate(): assert (test_feature.aggregate == np.mean)
def test_base_validation(): with pytest.raises(AssertionError): f = Feature(test_dataframe, np.mean, [1, 2, 3])
from amen.audio import Audio from amen.feature import Feature from amen.feature import FeatureCollection from amen.timing import TimeSlice from amen.utils import example_audio_file from amen.exceptions import FeatureError EXAMPLE_FILE = example_audio_file() audio = Audio(EXAMPLE_FILE) test_times = np.linspace(0, 10, num=1000) test_index = pd.to_timedelta(test_times, unit='s') test_dataframe = pd.DataFrame(data=audio.analysis_samples[:1000], index=test_index) test_feature = Feature(test_dataframe) # Test init def test_data_validation(): # Makes sure that we can't pass lousy data. assert_raises(AssertionError, Feature, [1, 2, 3]) def test_data(): assert_frame_equal(test_feature.data, test_dataframe) def test_default_aggregate(): assert(test_feature.aggregate == np.mean) def test_default_base(): assert(test_feature.base == None)
def test_data_validation(): with pytest.raises(AssertionError): f = Feature([1, 2, 3])