Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Update textgrid.py #40

Merged
merged 2 commits into from
Nov 8, 2023
Merged

Update textgrid.py #40

merged 2 commits into from
Nov 8, 2023

Conversation

lcavasso
Copy link
Contributor

@lcavasso lcavasso commented Nov 7, 2023

Changed logic in IntervalTier.intervalContaining() so that you can check for times that are less than 1 without returning None.

Suppose mygrid is a TextGrid with a duration of greater than 0.1 seconds. mygrid[0].intervalContaining(0.1) would previously return None. It seems 0.1 is somehow evaluating to False

Addresses issue #38

changed logic in IntervalTier.intervalContaining() so that you can check for times that are less than 1 without returning None
@kylebgorman
Copy link
Owner

Hi Luca, thanks for this. I see the issue you mention.

I wonder if you could add a test to tests.py that covers this bug...i.e., something that previously failed and now succeeds. (We should do more test automation and such here but we wrote this library over a decade ago, before such things were standard practice.)

@lcavasso
Copy link
Contributor Author

lcavasso commented Nov 7, 2023

Sure, I can give that a try. Also, while working on this I realized I was confused before - the bug is actually that since 0 evaluates as False, intervalContaining can't return the first interval. (It checks whether the index i is None just by if i, so where i is 0, whatever's under the if statement will never execute.)

added test to check `intervalContaining`
@lcavasso
Copy link
Contributor Author

lcavasso commented Nov 8, 2023

Test added!

@kylebgorman
Copy link
Owner

Thanks, that's all we need. Merging now.

If I may, feel free to continue to contribute here...

@kylebgorman kylebgorman merged commit 2fba4fd into kylebgorman:master Nov 8, 2023
@lcavasso
Copy link
Contributor Author

Hi Kyle, would you mind updating PyPi so that pip install textgrid includes this fix?

@kylebgorman
Copy link
Owner

Sure, or if you want to I could make you a maintainer on PyPI?

@lcavasso
Copy link
Contributor Author

lcavasso commented Mar 5, 2024

Sure! I don't really have experience with PyPi, but I'm sure I can figure it out. I just made a PyPi profile: https://pypi.org/user/lcavasso/

@kylebgorman
Copy link
Owner

kylebgorman commented Mar 5, 2024 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants