Skip to content

Commit

Permalink
address linter comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bvreede committed Nov 21, 2023
1 parent 6a34489 commit c5c3430
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions sktalk/corpus/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def _subconversation(self,
"`time_or_index` must be either 'time' or 'index'")
return Conversation(utterances=returned_utterances)

def _count_participants(self) -> int:
def count_participants(self) -> int:
"""Count the number of participants in a conversation
Importantly: if one of the utterances has no participant, it is counted
Expand Down Expand Up @@ -183,11 +183,11 @@ def calculate_FTO(self, window: int = 10000, planning_buffer: int = 200, n_parti
time_or_index="time",
before=window,
after=0)
if not 2 <= sub._count_participants() <= n_participants:
if not 2 <= sub.count_participants() <= n_participants:
values.append(None)
continue
potentials = [
u for u in sub.utterances if utterance._relevant_for_fto(u, planning_buffer)]
u for u in sub.utterances if utterance.relevant_for_fto(u, planning_buffer)]
try:
relevant = potentials[-1]
values.append(utterance.until(relevant))
Expand All @@ -206,6 +206,6 @@ def overlap(begin: int, end: int, time: list):
# time[0] is before begin and time[1] is after end
if time is None:
return False
elif begin <= time[0] <= end or begin <= time[1] <= end:
if begin <= time[0] <= end or begin <= time[1] <= end:
return True
return time[0] <= begin and time[1] >= end
2 changes: 1 addition & 1 deletion sktalk/corpus/utterance.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def _clean_utterance(self):
def until(self, next_utt):
return next_utt.time[0] - self.time[1]

def _relevant_for_fto(self, prior_utt, planning_buffer: int):
def relevant_for_fto(self, prior_utt, planning_buffer: int):
"""Assess whether an utterance is potentially relevant to calculate FTO
An utterance is potentially relevant for fto calculation if:
Expand Down
14 changes: 7 additions & 7 deletions tests/corpus/test_conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class TestConversationMetrics:
def test_subconversation_errors(self, convo, args, error):
index, before, after, time_or_index = args
with error:
convo._subconversation(index=index,
convo._subconversation(index=index, #noqa W0212
before=before,
after=after,
time_or_index=time_or_index)
Expand All @@ -78,7 +78,7 @@ def test_subconversation_errors(self, convo, args, error):
])
def test_subconversation(self, convo, args, expected_length):
index, before, after, time_or_index = args
sub = convo._subconversation(index=index,
sub = convo._subconversation(index=index, #noqa W0212
before=before,
after=after,
time_or_index=time_or_index)
Expand All @@ -100,8 +100,8 @@ def test_overlap(self):
70, 80, [90, 110]) # utterance after window

def test_count_participants(self, convo):
assert convo._count_participants() == 3
convo2 = convo._subconversation(index=0, before=2)
assert convo2._count_participants() == 2
convo3 = convo._subconversation(index=0)
assert convo3._count_participants() == 1
assert convo.count_participants() == 3
convo2 = convo._subconversation(index=0, before=2) #noqa W0212
assert convo2.count_participants() == 2
convo3 = convo._subconversation(index=0) #noqa W0212
assert convo3.count_participants() == 1

0 comments on commit c5c3430

Please sign in to comment.