Skip to content

Commit

Permalink
Overhaul global filtering of participants
Browse files Browse the repository at this point in the history
--participant-filter and --exclude-participant filter have had a couple
of bugs over the past few versions:

1. Both terms would apply to every single component, even components
   without the subject entity. These components would have all of their
   entries filtered out
2. Using --exclude-participant-filter would turn on regex matching
   mode for every single filter. This changed the meaning of the filters
   (e.g. allowing partial matches), leading to workflow disruption

The overhaul fixes both bugs, while improving the organization of the
input generation code.

Additionally, the documentation states the magic filter `regex_search:
True` can be used to enable regex searching for a block of filters. This
hasn't worked for the past few versions. Rather than fix it, the
behaviour has been silently disabled in preparation for an overhaul of
the regex filtering api

Resolves #303
Resolves #216
  • Loading branch information
pvandyken committed Oct 17, 2023
1 parent db24a2d commit 18946e4
Show file tree
Hide file tree
Showing 6 changed files with 496 additions and 165 deletions.
2 changes: 2 additions & 0 deletions snakebids/core/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,8 @@ def filter(
if not isinstance(regex_search, bool):
msg = "regex_search must be a boolean"
raise TypeError(msg)
if not filters:
return self
return attr.evolve(
self,
zip_lists=filter_list(self.zip_lists, filters, regex_search=regex_search),
Expand Down
2 changes: 1 addition & 1 deletion snakebids/core/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def filter_list(
def filter_list(
zip_list: ZipListLike,
filters: Mapping[str, Iterable[str] | str],
return_indices_only: Literal[True] = ...,
return_indices_only: Literal[True],
regex_search: bool = ...,
) -> list[int]:
...
Expand Down
Loading

0 comments on commit 18946e4

Please sign in to comment.