def test_round_window_boundless(path_alpha_tif): with rasterio.open(path_alpha_tif) as src: block_shapes = src.block_shapes test_window = ((256, 512), (1000, 1500)) rounded_window = round_window_to_full_blocks(test_window, block_shapes) block_shape = block_shapes[0] height_shape = block_shape[0] width_shape = block_shape[1] assert rounded_window.row_off % height_shape == 0 assert rounded_window.height % height_shape == 0 assert rounded_window.col_off % width_shape == 0 assert rounded_window.width % width_shape == 0
def test_round_window_boundless(): with rasterio.open('tests/data/alpha.tif') as src: block_shapes = src.block_shapes test_window = ((256, 512), (1000, 1500)) rounded_window = round_window_to_full_blocks(test_window, block_shapes) block_shape = block_shapes[0] height_shape = block_shape[0] width_shape = block_shape[1] assert rounded_window[0][0] % height_shape == 0 assert rounded_window[0][1] % height_shape == 0 assert rounded_window[1][0] % width_shape == 0 assert rounded_window[1][1] % width_shape == 0
def test_round_window_to_full_blocks(path_alpha_tif): with rasterio.open(path_alpha_tif) as src: block_shapes = src.block_shapes test_window = ((321, 548), (432, 765)) rounded_window = round_window_to_full_blocks(test_window, block_shapes) block_shape = block_shapes[0] height_shape = block_shape[0] width_shape = block_shape[1] assert rounded_window.row_off % height_shape == 0 assert rounded_window.height % height_shape == 0 assert rounded_window.col_off % width_shape == 0 assert rounded_window.width % width_shape == 0
def test_round_window_to_full_blocks(): with rasterio.open('tests/data/alpha.tif') as src: block_shapes = src.block_shapes test_window = ((321, 548), (432, 765)) rounded_window = round_window_to_full_blocks(test_window, block_shapes) block_shape = block_shapes[0] height_shape = block_shape[0] width_shape = block_shape[1] assert rounded_window[0][0] % height_shape == 0 assert rounded_window[0][1] % height_shape == 0 assert rounded_window[1][0] % width_shape == 0 assert rounded_window[1][1] % width_shape == 0
def test_round_window_already_at_edge(path_alpha_tif): with rasterio.open(path_alpha_tif) as src: block_shapes = src.block_shapes test_window = ((256, 512), (512, 768)) rounded_window = round_window_to_full_blocks(test_window, block_shapes) assert rounded_window == Window.from_slices(*test_window)
def test_round_window_to_full_blocks_error(): with pytest.raises(WindowError): round_window_to_full_blocks(Window(0, 0, 10, 10), block_shapes=[(1, 1), (2, 2)])
def test_round_window_already_at_edge(): with rasterio.open('tests/data/alpha.tif') as src: block_shapes = src.block_shapes test_window = ((256, 512), (512, 768)) rounded_window = round_window_to_full_blocks(test_window, block_shapes) assert rounded_window == test_window
def test_round_window_to_full_blocks_error(): with pytest.raises(WindowError): round_window_to_full_blocks( Window(0, 0, 10, 10), block_shapes=[(1, 1), (2, 2)])