Skip to content

Commit 49ef10d

Browse files
committed
Reorder binary case patterns to avoid false matches
1 parent 81df5f6 commit 49ef10d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

array_api_tests/test_special_cases.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -579,12 +579,6 @@ def __call__(self, groups: Tuple[str, ...]) -> BinaryCase:
579579
r_result_sign = re.compile("([a-z]+) mathematical sign")
580580

581581
binary_pattern_to_case_factory: Dict[Pattern, BinaryCaseFactory] = {
582-
re.compile(
583-
"If ``x1_i`` is (.+) and ``x2_i`` is (.+), the result is (.+)"
584-
): BinaryCaseFactory(
585-
AndCondFactory(ValueCondFactory("i1", 0), ValueCondFactory("i2", 1)),
586-
ResultCheckFactory(2),
587-
),
588582
re.compile(
589583
"If ``x1_i`` is (.+), ``x1_i`` (.+), "
590584
"and ``x2_i`` is (.+), the result is (.+)"
@@ -607,6 +601,13 @@ def __call__(self, groups: Tuple[str, ...]) -> BinaryCase:
607601
),
608602
ResultCheckFactory(3),
609603
),
604+
# This case must come after the above to avoid false matches
605+
re.compile(
606+
"If ``x1_i`` is (.+) and ``x2_i`` is (.+), the result is (.+)"
607+
): BinaryCaseFactory(
608+
AndCondFactory(ValueCondFactory("i1", 0), ValueCondFactory("i2", 1)),
609+
ResultCheckFactory(2),
610+
),
610611
re.compile(
611612
r"If ``abs\(x1_i\)`` is (.+) and ``x2_i`` is (.+), the result is (.+)"
612613
): BinaryCaseFactory(

0 commit comments

Comments
 (0)