Skip to content

Make the test suite work if float64/complex128 are not available. #431

Description

@ev-br

Step 1: remove explicit imports of float64 and complex128.

Activity

  1. ev-br commented on Mar 21, 2026

    @ev-br
    MemberAuthor

    After #428, #429 and #430, the remaing complex128 entries are as below. Which is as good as it gets.

    $ git grep -n complex128
    array_api_tests/_array_module.py:31:    "complex64", "complex128",
    array_api_tests/dtype_helpers.py:105:complex_names = ("complex64", "complex128")
    array_api_tests/dtype_helpers.py:210:    complex_name = {"float32": "complex64", "float64": "complex128"}[real_name]
    array_api_tests/dtype_helpers.py:226:    real_name = {"complex64": "float32", "complex128": "float64"}[complex_name]
    array_api_tests/dtype_helpers.py:284:# complex128 if available else complex64
    array_api_tests/dtype_helpers.py:297:    {"complex64": xp.float32, "complex128": xp.float64}
    array_api_tests/dtype_helpers.py:376:    if api_version > "2021.12" and ({'complex64', 'complex128'} - set(skip_dtypes)):
    array_api_tests/dtype_helpers.py:434:    ("complex64", "complex128"): "complex128",
    array_api_tests/dtype_helpers.py:435:    ("complex128", "complex128"): "complex128",
    array_api_tests/test_signatures.py:159:        for dtype_name in ["float64", "bool", "int64", "complex128"]:
    array_api_tests/test_special_cases.py:586:        # complex64 -> float32, complex128 -> float64
    

    Explicit xp.float64s (removed docstrings and comments):

    array_api_tests/dtype_helpers.py:297:    {"complex64": xp.float32, "complex128": xp.float64}
    array_api_tests/test_creation_functions.py:213:                [(xp.bool,), (xp.int32, xp.int64), (xp.float32, xp.float64)]
    array_api_tests/test_creation_functions.py:245:            if dtype_family == (xp.float32, xp.float64):
    array_api_tests/test_creation_functions.py:399:    default_unsafe_dtypes.append(xp.float64)
    array_api_tests/test_operators_and_elementwise_functions.py:1133:                if min is not None and not dh.is_scalar(min) and min.dtype == xp.float64 and math.isfinite(_min):
    array_api_tests/test_operators_and_elementwise_functions.py:1140:                if max is not None and not dh.is_scalar(max) and max.dtype == xp.float64 and math.isfinite(_max):
    
    meta_tests/test_hypothesis_helpers.py:24:        (xp.float32, xp.float64),
    meta_tests/test_hypothesis_helpers.py:25:        (xp.float64, xp.float32),
    meta_tests/test_hypothesis_helpers.py:26:        (xp.float64, xp.float64),
    meta_tests/test_hypothesis_helpers.py:128:    assert any("d" in kw.keys() and kw["d"] is xp.float64 for kw in results)
    
  2. ev-br commented on Apr 3, 2026

    @ev-br
    MemberAuthor

    #434 makes the test suite run with torch "mps" default device.

    Lots of failures (details below the fold), the vast majority flag MPS limitations and are not major problems with the test suite itself. Running with more examples will surely smoke more MPS-specific bugs and edge cases, but overall ISTM we can declare the test suite mostly compatible.

    Details
    $ ARRAY_API_TESTS_SKIP_DTYPES=uint32,uint64,uint16,float64,complex128  pytest array_api_tests/ -vs --skips-file=../array-api-compat/torch-xfails.txt --max-examples=10
    
    ....
    
    ================================================================================ short test summary info ================================================================================
    FAILED array_api_tests/test_creation_functions.py::test_linspace - AssertionError: out[-1]=1072614395084800.0, but should be 1072614462193664.0 [linspace(0.0, 1072614462193664.0, 100)]
    FAILED array_api_tests/test_linalg.py::test_eigh - NotImplementedError: The operator 'aten::_linalg_eigh.eigenvalues' is not currently implemented for the MPS device. If you want this op to be considered for addition please comment...
    FAILED array_api_tests/test_linalg.py::test_eigvalsh - NotImplementedError: The operator 'aten::_linalg_eigh.eigenvalues' is not currently implemented for the MPS device. If you want this op to be considered for addition please comment...
    FAILED array_api_tests/test_linalg.py::test_eig - NotImplementedError: The operator 'aten::linalg_eig' is not currently implemented for the MPS device. If you want this op to be considered for addition please comment on https://gi...
    FAILED array_api_tests/test_linalg.py::test_eigvals - NotImplementedError: The operator 'aten::_linalg_eigvals' is not currently implemented for the MPS device. If you want this op to be considered for addition please comment on https...
    FAILED array_api_tests/test_linalg.py::test_matrix_rank - NotImplementedError: The operator 'aten::_linalg_svd.U' is not currently implemented for the MPS device. If you want this op to be considered for addition please comment on https:/...
    FAILED array_api_tests/test_linalg.py::test_qr - NotImplementedError: The operator 'aten::linalg_qr.out' is not currently implemented for the MPS device. If you want this op to be considered for addition please comment on https:/...
    FAILED array_api_tests/test_linalg.py::test_svdvals - NotImplementedError: The operator 'aten::_linalg_svd.U' is not currently implemented for the MPS device. If you want this op to be considered for addition please comment on https:/...
    FAILED array_api_tests/test_manipulation_functions.py::test_tile - RuntimeError: repeat(): Not supported for complex yet!
    FAILED array_api_tests/test_signatures.py::test_extension_func_signature[linalg.eigh] - NotImplementedError: The operator 'aten::_linalg_eigh.eigenvalues' is not currently implemented for the MPS device. If you want this op to be considered for addition please comment...
    FAILED array_api_tests/test_signatures.py::test_extension_func_signature[linalg.eigvalsh] - NotImplementedError: The operator 'aten::_linalg_eigh.eigenvalues' is not currently implemented for the MPS device. If you want this op to be considered for addition please comment...
    FAILED array_api_tests/test_signatures.py::test_extension_func_signature[linalg.matrix_rank] - NotImplementedError: The operator 'aten::_linalg_svd.U' is not currently implemented for the MPS device. If you want this op to be considered for addition please comment on https:/...
    FAILED array_api_tests/test_signatures.py::test_extension_func_signature[linalg.qr] - NotImplementedError: The operator 'aten::linalg_qr.out' is not currently implemented for the MPS device. If you want this op to be considered for addition please comment on https:/...
    FAILED array_api_tests/test_signatures.py::test_extension_func_signature[linalg.svdvals] - NotImplementedError: The operator 'aten::_linalg_svd.U' is not currently implemented for the MPS device. If you want this op to be considered for addition please comment on https:/...
    FAILED array_api_tests/test_special_cases.py::test_unary[acos((real(x_i) is +0 or real(x_i) == -0) and imag(x_i) is NaN) -> \u03c0/2 + NaN j] - AssertionError: out=(nan+nanj), but should be π/2 + NaN j [acos()]
    FAILED array_api_tests/test_special_cases.py::test_unary[acos(isfinite(real(x_i)) and imag(x_i) is +infinity) -> \u03c0/2 - infinity j] - AssertionError: out=(nan+nanj), but should be π/2 - infinity j [acos()]
    FAILED array_api_tests/test_special_cases.py::test_unary[acos(real(x_i) is -infinity and isfinite(imag(x_i)) and imag(x_i) > 0) -> \u03c0 - infinity j] - AssertionError: out=(nan+nanj), but should be π - infinity j [acos()]
    FAILED array_api_tests/test_special_cases.py::test_unary[acos(real(x_i) is +infinity and isfinite(imag(x_i)) and imag(x_i) > 0) -> +0 - infinity j] - AssertionError: out=(nan+nanj), but should be +0 - infinity j [acos()]
    FAILED array_api_tests/test_special_cases.py::test_unary[acos(real(x_i) is -infinity and imag(x_i) is +infinity) -> 3\u03c0/4 - infinity j] - AssertionError: out=(nan+nanj), but should be 3π/4 - infinity j [acos()]
    FAILED array_api_tests/test_special_cases.py::test_unary[acos(real(x_i) is +infinity and imag(x_i) is +infinity) -> \u03c0/4 - infinity j] - AssertionError: out=(nan+nanj), but should be π/4 - infinity j [acos()]
    FAILED array_api_tests/test_special_cases.py::test_unary[acos((real(x_i) is +infinity or real(x_i) == -infinity) and imag(x_i) is NaN) -> NaN \xb1 infinity j] - AssertionError: out=(nan+nanj), but should be NaN ± infinity j [acos()]
    FAILED array_api_tests/test_special_cases.py::test_unary[acos(real(x_i) is NaN and imag(x_i) is +infinity) -> NaN - infinity j] - AssertionError: out=(nan+nanj), but should be NaN - infinity j [acos()]
    FAILED array_api_tests/test_special_cases.py::test_unary[acosh(isfinite(real(x_i)) and imag(x_i) is +infinity) -> +infinity + \u03c0j/2] - AssertionError: out=(nan+nanj), but should be +infinity + πj/2 [acosh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[acosh(real(x_i) is +0 and imag(x_i) is NaN) -> NaN \xb1 \u03c0j/2] - AssertionError: out=(nan+nanj), but should be NaN ± πj/2 [acosh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[acosh(real(x_i) is -infinity and isfinite(imag(x_i)) and imag(x_i) > 0) -> +infinity + \u03c0j] - AssertionError: out=(nan+nanj), but should be +infinity + πj [acosh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[acosh(real(x_i) is +infinity and isfinite(imag(x_i)) and imag(x_i) > 0) -> +infinity + 0j] - AssertionError: out=(nan+nanj), but should be +infinity + 0j [acosh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[acosh(real(x_i) is -infinity and imag(x_i) is +infinity) -> +infinity + 3\u03c0j/4] - AssertionError: out=(nan+nanj), but should be +infinity + 3πj/4 [acosh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[acosh(real(x_i) is +infinity and imag(x_i) is +infinity) -> +infinity + \u03c0j/4] - AssertionError: out=(nan+nanj), but should be +infinity + πj/4 [acosh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[acosh((real(x_i) is +infinity or real(x_i) == -infinity) and imag(x_i) is NaN) -> +infinity + NaN j] - AssertionError: out=(nan+nanj), but should be +infinity + NaN j [acosh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[acosh(real(x_i) is NaN and imag(x_i) is +infinity) -> +infinity + NaN j] - AssertionError: out=(nan+nanj), but should be +infinity + NaN j [acosh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[asinh(isfinite(real(x_i)) and real(x_i) > 0 and imag(x_i) is +infinity) -> +infinity + \u03c0j/2] - AssertionError: out=(inf+0.7853981852531433j), but should be +infinity + πj/2 [asinh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[asinh(real(x_i) is +infinity and isfinite(imag(x_i)) and imag(x_i) > 0) -> +infinity + 0j] - AssertionError: out=(inf+0.7853981852531433j), but should be +infinity + 0j [asinh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[asinh(real(x_i) is +infinity and imag(x_i) is +infinity) -> +infinity + \u03c0j/4] - AssertionError: out=(nan+nanj), but should be +infinity + πj/4 [asinh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[asinh(real(x_i) is NaN and imag(x_i) is +0) -> NaN + 0j] - AssertionError: out=(nan+nanj), but should be NaN + 0j [asinh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[asinh(real(x_i) is NaN and imag(x_i) is +infinity) -> \xb1infinity + NaN j] - AssertionError: out=(nan+nanj), but should be ±infinity + NaN j [asinh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[atan(x_i is -0) -> -0] - AssertionError: out=0.0, but should be -0 [atan()]
    FAILED array_api_tests/test_special_cases.py::test_unary[atanh(real(x_i) is +0 and imag(x_i) is NaN) -> +0 + NaN j] - AssertionError: out=(nan+nanj), but should be +0 + NaN j [atanh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[atanh(isfinite(real(x_i)) and real(x_i) > 0 and imag(x_i) is +infinity) -> +0 + \u03c0j/2] - AssertionError: out=(nan+nanj), but should be +0 + πj/2 [atanh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[atanh(real(x_i) is +infinity and isfinite(imag(x_i)) and imag(x_i) > 0) -> +0 + \u03c0j/2] - AssertionError: out=(nan+nanj), but should be +0 + πj/2 [atanh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[atanh(real(x_i) is +infinity and imag(x_i) is +infinity) -> +0 + \u03c0j/2] - AssertionError: out=(nan+nanj), but should be +0 + πj/2 [atanh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[atanh(real(x_i) is +infinity and imag(x_i) is NaN) -> +0 + NaN j] - AssertionError: out=(nan+nanj), but should be +0 + NaN j [atanh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[atanh(real(x_i) is NaN and imag(x_i) is +infinity) -> \xb10 + \u03c0j/2] - AssertionError: out=(nan+nanj), but should be ±0 + πj/2 [atanh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[cosh(real(x_i) is +0 and imag(x_i) is +infinity) -> NaN + 0j] - AssertionError: out=(nan+nanj), but should be NaN + 0j [cosh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[cosh(real(x_i) is +0 and imag(x_i) is NaN) -> NaN + 0j] - AssertionError: out=(nan+nanj), but should be NaN + 0j [cosh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[cosh(real(x_i) is +infinity and imag(x_i) is +0) -> +infinity + 0j] - AssertionError: out=(nan+nanj), but should be +infinity + 0j [cosh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[cosh(real(x_i) is +infinity and imag(x_i) is +infinity) -> +infinity + NaN j] - AssertionError: out=(nan+nanj), but should be +infinity + NaN j [cosh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[cosh(real(x_i) is +infinity and imag(x_i) is NaN) -> +infinity + NaN j] - AssertionError: out=(nan+nanj), but should be +infinity + NaN j [cosh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[cosh(real(x_i) is NaN and (imag(x_i) is +0 or imag(x_i) == -0)) -> NaN + 0j] - AssertionError: out=(nan+nanj), but should be NaN + 0j [cosh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[exp(real(x_i) is +infinity and imag(x_i) is +0) -> infinity + 0j] - AssertionError: out=(inf+nanj), but should be infinity + 0j [exp()]
    FAILED array_api_tests/test_special_cases.py::test_unary[exp(real(x_i) is -infinity and imag(x_i) is +infinity) -> 0 + 0j] - AssertionError: out=(nan+nanj), but should be 0 + 0j [exp()]
    FAILED array_api_tests/test_special_cases.py::test_unary[exp(real(x_i) is +infinity and imag(x_i) is +infinity) -> infinity + NaN j] - AssertionError: out=(nan+nanj), but should be infinity + NaN j [exp()]
    FAILED array_api_tests/test_special_cases.py::test_unary[exp(real(x_i) is -infinity and imag(x_i) is NaN) -> 0 + 0j] - AssertionError: out=(nan+nanj), but should be 0 + 0j [exp()]
    FAILED array_api_tests/test_special_cases.py::test_unary[exp(real(x_i) is +infinity and imag(x_i) is NaN) -> infinity + NaN j] - AssertionError: out=(nan+nanj), but should be infinity + NaN j [exp()]
    FAILED array_api_tests/test_special_cases.py::test_unary[exp(real(x_i) is NaN and imag(x_i) is +0) -> NaN + 0j] - AssertionError: out=(nan+nanj), but should be NaN + 0j [exp()]
    FAILED array_api_tests/test_special_cases.py::test_unary[log(real(x_i) is -0 and imag(x_i) is +0) -> -infinity + \u03c0j] - AssertionError: out=(-inf+0j), but should be -infinity + πj [log()]
    FAILED array_api_tests/test_special_cases.py::test_unary[log((real(x_i) is +infinity or real(x_i) == -infinity) and imag(x_i) is NaN) -> +infinity + NaN j] - AssertionError: out=(nan+nanj), but should be +infinity + NaN j [log()]
    FAILED array_api_tests/test_special_cases.py::test_unary[log(real(x_i) is NaN and imag(x_i) is +infinity) -> +infinity + NaN j] - AssertionError: out=(nan+nanj), but should be +infinity + NaN j [log()]
    FAILED array_api_tests/test_special_cases.py::test_unary[sinh(real(x_i) is +0 and imag(x_i) is +infinity) -> 0 + NaN j] - AssertionError: out=(nan+nanj), but should be 0 + NaN j [sinh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[sinh(real(x_i) is +0 and imag(x_i) is NaN) -> 0 + NaN j] - AssertionError: out=(nan+nanj), but should be 0 + NaN j [sinh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[sinh(real(x_i) is +infinity and imag(x_i) is +0) -> +infinity + 0j] - AssertionError: out=(nan+nanj), but should be +infinity + 0j [sinh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[sinh(real(x_i) is +infinity and imag(x_i) is +infinity) -> infinity + NaN j] - AssertionError: out=(nan+nanj), but should be infinity + NaN j [sinh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[sinh(real(x_i) is +infinity and imag(x_i) is NaN) -> infinity + NaN j] - AssertionError: out=(nan+nanj), but should be infinity + NaN j [sinh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[sinh(real(x_i) is NaN and imag(x_i) is +0) -> NaN + 0j] - AssertionError: out=(nan+nanj), but should be NaN + 0j [sinh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[sqrt(real(x_i) is +infinity and isfinite(imag(x_i)) and imag(x_i) > 0) -> +infinity + 0 j] - AssertionError: out=(inf+nanj), but should be +infinity + 0 j [sqrt()]
    FAILED array_api_tests/test_special_cases.py::test_unary[sqrt(real(x_i) is -infinity and imag(x_i) is NaN) -> NaN + infinity j] - AssertionError: out=(nan+nanj), but should be NaN + infinity j [sqrt()]
    FAILED array_api_tests/test_special_cases.py::test_unary[sqrt(real(x_i) is +infinity and imag(x_i) is NaN) -> +infinity + NaN j] - AssertionError: out=(nan+nanj), but should be +infinity + NaN j [sqrt()]
    FAILED array_api_tests/test_special_cases.py::test_unary[tanh(real(x_i) is +0 and imag(x_i) is +infinity) -> +0 + NaN j] - AssertionError: out=(nan+nanj), but should be +0 + NaN j [tanh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[tanh(real(x_i) is +0 and imag(x_i) is NaN) -> +0 + NaN j] - AssertionError: out=(nan+nanj), but should be +0 + NaN j [tanh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[tanh(real(x_i) is +infinity and imag(x_i) is +infinity) -> 1 + 0j] - AssertionError: out=(nan+nanj), but should be 1 + 0j [tanh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[tanh(real(x_i) is +infinity and imag(x_i) is NaN) -> 1 + 0j] - AssertionError: out=(nan+nanj), but should be 1 + 0j [tanh()]
    FAILED array_api_tests/test_special_cases.py::test_unary[tanh(real(x_i) is NaN and imag(x_i) is +0) -> NaN + 0j] - AssertionError: out=(nan+nanj), but should be NaN + 0j [tanh()]
    FAILED array_api_tests/test_special_cases.py::test_binary[remainder(x1_i is -0 and x2_i < 0) -> -0] - AssertionError: out=0.0, but should be -0 [remainder()]
    FAILED array_api_tests/test_special_cases.py::test_binary[remainder(isfinite(x1_i) and x1_i > 0 and x2_i is +infinity) -> x1_i] - AssertionError: out=nan, but should be x1_i [remainder()]
    FAILED array_api_tests/test_special_cases.py::test_binary[remainder(isfinite(x1_i) and x1_i > 0 and x2_i is -infinity) -> x2_i] - AssertionError: out=nan, but should be x2_i [remainder()]
    FAILED array_api_tests/test_special_cases.py::test_binary[remainder(isfinite(x1_i) and x1_i < 0 and x2_i is +infinity) -> x2_i] - AssertionError: out=nan, but should be x2_i [remainder()]
    FAILED array_api_tests/test_special_cases.py::test_binary[remainder(isfinite(x1_i) and x1_i < 0 and x2_i is -infinity) -> x1_i] - AssertionError: out=nan, but should be x1_i [remainder()]
    FAILED array_api_tests/test_special_cases.py::test_iop[__imod__(x1_i is -0 and x2_i < 0) -> -0] - AssertionError: x1=0.0, but should be -0 [trunc()]
    FAILED array_api_tests/test_special_cases.py::test_iop[__imod__(isfinite(x1_i) and x1_i > 0 and x2_i is +infinity) -> x1_i] - AssertionError: x1=nan, but should be x1_i [trunc()]
    FAILED array_api_tests/test_special_cases.py::test_iop[__imod__(isfinite(x1_i) and x1_i > 0 and x2_i is -infinity) -> x2_i] - AssertionError: x1=nan, but should be x2_i [trunc()]
    FAILED array_api_tests/test_special_cases.py::test_iop[__imod__(isfinite(x1_i) and x1_i < 0 and x2_i is +infinity) -> x2_i] - AssertionError: x1=nan, but should be x2_i [trunc()]
    FAILED array_api_tests/test_special_cases.py::test_iop[__imod__(isfinite(x1_i) and x1_i < 0 and x2_i is -infinity) -> x1_i] - AssertionError: x1=nan, but should be x1_i [trunc()]
    FAILED array_api_tests/test_special_cases.py::test_empty_arrays[std] - AssertionError: out=tensor(1., device='mps:0'), but should be nan
    FAILED array_api_tests/test_special_cases.py::test_empty_arrays[var] - AssertionError: out=tensor(0., device='mps:0'), but should be nan
    ============================================================== 83 failed, 1153 passed, 127 skipped, 116 warnings in 15.40s ==============================================================
    
    
  3. ev-br commented on Apr 3, 2026

    @ev-br
    MemberAuthor

    #435 makes a small tweak to avoid a failure with JAX in the "no 64-bit" mode, i.e. when JAX_ENABLE_X64 env variable is not set.

  4. aaishwarymishra commented on Jul 19, 2026

    @aaishwarymishra

    Hi, I am not sure if this is relevant here but i faced few problems with the MLX,
    When I put export ARRAY_API_TESTS_SKIP_DTYPES=float64,complex128,complex64 the tests didn't ran as few tests assume there will be atleast a single complex type when running the tests and it failed to run. The reason I ran test without the complex datatypes because MLX does not have __complex__ implemented and it gives error when using complex(arr) which some tests use, it maybe just MLX case but I think tests should be resilient if a complete dtype category is ignored maybe.

  5. ev-br commented on Sep 14, 2026

    @ev-br
    MemberAuthor

    The test suite now runs with MLX in ml-explore/mlx#4433. This issue can thus be closed as completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions