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 Database.get() for non-existent schemes #427

Merged
merged 5 commits into from
May 15, 2024

Conversation

hagenw
Copy link
Member

@hagenw hagenw commented May 15, 2024

Closes #426

Add two tests that cover #246. The code itself is fixed by removing an if statement, that explicitly was setting an requested additional scheme to an empty frame, if the additional scheme requested before was also empty. I guess this was some left over code, that was no longer needed, but did also not fail the tests we had so far.

@hagenw hagenw marked this pull request as draft May 15, 2024 06:21
Copy link

codecov bot commented May 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.0%. Comparing base (6b16209) to head (8ab1038).

Additional details and impacted files
Files Coverage Δ
audformat/core/database.py 100.0% <100.0%> (ø)

@hagenw hagenw marked this pull request as ready for review May 15, 2024 06:34
@hagenw hagenw requested a review from audeerington May 15, 2024 06:35
Copy link

@audeerington audeerington left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this!

I would guess that the original intention of the line is that you don't need to load the data at all to check for additional schemes if you already know that the length of the dataframe containing the main scheme is 0. So maybe this would save some time. But since obj is overwritten in the loop, this leads to the bug.

It seems to me that this case wouldn't come up very often, so I think it is fine to just remove the check like this.

@hagenw
Copy link
Member Author

hagenw commented May 15, 2024

Good point.
I think, this is still of interest as it can save execution time. The problem before was, that I used the same variable name for the additional schemes. I updated the code now to use the structure from main, but use additional_obj as variable name for the additional schemes, instead of obj.

@audeerington
Copy link

Great, then everything looks good to me.

@hagenw hagenw merged commit 90e21d4 into main May 15, 2024
10 checks passed
@hagenw hagenw deleted the fix-get-for-non-existing-additional-schemes branch May 15, 2024 10:07
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.

audformat.Database.get() is not always returning the requested scheme
2 participants