From bf49717337896a3090babf017493b19751f07669 Mon Sep 17 00:00:00 2001 From: Jake VanderPlas Date: Tue, 14 Nov 2023 21:22:00 -0800 Subject: [PATCH 1/3] Update to most recent array-api commit --- array-api | 2 +- array_api_tests/dtype_helpers.py | 6 ++++-- array_api_tests/stubs.py | 14 ++++++++------ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/array-api b/array-api index c5808f2b..0f64005c 160000 --- a/array-api +++ b/array-api @@ -1 +1 @@ -Subproject commit c5808f2b173ea52d813c450bec7b1beaf2973299 +Subproject commit 0f64005c7af6cc1906f310e929d0b8fcac24fd41 diff --git a/array_api_tests/dtype_helpers.py b/array_api_tests/dtype_helpers.py index 9c2f3bfe..d508f5b0 100644 --- a/array_api_tests/dtype_helpers.py +++ b/array_api_tests/dtype_helpers.py @@ -352,6 +352,10 @@ def result_type(*dtypes: DataType): "boolean": (xp.bool,), "integer": all_int_dtypes, "floating-point": real_float_dtypes, + "real-valued": real_float_dtypes, + "real-valued floating-point": real_float_dtypes, + "complex floating-point": complex_dtypes, + "complex-floating point": complex_dtypes, "numeric": numeric_dtypes, "integer or boolean": bool_and_all_int_dtypes, } @@ -364,8 +368,6 @@ def result_type(*dtypes: DataType): dtype_category = "floating-point" dtypes = category_to_dtypes[dtype_category] func_in_dtypes[name] = dtypes -# See https://github.com/data-apis/array-api/pull/413 -func_in_dtypes["expm1"] = real_float_dtypes func_returns_bool = { diff --git a/array_api_tests/stubs.py b/array_api_tests/stubs.py index 0134765b..628c74c0 100644 --- a/array_api_tests/stubs.py +++ b/array_api_tests/stubs.py @@ -15,20 +15,22 @@ "extension_to_funcs", ] +spec_version = "2022.12" +spec_module = "_" + spec_version.replace('.', '_') -spec_dir = Path(__file__).parent.parent / "array-api" / "spec" / "API_specification" +spec_dir = Path(__file__).parent.parent / "array-api" / "spec" / spec_version / "API_specification" assert spec_dir.exists(), f"{spec_dir} not found - try `git submodule update --init`" -sigs_dir = spec_dir / "signatures" +sigs_dir = Path(__file__).parent.parent / "array-api" / "src" / "array_api_stubs" / spec_module assert sigs_dir.exists() -spec_abs_path: str = str(spec_dir.resolve()) -sys.path.append(spec_abs_path) -assert find_spec("signatures") is not None +sigs_abs_path: str = str(sigs_dir.parent.parent.resolve()) +sys.path.append(sigs_abs_path) +assert find_spec(f"array_api_stubs.{spec_module}") is not None name_to_mod: Dict[str, ModuleType] = {} for path in sigs_dir.glob("*.py"): name = path.name.replace(".py", "") - name_to_mod[name] = import_module(f"signatures.{name}") + name_to_mod[name] = import_module(f"array_api_stubs.{spec_module}.{name}") array = name_to_mod["array_object"].array array_methods = [ From 154c02ad6d4ff9cc3b54423e27a0e39cb7f0cd0b Mon Sep 17 00:00:00 2001 From: Matthew Barber Date: Wed, 15 Nov 2023 18:37:46 +0000 Subject: [PATCH 2/3] Sanity check special case params are being generated --- array_api_tests/test_special_cases.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/array_api_tests/test_special_cases.py b/array_api_tests/test_special_cases.py index 345d7fe5..be031afa 100644 --- a/array_api_tests/test_special_cases.py +++ b/array_api_tests/test_special_cases.py @@ -1197,6 +1197,10 @@ def parse_binary_case_block(case_block: str) -> List[BinaryCase]: # its False - Hypothesis will complain if we reject too many examples, thus # indicating we've done something wrong. +assert len(unary_params) != 0 # sanity check +assert len(binary_params) != 0 # sanity check +assert len(iop_params) != 0 # sanity check + @pytest.mark.parametrize("func_name, func, case", unary_params) @given( From 83dfe92816ba60d02e6ece81c4e22b3d2681b4a8 Mon Sep 17 00:00:00 2001 From: Matthew Barber Date: Thu, 16 Nov 2023 15:20:28 +0000 Subject: [PATCH 3/3] Remove `"complex-floating point"` hack for spec typo --- array-api | 2 +- array_api_tests/dtype_helpers.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/array-api b/array-api index 0f64005c..ab69aa24 160000 --- a/array-api +++ b/array-api @@ -1 +1 @@ -Subproject commit 0f64005c7af6cc1906f310e929d0b8fcac24fd41 +Subproject commit ab69aa240025ff1d52525ce3859b69ebfd6b7faf diff --git a/array_api_tests/dtype_helpers.py b/array_api_tests/dtype_helpers.py index d508f5b0..8d3bdf97 100644 --- a/array_api_tests/dtype_helpers.py +++ b/array_api_tests/dtype_helpers.py @@ -355,7 +355,6 @@ def result_type(*dtypes: DataType): "real-valued": real_float_dtypes, "real-valued floating-point": real_float_dtypes, "complex floating-point": complex_dtypes, - "complex-floating point": complex_dtypes, "numeric": numeric_dtypes, "integer or boolean": bool_and_all_int_dtypes, }