def test_apply_mask_job(default_k2is, lt_ctx): mask = np.ones((1860, 2048)) tileshape = Shape( (16, 930, 16), sig_dims=2, ) tiling_scheme = TilingScheme.make_for_shape( tileshape=tileshape, dataset_shape=default_k2is.shape, ) job = ApplyMasksJob( dataset=default_k2is, mask_factories=[lambda: mask], tiling_scheme=tiling_scheme, ) out = job.get_result_buffer() executor = InlineJobExecutor() for tiles in executor.run_job(job): for tile in tiles: tile.reduce_into_result(out) results = lt_ctx.run(job) assert results[0].shape == (34 * 35, ) # there should be _something_ in each result pixel for px in results[0].reshape((-1, )): assert not np.isclose(px, 0)
def test_apply_mask_on_raw_job(default_blo, lt_ctx): mask = np.ones((144, 144)) job = ApplyMasksJob(dataset=default_blo, mask_factories=[lambda: mask]) out = job.get_result_buffer() executor = InlineJobExecutor() for tiles in executor.run_job(job): for tile in tiles: tile.reduce_into_result(out) results = lt_ctx.run(job) assert results[0].shape == (90 * 121, )
def test_apply_mask_on_empad_job(default_empad, lt_ctx): mask = np.ones((128, 128)) job = ApplyMasksJob(dataset=default_empad, mask_factories=[lambda: mask]) out = job.get_result_buffer() executor = InlineJobExecutor() for tiles in executor.run_job(job): for tile in tiles: tile.reduce_into_result(out) results = lt_ctx.run(job) assert results[0].shape == (4 * 4,) assert np.count_nonzero(results[0]) > 0
def test_apply_mask_on_raw_job(default_raw, lt_ctx): mask = np.ones((128, 128)) job = ApplyMasksJob(dataset=default_raw, mask_factories=[lambda: mask]) out = job.get_result_buffer() executor = InlineJobExecutor() for tiles in executor.run_job(job): for tile in tiles: tile.reduce_into_result(out) results = lt_ctx.run(job) # FIXME: should the result here be 1D or 2D? # currently, for inherently 4D datasets it is 2D, and for 3D datasets # it is 1D. make this consistent? assert results[0].shape == (16, 16)