-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from SimeonEhrig/filters
Add filters and setup pairwise generator
- Loading branch information
Showing
19 changed files
with
1,317 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"""Filter rules basing on backend names and versions.""" | ||
|
||
from typing import Optional, IO | ||
from bashi.types import ParameterValueTuple | ||
|
||
|
||
def backend_filter( | ||
row: ParameterValueTuple, | ||
output: Optional[IO[str]] = None, | ||
) -> bool: | ||
"""Filter rules basing on backend names and versions. | ||
Args: | ||
row (ParameterValueTuple): parameter-value-tuple to verify. | ||
output (Optional[IO[str]], optional): Writes the reason in the io object why the parameter | ||
value tuple does not pass the filter. If None, no information is provided. The default | ||
value is None. | ||
Returns: | ||
bool: True, if parameter-value-tuple is valid. | ||
""" | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"""Filter rules basing on host and device compiler names.""" | ||
|
||
from typing import Optional, IO | ||
from bashi.types import ParameterValueTuple | ||
|
||
|
||
def compiler_name_filter( | ||
row: ParameterValueTuple, | ||
output: Optional[IO[str]] = None, | ||
) -> bool: | ||
"""Filter rules basing on host and device compiler names. | ||
Args: | ||
row (ParameterValueTuple): parameter-value-tuple to verify. | ||
output (Optional[IO[str]], optional): Writes the reason in the io object why the parameter | ||
value tuple does not pass the filter. If None, no information is provided. The default | ||
value is None. | ||
Returns: | ||
bool: True, if parameter-value-tuple is valid. | ||
""" | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"""Filter rules basing on host and device compiler names and versions.""" | ||
|
||
from typing import Optional, IO | ||
from bashi.types import ParameterValueTuple | ||
|
||
|
||
def compiler_version_filter( | ||
row: ParameterValueTuple, | ||
output: Optional[IO[str]] = None, | ||
) -> bool: | ||
"""Filter rules basing on host and device compiler names and versions. | ||
Args: | ||
row (ParameterValueTuple): parameter-value-tuple to verify. | ||
output (Optional[IO[str]], optional): Writes the reason in the io object why the parameter | ||
value tuple does not pass the filter. If None, no information is provided. The default | ||
value is None. | ||
Returns: | ||
bool: True, if parameter-value-tuple is valid. | ||
""" | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"""Filter rules handling software dependencies and compiler settings.""" | ||
|
||
from typing import Optional, IO | ||
from bashi.types import ParameterValueTuple | ||
|
||
|
||
def software_dependency_filter( | ||
row: ParameterValueTuple, | ||
output: Optional[IO[str]] = None, | ||
) -> bool: | ||
"""Filter rules handling software dependencies and compiler settings. | ||
Args: | ||
row (ParameterValueTuple): parameter-value-tuple to verify. | ||
output (Optional[IO[str]], optional): Writes the reason in the io object why the parameter | ||
value tuple does not pass the filter. If None, no information is provided. The default | ||
value is None. | ||
Returns: | ||
bool: True, if parameter-value-tuple is valid. | ||
""" | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,53 @@ | ||
def foo(): | ||
print("Hello bashi.") | ||
"""Functions to generate the combination-list""" | ||
|
||
from typing import Dict, List | ||
from collections import OrderedDict | ||
|
||
def add(x: int, y: int): | ||
return x + y | ||
from covertable import make | ||
|
||
from bashi.types import ( | ||
Parameter, | ||
ParameterValue, | ||
ParameterValueMatrix, | ||
FilterFunction, | ||
Combination, | ||
CombinationList, | ||
) | ||
from bashi.utils import get_default_filter_chain | ||
|
||
|
||
def generate_combination_list( | ||
parameter_value_matrix: ParameterValueMatrix, | ||
custom_filter: FilterFunction = lambda _: True, | ||
) -> CombinationList: | ||
"""Generate combination-list from the parameter-value-matrix. The combination list contains | ||
all valid parameter-value-pairs at least one time. | ||
Args: | ||
parameter_value_matrix (ParameterValueMatrix): Input matrix with parameter and | ||
parameter-values. | ||
custom_filter (FilterFunction, optional): Custom filter function to extend bashi | ||
filters. Defaults is lambda _: True. | ||
Returns: | ||
CombinationList: combination-list | ||
""" | ||
filter_chain = get_default_filter_chain(custom_filter) | ||
|
||
comb_list: CombinationList = [] | ||
|
||
all_pairs: List[Dict[Parameter, ParameterValue]] = make( | ||
factors=parameter_value_matrix, | ||
length=2, | ||
pre_filter=filter_chain, | ||
) # type: ignore | ||
|
||
# convert List[Dict[Parameter, ParameterValue]] to CombinationList | ||
for all_pair in all_pairs: | ||
tmp_comb: Combination = OrderedDict() | ||
# covertable does not keep the ordering of the parameters | ||
# therefore we sort it | ||
for param in parameter_value_matrix.keys(): | ||
tmp_comb[param] = all_pair[param] | ||
comb_list.append(tmp_comb) | ||
|
||
return comb_list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.