Used loops instead of list comprehension

This commit is contained in:
kinaryml 2022-11-08 10:57:12 -08:00
parent 0fd78c2ec6
commit 72f08c6878

View File

@ -48,15 +48,13 @@ class Classifications:
def to_pb2(self) -> _ClassificationsProto: def to_pb2(self) -> _ClassificationsProto:
"""Generates a Classifications protobuf object.""" """Generates a Classifications protobuf object."""
classification_list_proto = _ClassificationListProto() classification_list_proto = _ClassificationListProto()
classification_list_proto.classification.extend([ for category in self.categories:
_ClassificationProto( classification_proto = _ClassificationProto(
index=category.index, index=category.index,
score=category.score, score=category.score,
label=category.category_name, label=category.category_name,
display_name=category.display_name display_name=category.display_name)
) classification_list_proto.classification.append(classification_proto)
for category in self.categories
])
return _ClassificationsProto( return _ClassificationsProto(
classification_list=classification_list_proto, classification_list=classification_list_proto,
head_index=self.head_index, head_index=self.head_index,