Skip to content

Commit 3661952

Browse files
authored
Add unit test for item rename (#1237)
- Added unit test for item `rename` transform
1 parent fb7b6f9 commit 3661952

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4343
(<https://github.com/openvinotoolkit/datumaro/pull/1223>)
4444
- Handling undefined labels at the annotation statistics
4545
(<https://github.com/openvinotoolkit/datumaro/pull/1232>)
46+
- Add unit test for item rename
47+
(<https://github.com/openvinotoolkit/datumaro/pull/1237>)
4648

4749
## 16/11/2023 - Release 1.5.1
4850
### Enhancements

docs/source/docs/command-reference/context_free/transform.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ Examples:
157157

158158
- Remove the `frame_` prefix from item ids
159159
```console
160-
datum transform -t rename -- -e "|^frame_|\1|"
160+
datum transform -t rename -- -e "|^frame_|"
161161
```
162162

163163
- Collect images from subdirectories into the base image directory using regex

tests/unit/test_transforms.py

+19
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,25 @@ def test_random_split_gives_error_on_wrong_ratios(self):
582582
],
583583
)
584584

585+
@mark_requirement(Requirements.DATUM_GENERAL_REQ)
586+
def test_rename_item(self):
587+
src_dataset = Dataset.from_iterable(
588+
[
589+
DatasetItem(id="frame_1"),
590+
DatasetItem(id="frame_2"),
591+
DatasetItem(id="frame_3"),
592+
]
593+
)
594+
expected = Dataset.from_iterable(
595+
[
596+
DatasetItem(id="1"),
597+
DatasetItem(id="2"),
598+
DatasetItem(id="3"),
599+
]
600+
)
601+
actual = transforms.Rename(src_dataset, "|^frame_|")
602+
compare_datasets(self, expected, actual)
603+
585604
@mark_requirement(Requirements.DATUM_GENERAL_REQ)
586605
def test_remap_labels(self):
587606
src_dataset = Dataset.from_iterable(

0 commit comments

Comments
 (0)