Skip to content

Fix zip usage for compatibility with python 3 #25

Open
mxmpl wants to merge 1 commit intobootphon:masterfrom
mxmpl:master
Open

Fix zip usage for compatibility with python 3 #25
mxmpl wants to merge 1 commit intobootphon:masterfrom
mxmpl:master

Conversation

@mxmpl
Copy link
Copy Markdown

@mxmpl mxmpl commented Nov 15, 2022

In Python 3, zip returns an iterator and not a list as in Python 2: it exhausts once it has been iterated over.

This behaviour causes issues in

for spkr in self.speakers:
spk_utts = [utt_id for utt_id, utt_speaker in self.utts
if utt_speaker == spkr]

as self.utts is defined in
self.utts = zip(utt_ids, utt_speakers)

For the first spkr, spk_utts is correct, but for the next ones it is an empty list as self.utts is exhausted.

This PR fixes this by changing zip(...) to list(zip(...)).

@mxmpl mxmpl self-assigned this Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant