@@ -103,6 +103,7 @@ class Classification:
103
103
schema_id: (str)
104
104
feature_schema_id: (str)
105
105
"""
106
+
106
107
class Type (Enum ):
107
108
TEXT = "text"
108
109
CHECKLIST = "checklist"
@@ -124,13 +125,12 @@ def name(self):
124
125
125
126
@classmethod
126
127
def from_dict (cls , dictionary : Dict [str , Any ]):
127
- return cls (
128
- class_type = cls .Type (dictionary ["type" ]),
129
- instructions = dictionary ["instructions" ],
130
- required = dictionary .get ("required" , False ),
131
- options = [Option .from_dict (o ) for o in dictionary ["options" ]],
132
- schema_id = dictionary .get ("schemaNodeId" , None ),
133
- feature_schema_id = dictionary .get ("featureSchemaId" , None ))
128
+ return cls (class_type = cls .Type (dictionary ["type" ]),
129
+ instructions = dictionary ["instructions" ],
130
+ required = dictionary .get ("required" , False ),
131
+ options = [Option .from_dict (o ) for o in dictionary ["options" ]],
132
+ schema_id = dictionary .get ("schemaNodeId" , None ),
133
+ feature_schema_id = dictionary .get ("featureSchemaId" , None ))
134
134
135
135
def asdict (self ) -> Dict [str , Any ]:
136
136
if self .class_type in self ._REQUIRES_OPTIONS \
@@ -185,6 +185,7 @@ class Tool:
185
185
schema_id: (str)
186
186
feature_schema_id: (str)
187
187
"""
188
+
188
189
class Type (Enum ):
189
190
POLYGON = "polygon"
190
191
SEGMENTATION = "superpixel"
@@ -226,8 +227,8 @@ def asdict(self) -> Dict[str, Any]:
226
227
}
227
228
228
229
def add_classification (self , classification : Classification ):
229
- if classification .instructions in (c . instructions
230
- for c in self .classifications ):
230
+ if classification .instructions in (
231
+ c . instructions for c in self .classifications ):
231
232
raise InconsistentOntologyException (
232
233
f"Duplicate nested classification '{ classification .instructions } ' "
233
234
f"for tool '{ self .name } '" )
@@ -348,8 +349,8 @@ def add_tool(self, tool: Tool):
348
349
self .tools .append (tool )
349
350
350
351
def add_classification (self , classification : Classification ):
351
- if classification .instructions in (c . instructions
352
- for c in self .classifications ):
352
+ if classification .instructions in (
353
+ c . instructions for c in self .classifications ):
353
354
raise InconsistentOntologyException (
354
355
f"Duplicate classification instructions '{ classification .instructions } '. "
355
356
)
0 commit comments