Skip to content

Commit f63a6a7

Browse files
committed
Document make_eq_input_check_result()
1 parent 08a544b commit f63a6a7

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

array_api_tests/test_special_cases.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,6 @@ def make_binary_cond(
736736
Wraps a unary condition as a binary condition, e.g.
737737
738738
>>> unary_cond = lambda i: i == 42
739-
740739
>>> binary_cond_first = make_binary_cond(BinaryCondArg.FIRST, unary_cond)
741740
>>> binary_cond_first(42, 0)
742741
True
@@ -790,6 +789,24 @@ def partial_cond(i1: float, i2: float) -> bool:
790789
def make_eq_input_check_result(
791790
eq_to: BinaryCondArg, *, eq_neg: bool = False
792791
) -> BinaryResultCheck:
792+
"""
793+
Returns a result checker for cases where the result equals an array element
794+
795+
>>> check_result_first = make_eq_input_check_result(BinaryCondArg.FIRST)
796+
>>> check_result(42, 0, 42)
797+
True
798+
>>> check_result_second = make_eq_input_check_result(BinaryCondArg.SECOND)
799+
>>> check_result(42, 0, 42)
800+
False
801+
>>> check_result(0, 42, 42)
802+
True
803+
>>> check_result_neg_first = make_eq_input_check_result(BinaryCondArg.FIRST, eq_neg=True)
804+
>>> check_result_neg_first(42, 0, 42)
805+
False
806+
>>> check_result_neg_first(42, 0, -42)
807+
True
808+
809+
"""
793810
if eq_neg:
794811
input_wrapper = lambda i: -i
795812
else:

0 commit comments

Comments
 (0)