예제 #1
0
def test_run_rand_by_cell_list_self_timing_max_runtime():
    """
    tests run by cell list using a SelfTimingDataset and restricting the
    maximum runtime
    """
    fd = FakeDataset(sleep_time=0.1)
    std = test_cases.SelfTimingDataset(fd)
    cell_list = range(500)
    date_start = dt.datetime(2007, 1, 1)
    date_end = dt.datetime(2008, 1, 1)
    date_list = helper.generate_date_list(date_start,
                                          date_end,
                                          n=len(cell_list),
                                          max_spread=5,
                                          min_spread=5)

    @test_cases.measure('test_rand_cells', runs=3)
    def test():
        test_cases.read_rand_cells_by_cell_list(std,
                                                date_list,
                                                cell_list,
                                                max_runtime=0.4)

    results = test()
    assert std.cells_read == 12
    assert len(std.measurements['get_data']) == std.cells_read
예제 #2
0
def test_run_rand_by_cell_list_self_timing():
    """
    tests run by cell list

    Does no assertions at the moment, but shows how to use
    the class
    """
    fd = FakeDataset()
    std = test_cases.SelfTimingDataset(fd)
    cell_list = range(500)
    date_start = dt.datetime(2007, 1, 1)
    date_end = dt.datetime(2008, 1, 1)
    date_list = helper.generate_date_list(date_start,
                                          date_end,
                                          n=len(cell_list),
                                          max_spread=5,
                                          min_spread=5)

    @test_cases.measure('test_rand_cells', runs=3)
    def test():
        test_cases.read_rand_cells_by_cell_list(std, date_list, cell_list)

    results = test()
    assert std.cells_read == 500 * 0.01 * 3
    assert len(std.measurements['get_data']) == std.cells_read
예제 #3
0
def test_run_rand_by_gpi_list_self_timing_max_runtime():
    """
    tests run by gpi list
    """
    fd = FakeDataset(sleep_time=0.01)
    std = test_cases.SelfTimingDataset(fd)
    # setup grid point index list, must come from grid object or
    # sciDB
    # this test dataset has 10000 gpis of which 20 percent will be read
    gpi_list = range(10000)

    @test_cases.measure('test_rand_gpi', runs=3)
    def test():
        test_cases.read_rand_ts_by_gpi_list(std, gpi_list, max_runtime=0.5)

    results = test()
    assert std.ts_read <= (10000 * 0.01 * 3) / 2
    assert len(std.measurements['get_timeseries']) <= 150
예제 #4
0
def test_run_rand_by_gpi_list_self_timing():
    """
    tests run by gpi list

    Does no assertions at the moment, but shows how to use
    the class
    """
    fd = FakeDataset()
    std = test_cases.SelfTimingDataset(fd)
    # setup grid point index list, must come from grid object or
    # sciDB
    # this test dataset has 10000 gpis of which 20 percent will be read
    gpi_list = range(10000)

    @test_cases.measure('test_rand_gpi', runs=3)
    def test():
        test_cases.read_rand_ts_by_gpi_list(std, gpi_list)

    results = test()
    assert std.ts_read == 10000 * 0.01 * 3
    assert len(std.measurements['get_timeseries']) == 300
예제 #5
0
def test_run_rand_by_date_list_self_timing_max_runtime():
    """
    tests run by date list

    Does no assertions at the moment, but shows how to use
    the class
    """
    fd = FakeDataset(sleep_time=0.1)
    std = test_cases.SelfTimingDataset(fd)
    # setup grid point index list, must come from grid object or
    # sciDB
    # this test dataset has 1 year of dates of which 4 images will be read
    date_list = []
    for days in range(365):
        date_list.append(dt.datetime(2007, 1, 1) + dt.timedelta(days=days))

    @test_cases.measure('test_rand_date', runs=3)
    def test():
        test_cases.read_rand_img_by_date_list(std, date_list, max_runtime=0.3)

    results = test()
    assert std.img_read == 9
    assert len(std.measurements['get_avg_image']) == 9
예제 #6
0
def test_self_timing_dataset():
    fd = FakeDataset()
    std = test_cases.SelfTimingDataset(fd)

    std.get_timeseries(12)