Skip to content

Commit

Permalink
Compare item ids in tests
Browse files Browse the repository at this point in the history
Signed-off-by: Ilya Trushkin <ilya.trushkin@intel.com>
  • Loading branch information
itrushkin committed Jan 28, 2024
1 parent 3d8ae86 commit bdbe2c2
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions tests/unit/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2049,23 +2049,28 @@ def test_index_access_tile(self):
dataset = Dataset.from_iterable(
DatasetItem(
id,
media=Image.from_numpy(data=np.ones((10, 6, 3))),
media=Image.from_numpy(data=np.ones((224, 224, 3))),
annotations=[
Bbox(1, 2, 3, 4, label=1),
],
)
for id in range(5)
)
length = len(dataset)
n_rows, n_cols = (1, 2)
n_rows, n_cols = (4, 4)
dataset.transform("tile", grid_size=(n_rows, n_cols), overlap=(0, 0), threshold_drop_ann=0)
tiled_length = length * n_rows * n_cols
for i in range(tiled_length):
dataset[i]
for i in range(length):
for row in range(n_rows):
for col in range(n_cols):
idx = i * n_rows * n_cols + row * n_cols + col
_id = f"{i}_tile_{row * n_cols + col}"
self.assertEqual(dataset[idx].id, _id)
self.assertRaises(IndexError, lambda: dataset[tiled_length])

dataset.transform("merge_tile")
for i in range(length):
dataset[i]
self.assertEqual(dataset[i].id, str(i))
self.assertRaises(IndexError, lambda: dataset[length])


Expand Down

0 comments on commit bdbe2c2

Please sign in to comment.