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

Refactor channel_group_search implementation in tdm_loader #27

Merged
merged 9 commits into from
Mar 22, 2024

Conversation

EspenEnes
Copy link
Contributor

When searching and resulting groups has identical channel group names, only the first channel group index is returned

New logic will look at channel group names together with occurrences to find the correct channel group index.

When searching and resulting groups has identical channel group names, only the first channel group index is returned

New logic will look at channel group names together with occurrences to find the correct channel group index.
Copy link
Owner

@domna domna left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution! Here are some comments on a slightly simpler implementation (but maybe I'm overlooking something here).

Do you have an example file with which we could add a test for this?

tdm_loader/tdm_loader.py Outdated Show resolved Hide resolved
tdm_loader/tdm_loader.py Outdated Show resolved Hide resolved
EspenEnes and others added 3 commits March 21, 2024 06:07
Co-authored-by: Florian Dobener <github@schroedingerscat.org>
The previous implementation counted and used the number of times a channel group name appeared, which added extra complexity to the search logic. The new logic simplifies this process by directly appending the names to the found_terms list and by making the search case- and space-insensitive.
Switched from a for-loop and conditional check structure to an inline list comprehension to search for channel group names. The aim of this refactor is to simplify the code and improve readability, while maintaining the functionality of ignoring None values and retaining valid group names.
@EspenEnes
Copy link
Contributor Author

The latest commit I have used yours suggestion and removed my implementation to find the occurrences with the for loop.

Changed the return type of a function in tdm_loader from a list to a set. This modification ensures unique channel group names are returned from the function, thus improving the accuracy of the channel search process.
@EspenEnes EspenEnes requested a review from domna March 21, 2024 07:38
@domna
Copy link
Owner

domna commented Mar 21, 2024

Thank you for the changes. One of the tests are not passing now, because you changed the return type of the function from list to set. I think it would also be useful to not use a set here as people might expect that this function returns a list. I would suggest that you do a check whether a certain key already exists before inputting it into the list (or you use a set in the for-loop and convert it to a list in the return but you might need to sort it to pass the test again).

Do you also have a file containing duplicate names which we could add as a test for your new feature?

tdm_loader/tdm_loader.py Outdated Show resolved Hide resolved
@EspenEnes
Copy link
Contributor Author

Sorry for my clumsiness, this is my first contribution ever.
I removed the set and used a dictionary lookup instead for the occurrences.
I have run your tests all passed..

I did not have any small TDM/TDX files I could share to make a test, all my files are 500mb ++ and Autogenerated from a recorder.

@EspenEnes EspenEnes requested a review from domna March 21, 2024 13:30
Copy link
Owner

@domna domna left a comment

Choose a reason for hiding this comment

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

I think there is also a more straightforward approach to this

tdm_loader/tdm_loader.py Outdated Show resolved Hide resolved
tdm_loader/tdm_loader.py Outdated Show resolved Hide resolved
tdm_loader/tdm_loader.py Outdated Show resolved Hide resolved
@domna
Copy link
Owner

domna commented Mar 21, 2024

Sorry for my clumsiness, this is my first contribution ever. I removed the set and used a dictionary lookup instead for the occurrences. I have run your tests all passed..

No worries. This is totally fine and part of the review process. Thank you for the changes again. Also congrats on your first contribution.

I did not have any small TDM/TDX files I could share to make a test, all my files are 500mb ++ and Autogenerated from a recorder.

Ok this is too large unfortunately. There is not chance you are able to generate a very small testing file just containing just some duplicate axes?

EspenEnes and others added 3 commits March 21, 2024 18:11
Co-authored-by: Florian Dobener <github@schroedingerscat.org>
Co-authored-by: Florian Dobener <github@schroedingerscat.org>
Co-authored-by: Florian Dobener <github@schroedingerscat.org>
@EspenEnes
Copy link
Contributor Author

suddenly it became such an little fix :)

@EspenEnes EspenEnes requested a review from domna March 21, 2024 17:40
@domna
Copy link
Owner

domna commented Mar 22, 2024

Thank you @EspenEnes. I'll merge it now and create a new release with it so you can use it

@domna domna merged commit 3cffb74 into domna:master Mar 22, 2024
1 check passed
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.

3 participants