Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance improvement 904 #907

Merged
merged 4 commits into from
Dec 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions forte/data/data_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -1598,12 +1598,14 @@ def require_annotations(entry_class=Annotation) -> bool:

# If we don't have any annotations but the items to check requires them,
# then we simply yield from an empty list.
# changed form using len(annotations) to num_annotations directly for
# improving the performance.
if (
len(self.annotations) == 0
self.num_annotations == 0
and isinstance(range_annotation, Annotation)
and require_annotations(Annotation)
) or (
len(self.audio_annotations) == 0
self.num_audio_annotations == 0
and isinstance(range_annotation, AudioAnnotation)
and require_annotations(AudioAnnotation)
):
Expand Down