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

Convert filtering functions to classes #531

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zargham-ahmad
Copy link
Collaborator

As per our discussion, Opening the draft PR for discussion.

This implementation is based on the template design pattern, containing a base class that contains two functions process() and abstract method apply_filter(). Then it has further sub base class for filters that share quite a lot of similar code e.g. select_by filter and harmonize_undefined filters. There is not really a change in the current filter function usage to keep usage the same for now, but internally they now use class implementation.


logger = logging.getLogger("matchms")

class AddCompoundName(BaseSpectrumFilter):
Copy link
Collaborator

Choose a reason for hiding this comment

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

It might make more sense, to have the Classes in the same file that has the functional equivalent.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So below the add_compound_name function

Copy link
Collaborator

Choose a reason for hiding this comment

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

Something that is hard to judge now is if the same functionality is still in the classes that was previously in the function, since we made quite some updates to matchms in the last few weeks. There is a risk that these changes are undone. I am not sure how we could best check this. Anyone any suggestions?

from matchms.typing import SpectrumType


class HarmonizeUndefinedTemplate(BaseSpectrumFilter):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe good for file organizations to make a separate folder with these kinds of parent classes. The folder could be called FilterTypes for instance.

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.

None yet

2 participants