Example #1
0
def test_API_get_buffer(config):
    test_name = test_API_get_buffer.__name__
    expected = 5

    buffer = get_buffer(config, key='validation')
    actual = len(buffer.read_ids)

    result = AssertThat(actual, expected).are_equal()
    print_test_result(result, test_name, expected, actual)
Example #2
0
def test_loader_read_id_length(data_filepath):
    test_name = test_loader_read_id_length.__name__
    expected = len('002f0f2d-ffc1-4072-82d3-6ce425d9724e')

    loader = DataLoader(data_filepath)
    actual = len(loader.load_read_ids()[0])

    result = AssertThat(actual, expected).are_equal()
    print_test_result(result, test_name, expected, actual)
Example #3
0
def test_API_get_generator(config):
    test_name = test_API_get_generator.__name__
    expected = 10

    generator = get_generator(config, key='validation')
    batches = next(generator.get_batches(10))
    actual = len(batches)

    result = AssertThat(actual, expected).are_equal()
    print_test_result(result, test_name, expected, actual)
Example #4
0
def test_loader_read_id_list_length(data_filepath):
    test_name = test_loader_read_id_list_length.__name__
    expected = 5

    loader = DataLoader(data_filepath)
    reads = loader.load_read_ids()
    actual = len(reads)

    result = AssertThat(actual, expected).are_equal()
    print_test_result(result, test_name, expected, actual)
Example #5
0
def test_loader_read_dacs_is_normilized(data_filepath):
    test_name = test_loader_read_dacs_is_normilized.__name__

    loader = DataLoader(data_filepath)
    read_id = loader.load_read_ids()[0]
    dacs, _, _ = loader.load_read(read_id)
    arr = np.array(dacs)
    actual = np.std(arr)
    result = AssertThat(actual).is_in_interval(0.99, 1.01)
    print_test_result(result, test_name,
                      "std of signal to be < 1.3 and > 0.7.", actual)
Example #6
0
def test_loader_read_dacs_list_elemnt(data_filepath):
    test_name = test_loader_read_dacs_list_elemnt.__name__
    expected = np.float64

    loader = DataLoader(data_filepath)
    read_id = loader.load_read_ids()[0]
    dacs, _, _ = loader.load_read(read_id)
    actual = type(dacs[0])

    result = AssertThat(actual, expected).are_equal()
    print_test_result(result, test_name, expected, actual)
def test_generator_get_batch_y_end_token(buffer, label_window_size):
    setup(buffer)
    test_name = test_generator_get_batch_y_end_token.__name__

    generator = DataGenerator(buffer, label_window_size)
    _, y = next(generator.get_batch())
    end_token_indexes = np.where(y[0] == 6)[0]

    result = AssertThat(len(end_token_indexes), 1).are_equal()
    print_test_result(result, test_name, 1, len(end_token_indexes))
    teardown(buffer)
def test_generator_get_batched_read_x_shape(buffer, label_window_size):
    setup(buffer)
    test_name = test_generator_get_batched_read_x_shape.__name__
    expected = (buffer.signal_window_size, 1)  # (any, 300, 1)

    generator = DataGenerator(buffer, label_window_size)
    x, _, _, _, _ = next(generator.get_batched_read())
    actual = x.shape[1:]

    result = AssertThat(actual, expected).are_equal()
    print_test_result(result, test_name, expected, actual)
    teardown(buffer)
def test_generator_get_batch_y_start_token(buffer, label_window_size):
    setup(buffer)
    test_name = test_generator_get_batch_y_start_token.__name__
    expected = 5

    generator = DataGenerator(buffer, label_window_size)
    _, y = next(generator.get_batch())
    actual = y[0][0]

    result = AssertThat(actual, expected).are_equal()
    print_test_result(result, test_name, expected, actual)
    teardown(buffer)
def test_generator_get_batch_y_shape(buffer, label_window_size):
    setup(buffer)
    test_name = test_generator_get_batch_y_shape.__name__
    expected = (buffer.batch_size, label_window_size)  #(32,100)

    generator = DataGenerator(buffer, label_window_size)
    _, y = next(generator.get_batch())
    actual = y.shape

    result = AssertThat(actual, expected).are_equal()
    print_test_result(result, test_name, expected, actual)
    teardown(buffer)
def test_buffer_get_batch_y_shape(data_loader):
    test_name = test_buffer_get_batch_y_shape.__name__
    expected = (32,)
    
    batch_size = 32
    buffer_size = 5
    signal_window_size = 300
    signal_window_stride = 30
    min_labels_per_window = 1
    buffer = DataBuffer(data_loader, buffer_size, batch_size, signal_window_size, signal_window_stride)
    _, y = buffer.get_batch()
    actual = y.shape

    result = AssertThat(actual, expected).are_equal()
    print_test_result(result, test_name, expected, actual)
def test_generator_get_batch_y_padding(buffer, label_window_size):
    setup(buffer)
    test_name = test_generator_get_batch_y_padding.__name__

    generator = DataGenerator(buffer, label_window_size)
    _, y = next(generator.get_batch())
    end_token_indexes = np.where(y[0] == 6)[0]
    i = end_token_indexes[0]

    padding = y[0][i + 1:]
    zeros = np.where(padding == 0)[0]

    result = AssertThat(len(zeros), len(padding)).are_equal()
    print_test_result(result, f'{test_name}_only_zero_padding', len(padding),
                      len(zeros))
    teardown(buffer)
def test_buffer_get_batched_read_x_shape(data_loader):
    test_name = test_buffer_get_batched_read_x_shape.__name__
    
    batch_size = 32
    buffer_size = 5
    signal_window_size = 300
    signal_window_stride = 30
    min_labels_per_window = 1
    buffer = DataBuffer(data_loader, buffer_size, batch_size, signal_window_size, signal_window_stride)
    x, _, _, _, _ = buffer.get_batched_read()
    actual = np.array(x).shape

    result1 = AssertThat(actual[0]).is_in_interval(5e2, 1e5)
    result2 = AssertThat(actual[1], 300).are_equal()
    result3 = AssertThat(actual[2], 1).are_equal()

    print_test_result(result1, f'{test_name}_a', f'Value betweem {5e2} - {1e5}', actual[0])
    print_test_result(result1, f'{test_name}_b', 300, actual[1])
    print_test_result(result1, f'{test_name}_c', 1, actual[2])
Example #14
0
def test_API_get_trained_model(config, experiment_name):
    test_name = test_API_get_trained_model.__name__
    actual = get_trained_model(config, experiment_name)
    result = AssertThat(actual).is_instance_of(FishNChips)
    print_test_result(result, f'{test_name}', 'Is isntance of FishNChips',
                      actual)
Example #15
0
def test_API_get_new_model(config):
    test_name = test_API_get_new_model.__name__
    actual = get_new_model(config)
    result = AssertThat(actual).is_instance_of(FishNChips)
    print_test_result(result, test_name, 'Is isntance of FishNChips', actual)