Skip to content

Commit

Permalink
covert FilterAdapter in dataclass
Browse files Browse the repository at this point in the history
  • Loading branch information
SimeonEhrig committed Jan 25, 2024
1 parent 788a73c commit 261f9c7
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions bashi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

from typing import Dict, Tuple, List
from collections import OrderedDict
import dataclasses
from packaging.version import Version
from typeguard import typechecked
from bashi.types import FilterFunction, ParameterValueTuple


@dataclasses.dataclass
class FilterAdapter:
"""
An adapter for the filter functions used by allpairspy to provide a better filter function
Expand Down Expand Up @@ -35,27 +36,19 @@ def filter_function(row: OrderedDict[str, Tuple[str, Version]]):
):
return False
return True
"""

@typechecked
def __init__(
self,
param_map: Dict[int, str],
filter_func: FilterFunction,
):
"""Create a new FilterAdapter, see class doc string.
Args:
Args:
param_map (Dict[int, str]): The param_map maps the index position of a parameter to the
parameter name. Assuming the parameter-value-matrix has the following keys:
["param1", "param2", "param3"], the param_map should look like this:
{0: "param1", 1 : "param2", 2 : "param3"}.
filter_func (Callable[[OrderedDict[str, Tuple[str, Version]]], bool]): The filter
function used by allpairspy, see class doc string.
"""
self.param_map = param_map
self.filter_func = filter_func
"""

param_map: Dict[int, str]
filter_func: FilterFunction

def __call__(self, row: List[Tuple[str, Version]]) -> bool:
"""The expected interface of allpairspy filter rule.
Expand Down

0 comments on commit 261f9c7

Please sign in to comment.