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

made eval matcher more pythonic #29

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions bananalyzer/runner/evals.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ def validate_field_match(expected: Result, actual: Result, field: str) -> None:
if actual_value is "":
actual_value = None

matcher = get_matcher(expected_value, actual_value)
if not matcher(actual_value, expected_value):
if not check_match(expected_value, actual_value):
pytest.fail(f"{expected_value} != {actual_value}")


Expand Down Expand Up @@ -103,8 +102,8 @@ def native_count_differences(actual: str, expected: str) -> int:
return diff_count


def get_matcher(expected_value: Any, actual_value: Any) -> Callable[[Any, Any], bool]:
def check_match(expected_value: Any, actual_value: Any) -> bool:
if isinstance(expected_value, str) and isinstance(actual_value, str):
return is_string_similar
return is_string_similar(expected_value, actual_value)
else:
return lambda x, y: x == y
return expected_value == actual_value
Loading