Skip to content

Commit e0c7320

Browse files
committed
update
1 parent fde2538 commit e0c7320

File tree

2 files changed

+32
-32
lines changed

2 files changed

+32
-32
lines changed

labelbox/schema/ontology.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ class Classification:
9898
schema_id: (str)
9999
feature_schema_id: (str)
100100
"""
101+
101102
class Type(Enum):
102103
TEXT = "text"
103104
CHECKLIST = "checklist"
@@ -180,6 +181,7 @@ class Tool:
180181
schema_id: (str)
181182
feature_schema_id: (str)
182183
"""
184+
183185
class Type(Enum):
184186
POLYGON = "polygon"
185187
SEGMENTATION = "superpixel"
@@ -221,8 +223,8 @@ def asdict(self) -> Dict[str, Any]:
221223
}
222224

223225
def add_classification(self, classification: Classification):
224-
if classification.instructions in (c.instructions
225-
for c in self.classifications):
226+
if classification.instructions in (
227+
c.instructions for c in self.classifications):
226228
raise InconsistentOntologyException(
227229
f"Duplicate nested classification '{classification.instructions}' "
228230
f"for tool '{self.name}'")
@@ -345,9 +347,9 @@ def add_tool(self, tool: Tool) -> Tool:
345347

346348
def add_classification(self,
347349
classification: Classification) -> Classification:
348-
if classification.instructions in (c.instructions
349-
for c in self.classifications):
350+
if classification.instructions in (
351+
c.instructions for c in self.classifications):
350352
raise InconsistentOntologyException(
351353
f"Duplicate classification instructions '{classification.instructions}'. "
352354
)
353-
self.classifications.append(classification)
355+
self.classifications.append(classification)

tests/integration/test_ontology.py

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,39 +26,39 @@
2626
"classifications": []
2727
}, {
2828
"schemaNodeId":
29-
None,
29+
None,
3030
"featureSchemaId":
31-
None,
31+
None,
3232
"required":
33-
False,
33+
False,
3434
"name":
35-
"bbox",
35+
"bbox",
3636
"color":
37-
"#FF0000",
37+
"#FF0000",
3838
"tool":
39-
"rectangle",
39+
"rectangle",
4040
"classifications": [{
4141
"schemaNodeId":
42-
None,
42+
None,
4343
"featureSchemaId":
44-
None,
44+
None,
4545
"required":
46-
True,
46+
True,
4747
"instructions":
48-
"nested classification",
48+
"nested classification",
4949
"name":
50-
"nested classification",
50+
"nested classification",
5151
"type":
52-
"radio",
52+
"radio",
5353
"options": [{
5454
"schemaNodeId":
55-
None,
55+
None,
5656
"featureSchemaId":
57-
None,
57+
None,
5858
"label":
59-
"first",
59+
"first",
6060
"value":
61-
"first",
61+
"first",
6262
"options": [{
6363
"schemaNodeId": None,
6464
"featureSchemaId": None,
@@ -111,17 +111,17 @@
111111
}],
112112
"classifications": [{
113113
"schemaNodeId":
114-
None,
114+
None,
115115
"featureSchemaId":
116-
None,
116+
None,
117117
"required":
118-
True,
118+
True,
119119
"instructions":
120-
"This is a question.",
120+
"This is a question.",
121121
"name":
122-
"This is a question.",
122+
"This is a question.",
123123
"type":
124-
"radio",
124+
"radio",
125125
"options": [{
126126
"schemaNodeId": None,
127127
"featureSchemaId": None,
@@ -204,8 +204,7 @@ def test_add_ontology_classification() -> None:
204204

205205
def test_tool_add_classification() -> None:
206206
t = Tool(tool=Tool.Type.SEGMENTATION, name="segmentation")
207-
c = Classification(class_type=Classification.Type.TEXT,
208-
instructions="text")
207+
c = Classification(class_type=Classification.Type.TEXT, instructions="text")
209208
t.add_classification(c)
210209
assert t.classifications == [c]
211210

@@ -228,8 +227,7 @@ def test_classification_add_option() -> None:
228227

229228
def test_option_add_option() -> None:
230229
o = Option(value="option")
231-
c = Classification(class_type=Classification.Type.TEXT,
232-
instructions="text")
230+
c = Classification(class_type=Classification.Type.TEXT, instructions="text")
233231
o.add_option(c)
234232
assert o.options == [c]
235233

@@ -245,4 +243,4 @@ def test_ontology_asdict(project) -> None:
245243

246244
def test_from_project_ontology(client, project) -> None:
247245
o = OntologyBuilder.from_project(project)
248-
assert o.asdict() == project.ontology().normalized
246+
assert o.asdict() == project.ontology().normalized

0 commit comments

Comments
 (0)