Skip to content

Commit 80615aa

Browse files
Copilotev-br
andcommitted
Address code review comments: fix make_and bug and refactor nested function
Co-authored-by: ev-br <2133832+ev-br@users.noreply.github.com>
1 parent df1f990 commit 80615aa

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

array_api_tests/test_special_cases.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def or_(i: float) -> bool:
9999

100100
def make_and(cond1: UnaryCheck, cond2: UnaryCheck) -> UnaryCheck:
101101
def and_(i: float) -> bool:
102-
return cond1(i) or cond2(i)
102+
return cond1(i) and cond2(i)
103103

104104
return and_
105105

@@ -778,6 +778,14 @@ def check_result(i: float, result: float) -> bool:
778778
return check_result
779779

780780

781+
def make_complex_unary_check_result(check_fn: Callable[[complex], bool]) -> UnaryResultCheck:
782+
"""Wraps a complex check function for use in UnaryCase."""
783+
def check_result(in_value, out_value):
784+
# in_value is complex, out_value is complex
785+
return check_fn(out_value)
786+
return check_result
787+
788+
781789
def parse_unary_case_block(case_block: str, func_name: str) -> List[UnaryCase]:
782790
"""
783791
Parses a Sphinx-formatted docstring of a unary function to return a list of
@@ -849,14 +857,7 @@ def parse_unary_case_block(case_block: str, func_name: str) -> List[UnaryCase]:
849857
)
850858
_check_result, result_expr = parse_complex_result(result_str)
851859

852-
# Create a wrapper that works with complex inputs
853-
def make_complex_check_result(check_fn):
854-
def check_result(in_value, out_value):
855-
# in_value is complex, out_value is complex
856-
return check_fn(out_value)
857-
return check_result
858-
859-
check_result = make_complex_check_result(_check_result)
860+
check_result = make_complex_unary_check_result(_check_result)
860861

861862
case = UnaryCase(
862863
cond_expr=cond_expr,

0 commit comments

Comments
 (0)