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

Fix bug in lazy CutSet subset with last #1023

Merged
merged 2 commits into from
Apr 10, 2023

Conversation

desh2608
Copy link
Collaborator

@desh2608 desh2608 commented Apr 7, 2023

This was raised in #1018 (reply in thread).

@@ -996,8 +996,7 @@ def subset(
f"CutSet has only {len(self)} items but last {last} required; not doing anything."
)
return self
cut_ids = list(self.ids)[-last:]
return CutSet.from_cuts(self[cid] for cid in cut_ids)
return CutSet.from_cuts(islice(self, len(self) - last, len(self)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you assign len(self) to a variable to avoid double iteration for lazy cut sets?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good point.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@pzelasko pzelasko merged commit cdb068c into lhotse-speech:master Apr 10, 2023
@pzelasko
Copy link
Collaborator

Thanks!

@pzelasko pzelasko added this to the v1.14 milestone Apr 10, 2023
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.

2 participants