Esempio n. 1
0
        def test_get_single_obj_convert_to_string(self, idx):
            data_field = 'strings_list'
            field_loader, set_data = db_generator.get_test_data_FieldLoader(
                'train', data_field)

            data = field_loader.get(idx, convert_to_str=True)

            assert np.array_equal(data,
                                  ascii_to_str(set_data[data_field][idx]))
            assert isinstance(data, str)
Esempio n. 2
0
def test_SetLoader__init():
    h5obj = db_generator.load_hdf5_file()

    dataset = db_generator.dataset
    set_name = 'test'
    set_loader = SetLoader(h5obj[set_name])

    assert set_loader.set == set_name
    assert set_loader.object_fields == ascii_to_str(dataset[set_name]['object_fields'])
    assert set_loader.nelems == 5
Esempio n. 3
0
        def test_get_multi_obj_convert_to_string_in_memory(self):
            data_field = 'strings_list'
            field_loader, set_data = db_generator.get_test_data_FieldLoader(
                'train', data_field)

            field_loader.to_memory = True
            idx = list(range(3))
            data = field_loader.get(idx, convert_to_str=True)

            assert np.array_equal(data,
                                  ascii_to_str(set_data[data_field][idx]))
            assert isinstance(data, list)
Esempio n. 4
0
def test_ascii_to_str(sample, output):
    res = ascii_to_str(np.array(sample, dtype=np.uint8))
    assert(output == res)