Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit test for item rename #1237

Merged
merged 2 commits into from
Jan 8, 2024
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
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
Loading