Skip to content

Commit

Permalink
black formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristofferEdlund committed Oct 23, 2023
1 parent f661f0f commit b5e0539
Showing 1 changed file with 91 additions and 20 deletions.
111 changes: 91 additions & 20 deletions tests/darwin/exporter/formats/export_darwin_1_0_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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"),
Expand All @@ -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},
Expand All @@ -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"),
Expand All @@ -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",
}

Expand All @@ -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"),
Expand All @@ -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},
Expand All @@ -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"),
Expand All @@ -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"),
Expand All @@ -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"),
Expand All @@ -266,4 +337,4 @@ def test_tags(self):
},
"annotations": [{"tag": {}, "name": "tag_test", "slot_names": []}],
"dataset": "None",
}
}

0 comments on commit b5e0539

Please sign in to comment.