diff --git a/tests/darwin/exporter/formats/export_darwin_1_0_test.py b/tests/darwin/exporter/formats/export_darwin_1_0_test.py index 62226394f..5df8cb300 100644 --- a/tests/darwin/exporter/formats/export_darwin_1_0_test.py +++ b/tests/darwin/exporter/formats/export_darwin_1_0_test.py @@ -6,7 +6,12 @@ class TestBuildJson: def test_empty_annotation_file(self): - annotation_file = dt.AnnotationFile(path=Path("test.json"), filename="test.json", annotation_classes=[], annotations=[]) + annotation_file = dt.AnnotationFile( + path=Path("test.json"), + filename="test.json", + annotation_classes=[], + annotations=[], + ) assert _build_json(annotation_file) == { "image": { @@ -57,7 +62,9 @@ def test_complete_annotation_file(self): ] annotation_class = dt.AnnotationClass(name="test", annotation_type="polygon") - annotation = dt.Annotation(annotation_class=annotation_class, data={"path": polygon_path}, subs=[]) + annotation = dt.Annotation( + annotation_class=annotation_class, data={"path": polygon_path}, subs=[] + ) annotation_file = dt.AnnotationFile( path=Path("test.json"), @@ -81,14 +88,24 @@ def test_complete_annotation_file(self): "path": None, "workview_url": None, }, - "annotations": [{"polygon": {"path": polygon_path}, "name": "test", "slot_names": []}], + "annotations": [ + {"polygon": {"path": polygon_path}, "name": "test", "slot_names": []} + ], "dataset": "None", } def test_complex_polygon(self): polygon_path = [ - [{"x": 230.06, "y": 174.04}, {"x": 226.39, "y": 170.36}, {"x": 224.61, "y": 166.81}], - [{"x": 238.98, "y": 171.69}, {"x": 236.97, "y": 174.04}, {"x": 238.67, "y": 174.04}], + [ + {"x": 230.06, "y": 174.04}, + {"x": 226.39, "y": 170.36}, + {"x": 224.61, "y": 166.81}, + ], + [ + {"x": 238.98, "y": 171.69}, + {"x": 236.97, "y": 174.04}, + {"x": 238.67, "y": 174.04}, + ], [ {"x": 251.75, "y": 169.77}, {"x": 251.75, "y": 154.34}, @@ -97,8 +114,12 @@ def test_complex_polygon(self): ], ] - annotation_class = dt.AnnotationClass(name="test", annotation_type="complex_polygon") - annotation = dt.Annotation(annotation_class=annotation_class, data={"paths": polygon_path}, subs=[]) + annotation_class = dt.AnnotationClass( + name="test", annotation_type="complex_polygon" + ) + annotation = dt.Annotation( + annotation_class=annotation_class, data={"paths": polygon_path}, subs=[] + ) annotation_file = dt.AnnotationFile( path=Path("test.json"), @@ -122,7 +143,13 @@ def test_complex_polygon(self): "path": None, "workview_url": None, }, - "annotations": [{"complex_polygon": {"path": polygon_path}, "name": "test", "slot_names": []}], + "annotations": [ + { + "complex_polygon": {"path": polygon_path}, + "name": "test", + "slot_names": [], + } + ], "dataset": "None", } @@ -136,7 +163,11 @@ def test_polygon_annotation_file_with_bbox(self): bounding_box = {"x": 557.66, "y": 428.98, "w": 160.76, "h": 315.3} annotation_class = dt.AnnotationClass(name="test", annotation_type="polygon") - annotation = dt.Annotation(annotation_class=annotation_class, data={"path": polygon_path, "bounding_box": bounding_box}, subs=[]) + annotation = dt.Annotation( + annotation_class=annotation_class, + data={"path": polygon_path, "bounding_box": bounding_box}, + subs=[], + ) annotation_file = dt.AnnotationFile( path=Path("test.json"), @@ -160,14 +191,29 @@ def test_polygon_annotation_file_with_bbox(self): "path": None, "workview_url": None, }, - "annotations": [{"polygon": {"path": polygon_path}, "name": "test", "slot_names": [], "bounding_box": bounding_box}], + "annotations": [ + { + "polygon": {"path": polygon_path}, + "name": "test", + "slot_names": [], + "bounding_box": bounding_box, + } + ], "dataset": "None", } def test_complex_polygon_with_bbox(self): polygon_path = [ - [{"x": 230.06, "y": 174.04}, {"x": 226.39, "y": 170.36}, {"x": 224.61, "y": 166.81}], - [{"x": 238.98, "y": 171.69}, {"x": 236.97, "y": 174.04}, {"x": 238.67, "y": 174.04}], + [ + {"x": 230.06, "y": 174.04}, + {"x": 226.39, "y": 170.36}, + {"x": 224.61, "y": 166.81}, + ], + [ + {"x": 238.98, "y": 171.69}, + {"x": 236.97, "y": 174.04}, + {"x": 238.67, "y": 174.04}, + ], [ {"x": 251.75, "y": 169.77}, {"x": 251.75, "y": 154.34}, @@ -178,8 +224,14 @@ def test_complex_polygon_with_bbox(self): bounding_box = {"x": 557.66, "y": 428.98, "w": 160.76, "h": 315.3} - annotation_class = dt.AnnotationClass(name="test", annotation_type="complex_polygon") - annotation = dt.Annotation(annotation_class=annotation_class, data={"paths": polygon_path, "bounding_box": bounding_box}, subs=[]) + annotation_class = dt.AnnotationClass( + name="test", annotation_type="complex_polygon" + ) + annotation = dt.Annotation( + annotation_class=annotation_class, + data={"paths": polygon_path, "bounding_box": bounding_box}, + subs=[], + ) annotation_file = dt.AnnotationFile( path=Path("test.json"), @@ -203,14 +255,25 @@ def test_complex_polygon_with_bbox(self): "path": None, "workview_url": None, }, - "annotations": [{"complex_polygon": {"path": polygon_path}, "name": "test", "slot_names": [], "bounding_box": bounding_box}], + "annotations": [ + { + "complex_polygon": {"path": polygon_path}, + "name": "test", + "slot_names": [], + "bounding_box": bounding_box, + } + ], "dataset": "None", } def test_bounding_box(self): bounding_box_data = {"x": 100, "y": 150, "w": 50, "h": 30} - annotation_class = dt.AnnotationClass(name="bbox_test", annotation_type="bounding_box") - annotation = dt.Annotation(annotation_class=annotation_class, data=bounding_box_data, subs=[]) + annotation_class = dt.AnnotationClass( + name="bbox_test", annotation_type="bounding_box" + ) + annotation = dt.Annotation( + annotation_class=annotation_class, data=bounding_box_data, subs=[] + ) annotation_file = dt.AnnotationFile( path=Path("test.json"), @@ -234,14 +297,22 @@ def test_bounding_box(self): "path": None, "workview_url": None, }, - "annotations": [{"bounding_box": bounding_box_data, "name": "bbox_test", "slot_names": []}], + "annotations": [ + { + "bounding_box": bounding_box_data, + "name": "bbox_test", + "slot_names": [], + } + ], "dataset": "None", } def test_tags(self): tag_data = "sample_tag" annotation_class = dt.AnnotationClass(name="tag_test", annotation_type="tag") - annotation = dt.Annotation(annotation_class=annotation_class, data=tag_data, subs=[]) + annotation = dt.Annotation( + annotation_class=annotation_class, data=tag_data, subs=[] + ) annotation_file = dt.AnnotationFile( path=Path("test.json"), @@ -266,4 +337,4 @@ def test_tags(self): }, "annotations": [{"tag": {}, "name": "tag_test", "slot_names": []}], "dataset": "None", - } \ No newline at end of file + }