From 53352f77096ce5b8d02aad6f7bca69fa04f1dd13 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 16 Jan 2026 16:43:13 +0000 Subject: [PATCH 1/4] Initial plan From 4b755147ed37f62d68093997c3907b429dd2b200 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 16 Jan 2026 16:49:10 +0000 Subject: [PATCH 2/4] Add special cases registry and emission mechanism Co-authored-by: ev-br <2133832+ev-br@users.noreply.github.com> --- array_api_tests/test_special_cases.py | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/array_api_tests/test_special_cases.py b/array_api_tests/test_special_cases.py index bf05a262..461190e8 100644 --- a/array_api_tests/test_special_cases.py +++ b/array_api_tests/test_special_cases.py @@ -38,6 +38,9 @@ UnaryCheck = Callable[[float], bool] BinaryCheck = Callable[[float, float], bool] +# Global registry for recording special cases +special_cases_registry: List[str] = [] + def make_strict_eq(v: float) -> UnaryCheck: if math.isnan(v): @@ -679,6 +682,9 @@ def parse_unary_case_block(case_block: str, func_name: str) -> List[UnaryCase]: cases = [] for case_m in r_case.finditer(case_block): case_str = case_m.group(1) + # Record the special case line in the global registry + special_cases_registry.append(f"{func_name}: {case_str}") + if r_already_int_case.search(case_str): cases.append(already_int_case) elif r_even_round_halves_case.search(case_str): @@ -1145,6 +1151,9 @@ def parse_binary_case_block(case_block: str, func_name: str) -> List[BinaryCase] cases = [] for case_m in r_case.finditer(case_block): case_str = case_m.group(1) + # Record the special case line in the global registry + special_cases_registry.append(f"{func_name}: {case_str}") + if r_redundant_case.search(case_str): continue if r_binary_case.match(case_str): @@ -1351,3 +1360,26 @@ def test_nan_propagation(func_name, x, data): ph.assert_shape(func_name, out_shape=out.shape, expected=()) # sanity check assert xp.isnan(out), f"{out=!r}, but should be NaN" + + +def test_print_special_cases_registry(): + """ + Test function to emit all recorded special cases. + + This test prints the complete registry of special cases that were parsed + from docstrings during module load time. + """ + print("\n" + "=" * 80) + print("SPECIAL CASES REGISTRY") + print("=" * 80) + if special_cases_registry: + for case_record in special_cases_registry: + print(case_record) + print("=" * 80) + print(f"Total special cases recorded: {len(special_cases_registry)}") + else: + print("No special cases recorded") + print("=" * 80) + # This test always passes - it's just for printing + assert True + From d70bf920fdf122501decefafe8a0ce0408a7382a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 16 Jan 2026 16:51:47 +0000 Subject: [PATCH 3/4] Improve documentation and clarify recording logic Co-authored-by: ev-br <2133832+ev-br@users.noreply.github.com> --- array_api_tests/test_special_cases.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/array_api_tests/test_special_cases.py b/array_api_tests/test_special_cases.py index 461190e8..32e8118c 100644 --- a/array_api_tests/test_special_cases.py +++ b/array_api_tests/test_special_cases.py @@ -682,7 +682,9 @@ def parse_unary_case_block(case_block: str, func_name: str) -> List[UnaryCase]: cases = [] for case_m in r_case.finditer(case_block): case_str = case_m.group(1) - # Record the special case line in the global registry + # Record the special case line in the global registry. + # Per requirements, we record ALL case lines that match r_case pattern, + # including those that fail to parse or trigger warnings. special_cases_registry.append(f"{func_name}: {case_str}") if r_already_int_case.search(case_str): @@ -1151,7 +1153,9 @@ def parse_binary_case_block(case_block: str, func_name: str) -> List[BinaryCase] cases = [] for case_m in r_case.finditer(case_block): case_str = case_m.group(1) - # Record the special case line in the global registry + # Record the special case line in the global registry. + # Per requirements, we record ALL case lines that match r_case pattern, + # including those that fail to parse or trigger warnings. special_cases_registry.append(f"{func_name}: {case_str}") if r_redundant_case.search(case_str): @@ -1367,7 +1371,12 @@ def test_print_special_cases_registry(): Test function to emit all recorded special cases. This test prints the complete registry of special cases that were parsed - from docstrings during module load time. + from docstrings during module load time. The registry is populated when + the module is imported, as parse_unary_case_block and parse_binary_case_block + are called to set up test parameters. + + This test always passes - it's purely for informational/debugging purposes + to view all special cases that were extracted from the Array API specification. """ print("\n" + "=" * 80) print("SPECIAL CASES REGISTRY") From 684195900a87febc2c0d6b1a7aef07294ffebee8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 16 Jan 2026 16:54:22 +0000 Subject: [PATCH 4/4] Replace assert True with meaningful assertion Co-authored-by: ev-br <2133832+ev-br@users.noreply.github.com> --- array_api_tests/test_special_cases.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/array_api_tests/test_special_cases.py b/array_api_tests/test_special_cases.py index 32e8118c..d74fb2c9 100644 --- a/array_api_tests/test_special_cases.py +++ b/array_api_tests/test_special_cases.py @@ -1389,6 +1389,6 @@ def test_print_special_cases_registry(): else: print("No special cases recorded") print("=" * 80) - # This test always passes - it's just for printing - assert True + # Verify the registry is accessible + assert isinstance(special_cases_registry, list)