Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions tests/test_tile_on_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
]
)

for tile_size in [8, 16]:
for step in [4, 8]:
TEST_CASES.append([{"tile_count": 16, "step": step, "tile_size": tile_size}])


TEST_CASES2 = []
for tile_count in [16, 64]:
Expand All @@ -54,15 +58,28 @@


def make_image(
tile_count: int, tile_size: int, random_offset: bool = False, filter_mode: Optional[str] = None, seed=123, **kwargs
tile_count: int,
tile_size: int,
step: int = 0,
random_offset: bool = False,
filter_mode: Optional[str] = None,
seed=123,
**kwargs,
):

tile_count = int(np.sqrt(tile_count))
pad = 0
if random_offset:
pad = 3

image = np.random.randint(200, size=[3, tile_count * tile_size + pad, tile_count * tile_size + pad], dtype=np.uint8)
if step == 0:
step = tile_size

image = np.random.randint(
200,
size=[3, (tile_count - 1) * step + tile_size + pad, (tile_count - 1) * step + tile_size + pad],
dtype=np.uint8,
)
imlarge = image

random_state = np.random.RandomState(seed)
Expand All @@ -76,7 +93,7 @@ def make_image(
tiles_list = []
for x in range(tile_count):
for y in range(tile_count):
tiles_list.append(image[:, x * tile_size : (x + 1) * tile_size, y * tile_size : (y + 1) * tile_size])
tiles_list.append(image[:, x * step : x * step + tile_size, y * step : y * step + tile_size])

tiles = np.stack(tiles_list, axis=0) # type: ignore

Expand Down
29 changes: 26 additions & 3 deletions tests/test_tile_on_grid_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
)


for tile_size in [8, 16]:
for step in [4, 8]:
TEST_CASES.append([{"tile_count": 16, "step": step, "tile_size": tile_size}])


TEST_CASES2 = []
for tile_count in [16, 64]:
for tile_size in [8, 32]:
Expand All @@ -57,16 +62,34 @@
)


for tile_size in [8, 16]:
for step in [4, 8]:
TEST_CASES.append([{"tile_count": 16, "step": step, "tile_size": tile_size}])


def make_image(
tile_count: int, tile_size: int, random_offset: bool = False, filter_mode: Optional[str] = None, seed=123, **kwargs
tile_count: int,
tile_size: int,
step: int = 0,
random_offset: bool = False,
filter_mode: Optional[str] = None,
seed=123,
**kwargs,
):

tile_count = int(np.sqrt(tile_count))
pad = 0
if random_offset:
pad = 3

image = np.random.randint(200, size=[3, tile_count * tile_size + pad, tile_count * tile_size + pad], dtype=np.uint8)
if step == 0:
step = tile_size

image = np.random.randint(
200,
size=[3, (tile_count - 1) * step + tile_size + pad, (tile_count - 1) * step + tile_size + pad],
dtype=np.uint8,
)
imlarge = image

random_state = np.random.RandomState(seed)
Expand All @@ -80,7 +103,7 @@ def make_image(
tiles_list = []
for x in range(tile_count):
for y in range(tile_count):
tiles_list.append(image[:, x * tile_size : (x + 1) * tile_size, y * tile_size : (y + 1) * tile_size])
tiles_list.append(image[:, x * step : x * step + tile_size, y * step : y * step + tile_size])

tiles = np.stack(tiles_list, axis=0) # type: ignore

Expand Down