Skip to content

Commit

Permalink
address linter issues and update fto calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
bvreede committed Nov 21, 2023
1 parent c5c3430 commit 7802063
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions sktalk/corpus/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def _update(self, field: str, values: list, **kwargs):
except KeyError:
self._metadata = {"Calculations": {field: kwargs}}
for index, utterance in enumerate(self.utterances):
utterance.__setattr__(field, values[index])
setattr(utterance, field, values[index])

def calculate_FTO(self, window: int = 10000, planning_buffer: int = 200, n_participants: int = 2):
"""Calculate Floor Transfer Offset (FTO) per utterance
Expand Down Expand Up @@ -190,7 +190,7 @@ def calculate_FTO(self, window: int = 10000, planning_buffer: int = 200, n_parti
u for u in sub.utterances if utterance.relevant_for_fto(u, planning_buffer)]
try:
relevant = potentials[-1]
values.append(utterance.until(relevant))
values.append(relevant.until(utterance))
except IndexError:
values.append(None)
self._update("FTO", values,
Expand Down
1 change: 1 addition & 0 deletions sktalk/corpus/utterance.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Utterance:
n_characters: Optional[int] = None
time_to_next: Optional[int] = None
dyadic: Optional[bool] = None
FTO: Optional[int] = None

def __post_init__(self):
# clean utterance:
Expand Down
8 changes: 4 additions & 4 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, #noqa W0212
convo._subconversation(index=index, #noqa protected-access
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, #noqa W0212
sub = convo._subconversation(index=index, #noqa protected-access
before=before,
after=after,
time_or_index=time_or_index)
Expand All @@ -101,7 +101,7 @@ def test_overlap(self):

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

0 comments on commit 7802063

Please sign in to comment.