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

Add tqdm to all iterators #181

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions convokit/model/conversation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from collections import defaultdict
from typing import Dict, List, Callable, Generator, Optional

from tqdm import tqdm

from convokit.util import warn
from .corpusComponent import CorpusComponent
from .corpusUtil import *
Expand Down Expand Up @@ -71,8 +73,8 @@ def iter_utterances(
By default, the selector includes all Utterances in the Conversation.
:return: a generator of Utterances
"""
for ut_id in self._utterance_ids:
utt = self._owner.get_utterance(ut_id)
for utt_id in tqdm(self._utterance_ids):
utt = self._owner.get_utterance(utt_id)
if selector(utt):
yield utt

Expand Down Expand Up @@ -134,7 +136,7 @@ def iter_speakers(
for ut_id in self._utterance_ids:
ut = self._owner.get_utterance(ut_id)
self._speaker_ids.add(ut.speaker.id)
for speaker_id in self._speaker_ids:
for speaker_id in tqdm(self._speaker_ids):
speaker = self._owner.get_speaker(speaker_id)
if selector(speaker):
yield speaker
Expand Down
6 changes: 3 additions & 3 deletions convokit/model/corpus.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ def iter_utterances(
By default, the selector includes all Utterances in the Corpus.
:return: a generator of Utterances
"""
for v in self.utterances.values():
for v in tqdm(self.utterances.values()):
if selector(v):
yield v

Expand Down Expand Up @@ -465,7 +465,7 @@ def iter_conversations(
By default, the selector includes all Conversations in the Corpus.
:return: a generator of Conversations
"""
for v in self.conversations.values():
for v in tqdm(self.conversations.values()):
if selector(v):
yield v

Expand Down Expand Up @@ -496,7 +496,7 @@ def iter_speakers(
:return: a generator of Speakers
"""

for speaker in self.speakers.values():
for speaker in tqdm(self.speakers.values()):
if selector(speaker):
yield speaker

Expand Down
6 changes: 4 additions & 2 deletions convokit/model/speaker.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from functools import total_ordering
from typing import Dict, List, Optional

from tqdm import tqdm

from .corpusComponent import CorpusComponent
from .corpusUtil import *

Expand Down Expand Up @@ -77,7 +79,7 @@ def iter_utterances(self, selector=lambda utt: True): # -> Generator[Utterance,
By default, the selector includes all Utterances in the Corpus.
:return: An iterator of the Utterances made by the speaker
"""
for v in self.utterances.values():
for v in tqdm(self.utterances.values()):
if selector(v):
yield v

Expand Down Expand Up @@ -117,7 +119,7 @@ def iter_conversations(

:return: An iterator of the Conversations that the speaker has participated in
"""
for v in self.conversations.values():
for v in tqdm(self.conversations.values()):
if selector(v):
yield v

Expand Down