Example #1
0
def test_add_filter_config_var():
    """Tests adding a var that already exists."""
    configparam = EnumStr(".wav",
                          ".mp3",
                          ".aif",
                          convert=lambda x: x.replace("wav", "aif"))
    AddConfigVar('new_var', "doc", configparam)
    assert msaf.config.new_var == ".aif"
Example #2
0
"""Default configuration parameters for MSAF."""
import logging
import numpy as np

from msaf.configparser import \
    (AddConfigVar, BoolParam, ConfigParam, EnumStr, FloatParam,
     IntParam, StrParam, ListParam, MsafConfigParser)

_logger = logging.getLogger('msaf.configdefaults')

config = MsafConfigParser()

# Globals
AddConfigVar('default_bound_id', "Default boundary detection algorithm",
             EnumStr("sf", "cnmf", "foote", "olda", "scluster", "gt"))
AddConfigVar('default_label_id', "Default label detection algorithm",
             EnumStr(None, "cnmf", "fmc2d", "scluster"))

# Global analysis parameters
AddConfigVar('sample_rate', "Default Sample Rate to be used.", IntParam(22050))
AddConfigVar('n_fft', "FFT size", IntParam(4096))
AddConfigVar('hop_size', "Hop length in samples", IntParam(1024))

# Files and dirs
AddConfigVar('results_dir', "Default directory to store results.",
             StrParam("results"))
AddConfigVar('results_ext', "Default extension for the results file.",
             StrParam(".csv"))
AddConfigVar('out_boundaries_ext', "Default extension for output audio "
             "bounds.", StrParam("-bounds.wav"))
AddConfigVar('minimum_frames', "Minimum number of frames to activate "
Example #3
0
def test_wrong_addconfig_root_multsections():
    """Tests adding a var that already exists in the root with
    multiple sections and wrong root."""
    conf = namedtuple('conf', ['cqt'])
    AddConfigVar('cqt.bins', "doc", IntParam(1), root=conf)
Example #4
0
def test_wrong_addconfig_root():
    """Tests adding a var that already exists in the root."""
    AddConfigVar('sample_rate', "doc", IntParam(1), root=msaf.config)
Example #5
0
def test_none_str():
    """Adds a None String variable."""
    AddConfigVar('test.my_none_str', "Test None string", StrParam(None))
    assert msaf.config.test.my_none_str is None
Example #6
0
def test_bool_var():
    """Adds a boolean variable."""
    AddConfigVar('test.my_new_bool', "Test bool variable only for testing",
                 BoolParam(True))
    assert msaf.config.test.my_new_bool
Example #7
0
def test_wrong_list_param():
    """Tests a wrong list param."""
    AddConfigVar('new_var7', "doc", ListParam(42))
Example #8
0
def test_add_var():
    """Adds a config variable and checks that it's correctly stored."""
    val = 10
    AddConfigVar('test.new_var', "Test Variable only for unit testing",
                 IntParam(val))
    assert msaf.config.test.new_var == val
Example #9
0
def test_empty_list_param():
    """Tests an empty list param."""
    AddConfigVar('new_var6', "doc", ListParam([]))
Example #10
0
def test_wrong_boolparam():
    """Tests a wrong boolean param."""
    AddConfigVar('new_var5', "doc", BoolParam("falsitto"))
Example #11
0
def test_false_boolparam():
    """Tests a false boolean param."""
    AddConfigVar('new_var4', "doc", BoolParam("false"))
    assert not msaf.config.new_var4
Example #12
0
def test_invalid_enumstr():
    """Tests invalid enumstrings."""
    AddConfigVar('new_var4', "doc", EnumStr("caca", 42, "merda"))
Example #13
0
def test_allowoverride():
    """Tests overriding a variable that can be overridden."""
    configparam = EnumStr("caca", "merda", allow_override=True)
    AddConfigVar('new_var3', "doc", configparam)
    msaf.config.new_var3 = "merda"
    assert msaf.config.new_var3 == "merda"
Example #14
0
def test_allowoverride_fail():
    """Tests overriding a variable that can't be overridden."""
    configparam = EnumStr("caca", "merda", allow_override=False)
    AddConfigVar('new_var2', "doc", configparam)
    msaf.config.new_var2 = "caca2"  # Raise Exception
Example #15
0
def test_wrong_callable_arg():
    """Tests adding a var with a wrong callable default param."""
    # We can add it
    AddConfigVar('my_int', "doc", IntParam(sorted))
    # but it should fail when retrieving it
    msaf.config.my_int
Example #16
0
def test_add_existing_config_var():
    """Tests adding a var that already exists."""
    AddConfigVar('sample_rate', "doc", IntParam(1))