From 36619529dc96cb4ab1f4120ebc269df2b95d8ecc Mon Sep 17 00:00:00 2001 From: Sooah Lee Date: Mon, 8 Jan 2024 17:24:59 +0900 Subject: [PATCH] Add unit test for item rename (#1237) - Added unit test for item `rename` transform --- CHANGELOG.md | 2 ++ .../context_free/transform.md | 2 +- tests/unit/test_transforms.py | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b2547cd23..e412f41a62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 () - Handling undefined labels at the annotation statistics () +- Add unit test for item rename + () ## 16/11/2023 - Release 1.5.1 ### Enhancements diff --git a/docs/source/docs/command-reference/context_free/transform.md b/docs/source/docs/command-reference/context_free/transform.md index 50c6303448..0ac3e86f28 100644 --- a/docs/source/docs/command-reference/context_free/transform.md +++ b/docs/source/docs/command-reference/context_free/transform.md @@ -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 diff --git a/tests/unit/test_transforms.py b/tests/unit/test_transforms.py index 4d4ff15cc2..1de9c03138 100644 --- a/tests/unit/test_transforms.py +++ b/tests/unit/test_transforms.py @@ -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(