Skip to content

Commit 41d3834

Browse files
committed
implemented unit test for benchmark
1 parent 0de7fac commit 41d3834

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
from pathlib import Path
2+
import superannotate as sa
3+
4+
sa.init(Path.home() / ".superannotate" / "config.json")
5+
6+
test_root = Path().resolve() / 'tests'
7+
8+
9+
def test_benchmark():
10+
annot_types = ['polygon', 'bbox', 'point']
11+
gt_project_name = 'consensus_1'
12+
project_names = ['consensus_2', 'consensus_3']
13+
df_column_names = [
14+
'creatorEmail', 'imageName', 'instanceId', 'area', 'className',
15+
'attributes', 'projectName', 'score'
16+
]
17+
export_path = test_root / 'consensus_benchmark'
18+
for annot_type in annot_types:
19+
res_df = sa.benchmark(
20+
gt_project_name,
21+
project_names,
22+
export_root=export_path,
23+
annot_type=annot_type
24+
)
25+
#test content of projectName column
26+
assert sorted(res_df['projectName'].unique()) == project_names
27+
28+
#test structure of resulting DataFrame
29+
assert sorted(res_df.columns) == sorted(df_column_names)
30+
31+
#test lower bound of the score
32+
assert (res_df['score'] >= 0).all()
33+
34+
#test upper bound of the score
35+
assert (res_df['score'] <= 1).all()
36+
37+
image_names = [
38+
'bonn_000000_000019_leftImg8bit.png',
39+
'bielefeld_000000_000321_leftImg8bit.png'
40+
]
41+
42+
#test filtering images with given image names list
43+
res_images = sa.benchmark(
44+
gt_project_name,
45+
project_names,
46+
export_root=export_path,
47+
image_list=image_names
48+
)
49+
50+
assert sorted(res_images['imageName'].unique()) == sorted(image_names)

0 commit comments

Comments
 (0)