def test_missing_data_with_negative_sync_offset(lt_ctx): nav_shape = (16, 8) sync_offset = -8 ds = SEQDataSet( path=SEQ_TESTDATA_PATH, nav_shape=nav_shape, sync_offset=sync_offset ) ds.set_num_cores(4) ds = ds.initialize(lt_ctx.executor) tileshape = Shape( (4,) + tuple(ds.shape.sig), sig_dims=ds.shape.sig.dims ) tiling_scheme = TilingScheme.make_for_shape( tileshape=tileshape, dataset_shape=ds.shape, ) for p in ds.get_partitions(): for t in p.get_tiles(tiling_scheme=tiling_scheme): pass assert p._start_frame == 88 assert p._num_frames == 32 assert t.tile_slice.origin == (68, 0, 0) assert t.tile_slice.shape[0] == 4
def test_missing_frames(lt_ctx): nav_shape = (16, 8) ds = SEQDataSet(path=SEQ_TESTDATA_PATH, nav_shape=nav_shape) ds.set_num_cores(4) ds = ds.initialize(lt_ctx.executor) ds.check_valid() tileshape = Shape( (4,) + tuple(ds.shape.sig), sig_dims=ds.shape.sig.dims ) tiling_scheme = TilingScheme.make_for_shape( tileshape=tileshape, dataset_shape=ds.shape, ) for p in ds.get_partitions(): for t in p.get_tiles(tiling_scheme=tiling_scheme): pass assert p._start_frame == 96 assert p._num_frames == 32 assert p.slice.origin == (96, 0, 0) assert p.slice.shape[0] == 32 assert t.tile_slice.origin == (60, 0, 0) assert t.tile_slice.shape[0] == 4
def test_positive_sync_offset(default_seq, lt_ctx): udf = SumSigUDF() sync_offset = 2 ds_with_offset = SEQDataSet( path=SEQ_TESTDATA_PATH, nav_shape=(8, 8), sync_offset=sync_offset ) ds_with_offset.set_num_cores(4) ds_with_offset = ds_with_offset.initialize(lt_ctx.executor) ds_with_offset.check_valid() p0 = next(ds_with_offset.get_partitions()) assert p0._start_frame == 2 assert p0.slice.origin == (0, 0, 0) tileshape = Shape( (4,) + tuple(ds_with_offset.shape.sig), sig_dims=ds_with_offset.shape.sig.dims ) tiling_scheme = TilingScheme.make_for_shape( tileshape=tileshape, dataset_shape=ds_with_offset.shape, ) t0 = next(p0.get_tiles(tiling_scheme)) assert tuple(t0.tile_slice.origin) == (0, 0, 0) for p in ds_with_offset.get_partitions(): for t in p.get_tiles(tiling_scheme=tiling_scheme): pass assert p.slice.origin == (48, 0, 0) assert p.slice.shape[0] == 16 result = lt_ctx.run_udf(dataset=default_seq, udf=udf) result = result['intensity'].raw_data[sync_offset:] result_with_offset = lt_ctx.run_udf(dataset=ds_with_offset, udf=udf) result_with_offset = result_with_offset['intensity'].raw_data[ :ds_with_offset._meta.image_count - sync_offset ] assert np.allclose(result, result_with_offset)
def test_no_sync_offset_seq(lt_ctx, benchmark): nav_shape = (8, 8) ds = SEQDataSet(path=SEQ_TESTDATA_PATH, nav_shape=nav_shape) ds.set_num_cores(4) ds = ds.initialize(lt_ctx.executor) tileshape = Shape((4, ) + tuple(ds.shape.sig), sig_dims=ds.shape.sig.dims) tiling_scheme = TilingScheme.make_for_shape( tileshape=tileshape, dataset_shape=ds.shape, ) p0 = next(ds.get_partitions()) benchmark(get_first_tile, p0=p0, tiling_scheme=tiling_scheme)
def test_too_many_frames(lt_ctx): nav_shape = (4, 8) ds = SEQDataSet(path=SEQ_TESTDATA_PATH, nav_shape=nav_shape) ds.set_num_cores(4) ds = ds.initialize(lt_ctx.executor) ds.check_valid() tileshape = Shape((4, ) + tuple(ds.shape.sig), sig_dims=ds.shape.sig.dims) tiling_scheme = TilingScheme.make_for_shape( tileshape=tileshape, dataset_shape=ds.shape, ) for p in ds.get_partitions(): for t in p.get_tiles(tiling_scheme=tiling_scheme): pass