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

Change optional filter ordering #64

Merged
merged 7 commits into from
Nov 21, 2024
Merged

Change optional filter ordering #64

merged 7 commits into from
Nov 21, 2024

Conversation

jthorton
Copy link
Contributor

Fixes #61 by applying additional filters before the default ring-based filters to ensure rings are not broken when requested.

Copy link

codecov bot commented Nov 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.60%. Comparing base (c2855ed) to head (1d69472).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #64   +/-   ##
=======================================
  Coverage   96.60%   96.60%           
=======================================
  Files          13       13           
  Lines         618      618           
=======================================
  Hits          597      597           
  Misses         21       21           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

Copy link
Contributor

@hannahbaumann hannahbaumann left a comment

Choose a reason for hiding this comment

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

Thanks @jthorton , lgtm, just that one question!

mapper = KartografAtomMapper(
map_exact_ring_matches_only=True,
additional_mapping_filter_functions=[filter_hybridization_changes]
Copy link
Contributor

Choose a reason for hiding this comment

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

What would happen if you include the default filters in the additional mapping filters, would it skip them/still preserve the correct order?
E.g.

additional_mapping_filter_functions=[
                filter_ringbreak_changes, # default
                filter_ringsize_changes, # default
                filter_whole_rings_only, # default
                filter_hybridization_changes]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We currently don't check what filters are passed as additional so if a default filter was used then it would be applied twice first as an additional filter then as the default, maybe I should expand the docs to make it clear that defaults are applied first?

Copy link
Member

Choose a reason for hiding this comment

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

Is this the behaviour we want to have?

Long term I could see a case where folks would want to chain custom filters so that they can iteratively patch some behaviour - however in this case where we have named filters vs custom ones, would it make sense to just error out (or at least warn) if the method is already in _filter_funcs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think a warning would be fair we don't want to error out and stop experimentation and a section in the docs which explains exactly which filters are applied when you set a default filter should help.

Copy link
Member

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

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

overall lgtm, but would be good to work out what we want our default behaviour to be.

src/kartograf/atom_mapper.py Show resolved Hide resolved
src/kartograf/atom_mapper.py Show resolved Hide resolved
mapper = KartografAtomMapper(
map_exact_ring_matches_only=True,
additional_mapping_filter_functions=[filter_hybridization_changes]
Copy link
Member

Choose a reason for hiding this comment

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

Is this the behaviour we want to have?

Long term I could see a case where folks would want to chain custom filters so that they can iteratively patch some behaviour - however in this case where we have named filters vs custom ones, would it make sense to just error out (or at least warn) if the method is already in _filter_funcs?

@jthorton jthorton merged commit 8ebfea7 into main Nov 21, 2024
7 checks passed
@jthorton jthorton deleted the optional_filter_ordering branch November 21, 2024 15:58
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.

The ordering of filters can give broken ring mappings
3 participants