diff --git a/tests/unit/test_annotation.py b/tests/unit/test_annotation.py index 6fcf5bc04c..b7b0ad5ac3 100644 --- a/tests/unit/test_annotation.py +++ b/tests/unit/test_annotation.py @@ -244,11 +244,17 @@ class PointsPositionsValidatorTest: """Tests for the validator of the `positions` field in PointsCategories.Category.""" @staticmethod - def test_empty_positions(): + def test_empty_positions_list(): """Test that an empty list of positions is allowed.""" obj = PointsCategories.Category(positions=[]) assert obj.positions == [] # Should allow empty list + @staticmethod + def test_empty_positions_tuple(): + """Test that an empty list of positions is allowed.""" + obj = PointsCategories.Category(positions=()) + assert obj.positions == [] # Should allow empty list + @staticmethod def test_none_positions(): """Test that None is allowed and converted to an empty list.""" @@ -300,3 +306,19 @@ def test_num_positions_not_same_as_num_labels(): ValueError, match="number of positions should be equal to the number of labels" ): PointsCategories.Category(labels=labels, positions=positions) + + @staticmethod + def test_positions_allowed_with_empty_labels(): + """Test that the the number of coordinates check is skipped when labels is empty.""" + labels = [] # no labels + positions = [1.0, 2.0, 3.0, 4.0] # 2 positions + obj = PointsCategories.Category(labels=labels, positions=positions) + assert obj + + @staticmethod + def test_labels_allowed_with_empty_positions(): + """Test that the the number of coordinates check is skipped when positions is empty.""" + labels = ["p1", "p2", "p3"] # 3 labels + positions = [] # no positions + obj = PointsCategories.Category(labels=labels, positions=positions) + assert obj