Skip to content

Commit

Permalink
Add postfilter as wildcards in filter mocker
Browse files Browse the repository at this point in the history
  • Loading branch information
pvandyken committed Dec 11, 2023
1 parent 98f19c0 commit 95240f9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
8 changes: 7 additions & 1 deletion snakebids/core/input_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,13 @@ def from_filter_dict(
Intended primarily for use in testing
"""
return cls({"filters": filters}, postfilter or _Postfilter())
wildcards: list[str] = []
if postfilter is not None:
wildcards.extend(postfilter.inclusions)
wildcards.extend(postfilter.exclusions)
return cls(
{"filters": filters, "wildcards": wildcards}, postfilter or _Postfilter()
)

def _has_empty_list(self, items: Iterable[Any]):
"""Check if any of the lists within iterable are empty"""
Expand Down
24 changes: 4 additions & 20 deletions snakebids/tests/test_generate_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,7 @@
import warnings
from collections import defaultdict
from pathlib import Path
from typing import (
Any,
Callable,
Iterable,
Literal,
NamedTuple,
TypedDict,
TypeVar,
cast,
)
from typing import Iterable, Literal, NamedTuple, TypedDict, TypeVar, cast

import attrs
import more_itertools as itx
Expand Down Expand Up @@ -50,11 +41,11 @@
from snakebids.paths.presets import bids
from snakebids.tests import strategies as sb_st
from snakebids.tests.helpers import (
Benchmark,
BidsListCompare,
allow_function_scoped,
create_dataset,
create_snakebids_config,
debug,
example_if,
get_bids_path,
get_zip_list,
Expand Down Expand Up @@ -699,13 +690,11 @@ def generate_test_directory(

T = TypeVar("T")

def test_benchmark_test_custom_paths(
self, benchmark: Callable[[Callable[..., Any], Any], Any], tmp_path: Path
):
def test_benchmark_test_custom_paths(self, benchmark: Benchmark, tmp_path: Path):
entities = {"A": ["A", "B", "C"], "B": ["1", "2", "3"]}
template = Path("{A}/A-{A}_B-{B}")
test_path = self.generate_test_directory(entities, template, tmp_path)
benchmark(_parse_custom_path, test_path)
benchmark(_parse_custom_path, test_path, _UnifiedFilter.from_filter_dict({}))

@allow_function_scoped
@given(path_entities=path_entities())
Expand Down Expand Up @@ -754,11 +743,6 @@ def test_collects_only_filtered_entities(
name="foo", path=get_bids_path(result_filtered), zip_lists=result_filtered
)

@debug(
path_entities=PathEntities(
entities={"A": ["A"]}, template=Path("A-{A}"), filters={"A": ["A"]}
),
)
@settings(deadline=400, suppress_health_check=[HealthCheck.function_scoped_fixture])
@given(path_entities=path_entities())
def test_collect_all_but_filters_when_exclusion_filters_used(
Expand Down

0 comments on commit 95240f9

Please sign in to comment.