Skip to content

Commit 19b65bd

Browse files
committed
Fix lint
1 parent 52f5549 commit 19b65bd

File tree

3 files changed

+28
-14
lines changed

3 files changed

+28
-14
lines changed

labelbox/data/annotation_types/classification/classification.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def __init__(self, **data: Any):
9393
"removed in a future release")
9494

9595

96-
class ClassificationAnnotation(BaseAnnotation, ConfidenceMixin):
96+
class ClassificationAnnotation(BaseAnnotation, ConfidenceMixin, CustomMetricsMixin):
9797
"""Classification annotations (non localized)
9898
9999
>>> ClassificationAnnotation(

labelbox/data/mixins.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ class CustomMetricsMixin(BaseModel):
5555
def dict(self, *args, **kwargs):
5656
res = super().dict(*args, **kwargs)
5757

58-
if "customMetrics" in res and res["customMetrics"] is None:
59-
res.pop("customMetrics")
58+
if "custom_metrics" in res and res["custom_metrics"] is None:
59+
res.pop("custom_metrics")
6060

6161
return res
6262

tests/data/annotation_types/classification/test_classification.py

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,16 @@ def test_classification_answer():
1313
feature_schema_id = "schema_id"
1414
name = "my_feature"
1515
confidence = 0.9
16-
answer = ClassificationAnswer(name=name, confidence=confidence)
16+
custom_metrics = [{ 'name': 'metric1', 'value': 2 }]
17+
answer = ClassificationAnswer(
18+
name=name,
19+
confidence=confidence,
20+
custom_metrics=custom_metrics)
1721

1822
assert answer.feature_schema_id is None
1923
assert answer.name == name
2024
assert answer.confidence == confidence
25+
assert answer.custom_metrics == custom_metrics
2126

2227
answer = ClassificationAnswer(feature_schema_id=feature_schema_id,
2328
name=name)
@@ -50,7 +55,7 @@ def test_subclass():
5055
'feature_schema_id': None,
5156
'extra': {},
5257
'value': {
53-
'answer': answer
58+
'answer': answer,
5459
},
5560
'message_id': None,
5661
}
@@ -63,7 +68,7 @@ def test_subclass():
6368
'feature_schema_id': feature_schema_id,
6469
'extra': {},
6570
'value': {
66-
'answer': answer
71+
'answer': answer,
6772
},
6873
'name': name,
6974
'message_id': None,
@@ -77,14 +82,17 @@ def test_subclass():
7782
'feature_schema_id': feature_schema_id,
7883
'extra': {},
7984
'value': {
80-
'answer': answer
85+
'answer': answer,
8186
},
8287
'message_id': None,
8388
}
8489

8590

8691
def test_radio():
87-
answer = ClassificationAnswer(name="1", confidence=0.81)
92+
answer = ClassificationAnswer(
93+
name="1",
94+
confidence=0.81,
95+
custom_metrics=[{ 'name': 'metric1', 'value': 0.99 }])
8896
feature_schema_id = "feature_schema_id"
8997
name = "my_feature"
9098

@@ -101,30 +109,34 @@ def test_radio():
101109
'feature_schema_id': None,
102110
'extra': {},
103111
'confidence': 0.81,
112+
'custom_metrics': [{ 'name': 'metric1', 'value': 0.99 }],
104113
}
105114
}
106115
classification = ClassificationAnnotation(
107116
value=Radio(answer=answer),
108117
feature_schema_id=feature_schema_id,
109-
name=name)
118+
name=name,
119+
custom_metrics=[{ 'name': 'metric1', 'value': 0.99 }])
110120
assert classification.dict() == {
111121
'name': name,
112122
'feature_schema_id': feature_schema_id,
113123
'extra': {},
124+
'custom_metrics': [{ 'name': 'metric1', 'value': 0.99 }],
114125
'value': {
115126
'answer': {
116127
'name': answer.name,
117128
'feature_schema_id': None,
118129
'extra': {},
119-
'confidence': 0.81
120-
}
130+
'confidence': 0.81,
131+
'custom_metrics': [{ 'name': 'metric1', 'value': 0.99 }]
132+
},
121133
},
122134
'message_id': None,
123135
}
124136

125137

126138
def test_checklist():
127-
answer = ClassificationAnswer(name="1", confidence=0.99)
139+
answer = ClassificationAnswer(name="1", confidence=0.99, custom_metrics=[{ 'name': 'metric1', 'value': 2 }])
128140
feature_schema_id = "feature_schema_id"
129141
name = "my_feature"
130142

@@ -140,7 +152,8 @@ def test_checklist():
140152
'name': answer.name,
141153
'feature_schema_id': None,
142154
'extra': {},
143-
'confidence': 0.99
155+
'confidence': 0.99,
156+
'custom_metrics': [{ 'name': 'metric1', 'value': 2 }],
144157
}]
145158
}
146159
classification = ClassificationAnnotation(
@@ -157,7 +170,8 @@ def test_checklist():
157170
'name': answer.name,
158171
'feature_schema_id': None,
159172
'extra': {},
160-
'confidence': 0.99
173+
'confidence': 0.99,
174+
'custom_metrics': [{ 'name': 'metric1', 'value': 2 }],
161175
}]
162176
},
163177
'message_id': None,

0 commit comments

Comments
 (0)