Skip to content

Commit

Permalink
Add unit test for item rename (#1237)
Browse files Browse the repository at this point in the history
- Added unit test for item `rename` transform
  • Loading branch information
sooahleex authored Jan 8, 2024
1 parent fb7b6f9 commit 3661952
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
(<https://github.com/openvinotoolkit/datumaro/pull/1223>)
- Handling undefined labels at the annotation statistics
(<https://github.com/openvinotoolkit/datumaro/pull/1232>)
- Add unit test for item rename
(<https://github.com/openvinotoolkit/datumaro/pull/1237>)

## 16/11/2023 - Release 1.5.1
### Enhancements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ Examples:

- Remove the `frame_` prefix from item ids
```console
datum transform -t rename -- -e "|^frame_|\1|"
datum transform -t rename -- -e "|^frame_|"
```

- Collect images from subdirectories into the base image directory using regex
Expand Down
19 changes: 19 additions & 0 deletions tests/unit/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,25 @@ def test_random_split_gives_error_on_wrong_ratios(self):
],
)

@mark_requirement(Requirements.DATUM_GENERAL_REQ)
def test_rename_item(self):
src_dataset = Dataset.from_iterable(
[
DatasetItem(id="frame_1"),
DatasetItem(id="frame_2"),
DatasetItem(id="frame_3"),
]
)
expected = Dataset.from_iterable(
[
DatasetItem(id="1"),
DatasetItem(id="2"),
DatasetItem(id="3"),
]
)
actual = transforms.Rename(src_dataset, "|^frame_|")
compare_datasets(self, expected, actual)

@mark_requirement(Requirements.DATUM_GENERAL_REQ)
def test_remap_labels(self):
src_dataset = Dataset.from_iterable(
Expand Down

0 comments on commit 3661952

Please sign in to comment.