def test_dataset_errors(): with pytest.raises(ValueError): soundata.initialize("not_a_dataset") d = soundata.initialize("orchset") d._track_class = None with pytest.raises(AttributeError): d.track("asdf") with pytest.raises(AttributeError): d.multitrack("asdf") with pytest.raises(AttributeError): d.load_tracks() with pytest.raises(AttributeError): d.load_multitracks() with pytest.raises(AttributeError): d.choice_track() with pytest.raises(AttributeError): d.choice_multitrack() d = soundata.initialize("acousticbrainz_genre") with pytest.raises(FileNotFoundError): d._index d = soundata.initialize("phenicx_anechoic") with pytest.raises(ValueError): d._multitrack("a")
def test_initialize(): d = initialize("esc50") assert isinstance(d, core.Dataset) assert d.name == "esc50" with pytest.raises(ValueError): initialize("asdfasdfasdfa")
def test_dataset(): dataset = soundata.initialize("esc50") assert isinstance(dataset, core.Dataset) dataset = soundata.initialize("urbansound8k") assert isinstance(dataset, core.Dataset) dataset = soundata.initialize("urbansed") assert isinstance(dataset, core.Dataset) print(dataset) # test that repr doesn't fail
def test_dataset(): dataset = soundata.initialize("guitarset") assert isinstance(dataset, core.Dataset) dataset = soundata.initialize("rwc_jazz") assert isinstance(dataset, core.Dataset) dataset = soundata.initialize("ikala") assert isinstance(dataset, core.Dataset) dataset = soundata.initialize("phenicx_anechoic") assert isinstance(dataset, core.Dataset) print(dataset) # test that repr doesn't fail
def dataset(test_dataset): if test_dataset == "": return None elif test_dataset not in soundata.DATASETS: raise ValueError( "{} is not a dataset in soundata".format(test_dataset)) data_home = os.path.join("tests/resources/mir_datasets_full", test_dataset) return soundata.initialize(test_dataset, data_home)
def test_multitracks(): data_home_dir = "tests/resources/mir_datasets" for dataset_name in DATASETS: module = importlib.import_module( "soundata.datasets.{}".format(dataset_name)) dataset = module.Dataset(os.path.join(TEST_DATA_HOME, dataset_name)) # TODO this is currently an opt-in test. Make it an opt out test # once #265 is addressed if dataset_name in CUSTOM_TEST_MTRACKS: mtrack_id = CUSTOM_TEST_MTRACKS[dataset_name] else: # there are no multitracks continue try: mtrack_default = dataset.MultiTrack(mtrack_id) except: assert False, "{}: {}".format(dataset_name, sys.exc_info()[0]) # test data home specified data_home = os.path.join(data_home_dir, dataset_name) dataset_specific = soundata.initialize(dataset_name, data_home=data_home) try: mtrack_test = dataset_specific.MultiTrack(mtrack_id, data_home=data_home) except: assert False, "{}: {}".format(dataset_name, sys.exc_info()[0]) assert isinstance( mtrack_test, core.MultiTrack ), "{}.MultiTrack must be an instance of type core.MultiTrack".format( dataset_name) assert hasattr( mtrack_test, "to_jams"), "{}.MultiTrack must have a to_jams method".format( dataset_name) # Validate JSON schema try: jam = mtrack_test.to_jams() except: assert False, "{}: {}".format(dataset_name, sys.exc_info()[0]) assert jam.validate( ), "Jams validation failed for {}.MultiTrack({})".format( dataset_name, mtrack_id)
def test_dataset_errors(): with pytest.raises(ValueError): soundata.initialize("not_a_dataset") d = soundata.initialize("esc50") d._clip_class = None with pytest.raises(AttributeError): d.clip("asdf") with pytest.raises(AttributeError): d.clipgroup("asdf") with pytest.raises(AttributeError): d.load_clips() with pytest.raises(AttributeError): d.load_clipgroups() with pytest.raises(AttributeError): d.choice_clip() with pytest.raises(AttributeError): d.choice_clipgroup()