From 93290ad93792dc596238feccdcfb8aa7418fec1e Mon Sep 17 00:00:00 2001 From: mtar <18899420+mtar@users.noreply.github.com> Date: Mon, 31 Aug 2026 16:34:48 +0200 Subject: [PATCH 1/8] move test skips.txt and xfails.txt --- .github/array_api_test/skips.txt | 89 ++++++++++ .github/array_api_test/xfails.txt | 269 ++++++++++++++++++++++++++++++ 2 files changed, 358 insertions(+) create mode 100644 .github/array_api_test/skips.txt create mode 100644 .github/array_api_test/xfails.txt diff --git a/.github/array_api_test/skips.txt b/.github/array_api_test/skips.txt new file mode 100644 index 0000000000..3fb57d77f3 --- /dev/null +++ b/.github/array_api_test/skips.txt @@ -0,0 +1,89 @@ +# fails sometimes +array_api_tests/test_creation_functions.py::test_asarray_scalars +array_api_tests/test_linalg.py::test_matmul +array_api_tests/test_manipulation_functions.py::test_concat +array_api_tests/test_manipulation_functions.py::test_expand_dims +array_api_tests/test_manipulation_functions.py::test_squeeze +array_api_tests/test_manipulation_functions.py::test_flip +array_api_tests/test_manipulation_functions.py::test_permute_dims +array_api_tests/test_manipulation_functions.py::test_roll +array_api_tests/test_manipulation_functions.py::test_stack +array_api_tests/test_operators_and_elementwise_functions.py::test_add[add(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_add[__add__(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_add[__add__(x, s)] +array_api_tests/test_operators_and_elementwise_functions.py::test_add[__iadd__(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_add[__iadd__(x, s)] +array_api_tests/test_operators_and_elementwise_functions.py::test_atan2 +array_api_tests/test_operators_and_elementwise_functions.py::test_ceil +array_api_tests/test_operators_and_elementwise_functions.py::test_equal[equal(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_equal[__eq__(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_equal[__eq__(x, s)] +array_api_tests/test_operators_and_elementwise_functions.py::test_floor +array_api_tests/test_operators_and_elementwise_functions.py::test_greater[greater(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_greater[__gt__(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_greater[__gt__(x, s)] +array_api_tests/test_operators_and_elementwise_functions.py::test_greater_equal[greater_equal(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_greater_equal[__ge__(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_greater_equal[__ge__(x, s)] +array_api_tests/test_operators_and_elementwise_functions.py::test_isfinite +array_api_tests/test_operators_and_elementwise_functions.py::test_isinf +array_api_tests/test_operators_and_elementwise_functions.py::test_isnan +array_api_tests/test_operators_and_elementwise_functions.py::test_less[less(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_less[__lt__(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_less[__lt__(x, s)] +array_api_tests/test_operators_and_elementwise_functions.py::test_less_equal[less_equal(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_less_equal[__le__(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_less_equal[__le__(x, s)] +array_api_tests/test_operators_and_elementwise_functions.py::test_log2 +array_api_tests/test_operators_and_elementwise_functions.py::test_logaddexp +array_api_tests/test_operators_and_elementwise_functions.py::test_multiply[multiply(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_multiply[__mul__(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_multiply[__mul__(x, s)] +array_api_tests/test_operators_and_elementwise_functions.py::test_multiply[__imul__(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_multiply[__imul__(x, s)] +array_api_tests/test_operators_and_elementwise_functions.py::test_not_equal[not_equal(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_not_equal[__ne__(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_not_equal[__ne__(x, s)] +array_api_tests/test_operators_and_elementwise_functions.py::test_pow[__pow__(x, s)] +array_api_tests/test_operators_and_elementwise_functions.py::test_pow[__ipow__(x, s)] +array_api_tests/test_operators_and_elementwise_functions.py::test_round +array_api_tests/test_operators_and_elementwise_functions.py::test_sign +array_api_tests/test_operators_and_elementwise_functions.py::test_square +array_api_tests/test_operators_and_elementwise_functions.py::test_subtract[subtract(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_subtract[__sub__(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_subtract[__sub__(x, s)] +array_api_tests/test_operators_and_elementwise_functions.py::test_subtract[__isub__(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_subtract[__isub__(x, s)] +array_api_tests/test_operators_and_elementwise_functions.py::test_trunc +array_api_tests/test_searching_functions.py::test_where +array_api_tests/test_set_functions.py::test_unique_inverse +array_api_tests/test_set_functions.py::test_unique_values +array_api_tests/test_special_cases.py::test_unary[acos(x_i < -1) -> NaN] +array_api_tests/test_special_cases.py::test_unary[acos(x_i > 1) -> NaN] +array_api_tests/test_special_cases.py::test_unary[asin(x_i > 1) -> NaN] +array_api_tests/test_special_cases.py::test_unary[asin(x_i < -1) -> NaN] +array_api_tests/test_special_cases.py::test_unary[atanh(x_i < -1) -> NaN] +array_api_tests/test_special_cases.py::test_unary[ceil(x_i.is_integer()) -> x_i] +array_api_tests/test_special_cases.py::test_unary[floor(x_i.is_integer()) -> x_i] +array_api_tests/test_special_cases.py::test_unary[log(x_i < 0) -> NaN] +array_api_tests/test_special_cases.py::test_unary[log2(x_i < 0) -> NaN] +array_api_tests/test_special_cases.py::test_unary[log10(x_i < 0) -> NaN] +array_api_tests/test_special_cases.py::test_unary[round(x_i.is_integer()) -> x_i] +array_api_tests/test_special_cases.py::test_unary[round(modf(i)[0] == 0.5) -> Decimal(i).to_integral_exact(ROUND_HALF_EVEN)] +array_api_tests/test_special_cases.py::test_unary[sign(x_i < 0) -> -1] +array_api_tests/test_special_cases.py::test_unary[sign(x_i > 0) -> +1] +array_api_tests/test_special_cases.py::test_unary[sqrt(x_i < 0) -> NaN] +array_api_tests/test_special_cases.py::test_unary[trunc(x_i.is_integer()) -> x_i] +array_api_tests/test_special_cases.py::test_binary[add((x1_i is +0 or x1_i == -0) and isfinite(x2_i) and x2_i != 0) -> x2_i] +array_api_tests/test_special_cases.py::test_binary[add(isfinite(x1_i) and x1_i != 0 and (x2_i is +0 or x2_i == -0)) -> x1_i] +array_api_tests/test_special_cases.py::test_binary[add(isfinite(x1_i) and x1_i != 0 and x2_i == -x1_i) -> +0] +array_api_tests/test_special_cases.py::test_binary[__add__((x1_i is +0 or x1_i == -0) and isfinite(x2_i) and x2_i != 0) -> x2_i] +array_api_tests/test_special_cases.py::test_binary[__add__(isfinite(x1_i) and x1_i != 0 and (x2_i is +0 or x2_i == -0)) -> x1_i] +array_api_tests/test_special_cases.py::test_binary[__add__(isfinite(x1_i) and x1_i != 0 and x2_i == -x1_i) -> +0] +array_api_tests/test_special_cases.py::test_binary[pow(x1_i < 0 and isfinite(x1_i) and isfinite(x2_i) and not x2_i.is_integer()) -> NaN] +array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i is NaN and not x2_i == 0) -> NaN] +array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i < 0 and isfinite(x1_i) and isfinite(x2_i) and not x2_i.is_integer()) -> NaN] +array_api_tests/test_special_cases.py::test_iop[__iadd__((x1_i is +0 or x1_i == -0) and isfinite(x2_i) and x2_i != 0) -> x2_i] +array_api_tests/test_special_cases.py::test_iop[__iadd__(isfinite(x1_i) and x1_i != 0 and (x2_i is +0 or x2_i == -0)) -> x1_i] +array_api_tests/test_special_cases.py::test_iop[__iadd__(isfinite(x1_i) and x1_i != 0 and x2_i == -x1_i) -> +0] +array_api_tests/test_special_cases.py::test_iop[__ipow__(x1_i < 0 and isfinite(x1_i) and isfinite(x2_i) and not x2_i.is_integer()) -> NaN] diff --git a/.github/array_api_test/xfails.txt b/.github/array_api_test/xfails.txt new file mode 100644 index 0000000000..a69262c2c4 --- /dev/null +++ b/.github/array_api_test/xfails.txt @@ -0,0 +1,269 @@ +# fails every time +array_api_tests/test_array_object.py::test_getitem +array_api_tests/test_array_object.py::test_setitem +array_api_tests/test_array_object.py::test_getitem_masking +array_api_tests/test_array_object.py::test_setitem_masking +array_api_tests/test_array_object.py::test_getitem_arrays_and_ints_1[None] +array_api_tests/test_array_object.py::test_getitem_arrays_and_ints_2[None] +array_api_tests/test_creation_functions.py::test_asarray_arrays +array_api_tests/test_creation_functions.py::test_empty +array_api_tests/test_creation_functions.py::test_empty_like +array_api_tests/test_creation_functions.py::test_eye +array_api_tests/test_creation_functions.py::test_full +array_api_tests/test_creation_functions.py::test_full_like +array_api_tests/test_creation_functions.py::test_linspace +array_api_tests/test_creation_functions.py::test_meshgrid +array_api_tests/test_creation_functions.py::test_ones +array_api_tests/test_creation_functions.py::test_ones_like +array_api_tests/test_creation_functions.py::test_tril +array_api_tests/test_creation_functions.py::test_triu +array_api_tests/test_creation_functions.py::test_zeros +array_api_tests/test_creation_functions.py::test_zeros_like +array_api_tests/test_has_names.py::test_has_names[linalg-cholesky] +array_api_tests/test_has_names.py::test_has_names[linalg-cross] +array_api_tests/test_has_names.py::test_has_names[linalg-det] +array_api_tests/test_has_names.py::test_has_names[linalg-diagonal] +array_api_tests/test_has_names.py::test_has_names[linalg-eigh] +array_api_tests/test_has_names.py::test_has_names[linalg-eigvalsh] +array_api_tests/test_has_names.py::test_has_names[linalg-inv] +array_api_tests/test_has_names.py::test_has_names[linalg-matrix_norm] +array_api_tests/test_has_names.py::test_has_names[linalg-matrix_power] +array_api_tests/test_has_names.py::test_has_names[linalg-matrix_rank] +array_api_tests/test_has_names.py::test_has_names[linalg-outer] +array_api_tests/test_has_names.py::test_has_names[linalg-pinv] +array_api_tests/test_has_names.py::test_has_names[linalg-qr] +array_api_tests/test_has_names.py::test_has_names[linalg-slogdet] +array_api_tests/test_has_names.py::test_has_names[linalg-solve] +array_api_tests/test_has_names.py::test_has_names[linalg-svd] +array_api_tests/test_has_names.py::test_has_names[linalg-svdvals] +array_api_tests/test_has_names.py::test_has_names[linalg-trace] +array_api_tests/test_has_names.py::test_has_names[linalg-vector_norm] +array_api_tests/test_has_names.py::test_has_names[fft-fft] +array_api_tests/test_has_names.py::test_has_names[fft-ifft] +array_api_tests/test_has_names.py::test_has_names[fft-fftn] +array_api_tests/test_has_names.py::test_has_names[fft-ifftn] +array_api_tests/test_has_names.py::test_has_names[fft-rfft] +array_api_tests/test_has_names.py::test_has_names[fft-irfft] +array_api_tests/test_has_names.py::test_has_names[fft-rfftn] +array_api_tests/test_has_names.py::test_has_names[fft-irfftn] +array_api_tests/test_has_names.py::test_has_names[fft-hfft] +array_api_tests/test_has_names.py::test_has_names[fft-ihfft] +array_api_tests/test_has_names.py::test_has_names[fft-fftfreq] +array_api_tests/test_has_names.py::test_has_names[fft-rfftfreq] +array_api_tests/test_has_names.py::test_has_names[fft-fftshift] +array_api_tests/test_has_names.py::test_has_names[fft-ifftshift] +array_api_tests/test_has_names.py::test_has_names[indexing-take] +array_api_tests/test_has_names.py::test_has_names[set-unique_all] +array_api_tests/test_has_names.py::test_has_names[set-unique_counts] +array_api_tests/test_has_names.py::test_has_names[manipulation-moveaxis] +array_api_tests/test_has_names.py::test_has_names[manipulation-repeat] +array_api_tests/test_has_names.py::test_has_names[manipulation-tile] +array_api_tests/test_has_names.py::test_has_names[manipulation-unstack] +array_api_tests/test_has_names.py::test_has_names[searching-searchsorted] +array_api_tests/test_has_names.py::test_has_names[elementwise-clip] +array_api_tests/test_has_names.py::test_has_names[elementwise-conj] +array_api_tests/test_has_names.py::test_has_names[elementwise-copysign] +array_api_tests/test_has_names.py::test_has_names[elementwise-hypot] +array_api_tests/test_has_names.py::test_has_names[elementwise-imag] +array_api_tests/test_has_names.py::test_has_names[elementwise-maximum] +array_api_tests/test_has_names.py::test_has_names[elementwise-minimum] +array_api_tests/test_has_names.py::test_has_names[elementwise-real] +array_api_tests/test_has_names.py::test_has_names[elementwise-signbit] +array_api_tests/test_has_names.py::test_has_names[statistical-cumulative_sum] +array_api_tests/test_has_names.py::test_has_names[sorting-argsort] +array_api_tests/test_has_names.py::test_has_names[data_type-isdtype] +array_api_tests/test_has_names.py::test_has_names[info-__array_namespace_info__] +array_api_tests/test_has_names.py::test_has_names[array_method-__complex__] +array_api_tests/test_indexing_functions.py::test_take +array_api_tests/test_inspection_functions.py::test_array_namespace_info +array_api_tests/test_inspection_functions.py::test_array_namespace_info_dtypes +array_api_tests/test_linalg.py::test_matrix_transpose +array_api_tests/test_linalg.py::test_tensordot +array_api_tests/test_linalg.py::test_vecdot +array_api_tests/test_manipulation_functions.py::test_moveaxis +array_api_tests/test_manipulation_functions.py::test_repeat +array_api_tests/test_manipulation_functions.py::test_tile +array_api_tests/test_manipulation_functions.py::test_unstack +array_api_tests/test_operators_and_elementwise_functions.py::test_abs[abs] +array_api_tests/test_operators_and_elementwise_functions.py::test_abs[__abs__] +array_api_tests/test_operators_and_elementwise_functions.py::test_acos +array_api_tests/test_operators_and_elementwise_functions.py::test_acosh +array_api_tests/test_operators_and_elementwise_functions.py::test_asin +array_api_tests/test_operators_and_elementwise_functions.py::test_asinh +array_api_tests/test_operators_and_elementwise_functions.py::test_atan +array_api_tests/test_operators_and_elementwise_functions.py::test_atanh +array_api_tests/test_operators_and_elementwise_functions.py::test_bitwise_left_shift[bitwise_left_shift(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_bitwise_left_shift[__lshift__(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_bitwise_left_shift[__ilshift__(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_bitwise_right_shift[bitwise_right_shift(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_bitwise_right_shift[__rshift__(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_bitwise_right_shift[__irshift__(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_clip +array_api_tests/test_operators_and_elementwise_functions.py::test_conj +array_api_tests/test_operators_and_elementwise_functions.py::test_copysign +array_api_tests/test_operators_and_elementwise_functions.py::test_cos +array_api_tests/test_operators_and_elementwise_functions.py::test_cosh +array_api_tests/test_operators_and_elementwise_functions.py::test_divide[divide(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_divide[__truediv__(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_divide[__truediv__(x, s)] +array_api_tests/test_operators_and_elementwise_functions.py::test_divide[__itruediv__(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_divide[__itruediv__(x, s)] +array_api_tests/test_operators_and_elementwise_functions.py::test_exp +array_api_tests/test_operators_and_elementwise_functions.py::test_expm1 +array_api_tests/test_operators_and_elementwise_functions.py::test_floor_divide[floor_divide(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_floor_divide[__floordiv__(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_floor_divide[__floordiv__(x, s)] +array_api_tests/test_operators_and_elementwise_functions.py::test_floor_divide[__ifloordiv__(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_floor_divide[__ifloordiv__(x, s)] +array_api_tests/test_operators_and_elementwise_functions.py::test_hypot +array_api_tests/test_operators_and_elementwise_functions.py::test_imag +array_api_tests/test_operators_and_elementwise_functions.py::test_log +array_api_tests/test_operators_and_elementwise_functions.py::test_log1p +array_api_tests/test_operators_and_elementwise_functions.py::test_log10 +array_api_tests/test_operators_and_elementwise_functions.py::test_maximum +array_api_tests/test_operators_and_elementwise_functions.py::test_minimum +array_api_tests/test_operators_and_elementwise_functions.py::test_negative[negative] +array_api_tests/test_operators_and_elementwise_functions.py::test_negative[__neg__] +array_api_tests/test_operators_and_elementwise_functions.py::test_positive[positive] +array_api_tests/test_operators_and_elementwise_functions.py::test_positive[__pos__] +array_api_tests/test_operators_and_elementwise_functions.py::test_pow[pow(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_pow[__pow__(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_pow[__ipow__(x1, x2)] +array_api_tests/test_operators_and_elementwise_functions.py::test_real +array_api_tests/test_operators_and_elementwise_functions.py::test_signbit +array_api_tests/test_operators_and_elementwise_functions.py::test_sin +array_api_tests/test_operators_and_elementwise_functions.py::test_sinh +array_api_tests/test_operators_and_elementwise_functions.py::test_sqrt +array_api_tests/test_operators_and_elementwise_functions.py::test_tan +array_api_tests/test_operators_and_elementwise_functions.py::test_tanh +array_api_tests/test_searching_functions.py::test_argmax +array_api_tests/test_searching_functions.py::test_argmin +array_api_tests/test_searching_functions.py::test_nonzero_zerodim_error +array_api_tests/test_searching_functions.py::test_nonzero +array_api_tests/test_searching_functions.py::test_searchsorted +array_api_tests/test_set_functions.py::test_unique_all +array_api_tests/test_set_functions.py::test_unique_counts +array_api_tests/test_signatures.py::test_func_signature[from_dlpack] +array_api_tests/test_signatures.py::test_func_signature[take] +array_api_tests/test_signatures.py::test_func_signature[unique_all] +array_api_tests/test_signatures.py::test_func_signature[unique_counts] +array_api_tests/test_signatures.py::test_func_signature[moveaxis] +array_api_tests/test_signatures.py::test_func_signature[repeat] +array_api_tests/test_signatures.py::test_func_signature[tile] +array_api_tests/test_signatures.py::test_func_signature[unstack] +array_api_tests/test_signatures.py::test_func_signature[searchsorted] +array_api_tests/test_signatures.py::test_func_signature[clip] +array_api_tests/test_signatures.py::test_func_signature[conj] +array_api_tests/test_signatures.py::test_func_signature[copysign] +array_api_tests/test_signatures.py::test_func_signature[hypot] +array_api_tests/test_signatures.py::test_func_signature[imag] +array_api_tests/test_signatures.py::test_func_signature[maximum] +array_api_tests/test_signatures.py::test_func_signature[minimum] +array_api_tests/test_signatures.py::test_func_signature[real] +array_api_tests/test_signatures.py::test_func_signature[signbit] +array_api_tests/test_signatures.py::test_func_signature[cumulative_sum] +array_api_tests/test_signatures.py::test_func_signature[argsort] +array_api_tests/test_signatures.py::test_func_signature[astype] +array_api_tests/test_signatures.py::test_func_signature[isdtype] +array_api_tests/test_signatures.py::test_func_signature[__array_namespace_info__] +array_api_tests/test_signatures.py::test_array_method_signature[__complex__] +array_api_tests/test_signatures.py::test_array_method_signature[__dlpack__] +array_api_tests/test_signatures.py::test_info_func_signature[capabilities] +array_api_tests/test_signatures.py::test_info_func_signature[default_device] +array_api_tests/test_signatures.py::test_info_func_signature[default_dtypes] +array_api_tests/test_signatures.py::test_info_func_signature[devices] +array_api_tests/test_signatures.py::test_info_func_signature[dtypes] +array_api_tests/test_sorting_functions.py::test_argsort +array_api_tests/test_sorting_functions.py::test_sort +array_api_tests/test_special_cases.py::test_unary[isfinite((x_i is +infinity or x_i == -infinity)) -> False] +array_api_tests/test_special_cases.py::test_unary[isfinite(x_i is NaN) -> False] +array_api_tests/test_special_cases.py::test_unary[isfinite(isfinite(x_i)) -> True] +array_api_tests/test_special_cases.py::test_unary[isinf((x_i is +infinity or x_i == -infinity)) -> True] +array_api_tests/test_special_cases.py::test_unary[isnan(x_i is NaN) -> True] +array_api_tests/test_special_cases.py::test_unary[sign(x_i is NaN) -> NaN] +array_api_tests/test_special_cases.py::test_unary[signbit(x_i is +0) -> False] +array_api_tests/test_special_cases.py::test_unary[signbit(x_i is -0) -> True] +array_api_tests/test_special_cases.py::test_unary[signbit(x_i is +infinity) -> False] +array_api_tests/test_special_cases.py::test_unary[signbit(x_i is -infinity) -> True] +array_api_tests/test_special_cases.py::test_unary[signbit(isfinite(x_i) and x_i > 0) -> False] +array_api_tests/test_special_cases.py::test_unary[signbit(isfinite(x_i) and x_i < 0) -> True] +array_api_tests/test_special_cases.py::test_unary[signbit(x_i is +NaN) -> False] +array_api_tests/test_special_cases.py::test_unary[signbit(x_i is -NaN) -> True] +array_api_tests/test_special_cases.py::test_binary[copysign(x1_i is NaN and x2_i < 0) -> NaN] +array_api_tests/test_special_cases.py::test_binary[copysign(x1_i is NaN and x2_i is -0) -> NaN] +array_api_tests/test_special_cases.py::test_binary[copysign(x1_i is NaN and x2_i is +0) -> NaN] +array_api_tests/test_special_cases.py::test_binary[copysign(x1_i is NaN and x2_i > 0) -> NaN] +array_api_tests/test_special_cases.py::test_binary[divide(x1_i is +0 and x2_i > 0) -> +0] +array_api_tests/test_special_cases.py::test_binary[divide(x1_i is -0 and x2_i > 0) -> -0] +array_api_tests/test_special_cases.py::test_binary[divide(x1_i is +0 and x2_i < 0) -> -0] +array_api_tests/test_special_cases.py::test_binary[divide(x1_i is -0 and x2_i < 0) -> +0] +array_api_tests/test_special_cases.py::test_binary[divide(x1_i > 0 and x2_i is +0) -> +infinity] +array_api_tests/test_special_cases.py::test_binary[divide(x1_i > 0 and x2_i is -0) -> -infinity] +array_api_tests/test_special_cases.py::test_binary[divide(x1_i < 0 and x2_i is +0) -> -infinity] +array_api_tests/test_special_cases.py::test_binary[divide(x1_i < 0 and x2_i is -0) -> +infinity] +array_api_tests/test_special_cases.py::test_binary[__truediv__(x1_i is +0 and x2_i > 0) -> +0] +array_api_tests/test_special_cases.py::test_binary[__truediv__(x1_i is -0 and x2_i > 0) -> -0] +array_api_tests/test_special_cases.py::test_binary[__truediv__(x1_i is +0 and x2_i < 0) -> -0] +array_api_tests/test_special_cases.py::test_binary[__truediv__(x1_i is -0 and x2_i < 0) -> +0] +array_api_tests/test_special_cases.py::test_binary[__truediv__(x1_i > 0 and x2_i is +0) -> +infinity] +array_api_tests/test_special_cases.py::test_binary[__truediv__(x1_i > 0 and x2_i is -0) -> -infinity] +array_api_tests/test_special_cases.py::test_binary[__truediv__(x1_i < 0 and x2_i is +0) -> -infinity] +array_api_tests/test_special_cases.py::test_binary[__truediv__(x1_i < 0 and x2_i is -0) -> +infinity] +array_api_tests/test_special_cases.py::test_binary[maximum(x1_i is NaN or x2_i is NaN) -> NaN] +array_api_tests/test_special_cases.py::test_binary[minimum(x1_i is NaN or x2_i is NaN) -> NaN] +array_api_tests/test_special_cases.py::test_binary[pow(abs(x1_i) > 1 and x2_i is +infinity) -> +infinity] +array_api_tests/test_special_cases.py::test_binary[pow(abs(x1_i) > 1 and x2_i is -infinity) -> +0] +array_api_tests/test_special_cases.py::test_binary[pow(x1_i is +infinity and x2_i > 0) -> +infinity] +array_api_tests/test_special_cases.py::test_binary[pow(x1_i is +infinity and x2_i < 0) -> +0] +array_api_tests/test_special_cases.py::test_binary[pow(x1_i is -infinity and x2_i > 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +infinity] +array_api_tests/test_special_cases.py::test_binary[pow(x1_i is -infinity and x2_i < 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +0] +array_api_tests/test_special_cases.py::test_binary[pow(x1_i is +0 and x2_i > 0) -> +0] +array_api_tests/test_special_cases.py::test_binary[pow(x1_i is +0 and x2_i < 0) -> +infinity] +array_api_tests/test_special_cases.py::test_binary[pow(x1_i is -0 and x2_i > 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +0] +array_api_tests/test_special_cases.py::test_binary[pow(x1_i is -0 and x2_i < 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +infinity] +array_api_tests/test_special_cases.py::test_binary[__pow__(abs(x1_i) > 1 and x2_i is +infinity) -> +infinity] +array_api_tests/test_special_cases.py::test_binary[__pow__(abs(x1_i) > 1 and x2_i is -infinity) -> +0] +array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i is +infinity and x2_i > 0) -> +infinity] +array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i is +infinity and x2_i < 0) -> +0] +array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i is -infinity and x2_i > 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +infinity] +array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i is -infinity and x2_i < 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +0] +array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i is +0 and x2_i > 0) -> +0] +array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i is +0 and x2_i < 0) -> +infinity] +array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i is -0 and x2_i > 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +0] +array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i is -0 and x2_i < 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +infinity] +array_api_tests/test_special_cases.py::test_iop[__itruediv__(x1_i is +0 and x2_i > 0) -> +0] +array_api_tests/test_special_cases.py::test_iop[__itruediv__(x1_i is -0 and x2_i > 0) -> -0] +array_api_tests/test_special_cases.py::test_iop[__itruediv__(x1_i is +0 and x2_i < 0) -> -0] +array_api_tests/test_special_cases.py::test_iop[__itruediv__(x1_i is -0 and x2_i < 0) -> +0] +array_api_tests/test_special_cases.py::test_iop[__itruediv__(x1_i > 0 and x2_i is +0) -> +infinity] +array_api_tests/test_special_cases.py::test_iop[__itruediv__(x1_i > 0 and x2_i is -0) -> -infinity] +array_api_tests/test_special_cases.py::test_iop[__itruediv__(x1_i < 0 and x2_i is +0) -> -infinity] +array_api_tests/test_special_cases.py::test_iop[__itruediv__(x1_i < 0 and x2_i is -0) -> +infinity] +array_api_tests/test_special_cases.py::test_iop[__ipow__(abs(x1_i) > 1 and x2_i is +infinity) -> +infinity] +array_api_tests/test_special_cases.py::test_iop[__ipow__(abs(x1_i) > 1 and x2_i is -infinity) -> +0] +array_api_tests/test_special_cases.py::test_iop[__ipow__(x1_i is +infinity and x2_i > 0) -> +infinity] +array_api_tests/test_special_cases.py::test_iop[__ipow__(x1_i is +infinity and x2_i < 0) -> +0] +array_api_tests/test_special_cases.py::test_iop[__ipow__(x1_i is -infinity and x2_i > 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +infinity] +array_api_tests/test_special_cases.py::test_iop[__ipow__(x1_i is -infinity and x2_i < 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +0] +array_api_tests/test_special_cases.py::test_iop[__ipow__(x1_i is +0 and x2_i > 0) -> +0] +array_api_tests/test_special_cases.py::test_iop[__ipow__(x1_i is +0 and x2_i < 0) -> +infinity] +array_api_tests/test_special_cases.py::test_iop[__ipow__(x1_i is -0 and x2_i > 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +0] +array_api_tests/test_special_cases.py::test_iop[__ipow__(x1_i is -0 and x2_i < 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +infinity] +array_api_tests/test_special_cases.py::test_empty_arrays[prod] +array_api_tests/test_special_cases.py::test_empty_arrays[std] +array_api_tests/test_special_cases.py::test_empty_arrays[sum] +array_api_tests/test_special_cases.py::test_nan_propagation[max] +array_api_tests/test_special_cases.py::test_nan_propagation[mean] +array_api_tests/test_special_cases.py::test_nan_propagation[min] +array_api_tests/test_special_cases.py::test_nan_propagation[prod] +array_api_tests/test_special_cases.py::test_nan_propagation[std] +array_api_tests/test_special_cases.py::test_nan_propagation[sum] +array_api_tests/test_special_cases.py::test_nan_propagation[var] +array_api_tests/test_statistical_functions.py::test_cumulative_sum +array_api_tests/test_statistical_functions.py::test_max +array_api_tests/test_statistical_functions.py::test_mean +array_api_tests/test_statistical_functions.py::test_min +array_api_tests/test_statistical_functions.py::test_prod +array_api_tests/test_statistical_functions.py::test_sum +array_api_tests/test_utility_functions.py::test_all +array_api_tests/test_utility_functions.py::test_any From d5709f093f47760aa194bf1c40146613caa4681e Mon Sep 17 00:00:00 2001 From: mtar <18899420+mtar@users.noreply.github.com> Date: Mon, 31 Aug 2026 16:35:43 +0200 Subject: [PATCH 2/8] use main namespace for array_api_tests_module --- .github/workflows/array-api.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/array-api.yml b/.github/workflows/array-api.yml index 4700076041..e41499ffe3 100644 --- a/.github/workflows/array-api.yml +++ b/.github/workflows/array-api.yml @@ -40,9 +40,9 @@ jobs: python -m pip install -r ${GITHUB_WORKSPACE}/array-api-tests/requirements.txt - name: Run the test suite env: - ARRAY_API_TESTS_MODULE: heat.array_api + ARRAY_API_TESTS_MODULE: heat run: | export PYTHONPATH="${GITHUB_WORKSPACE}/heat" # Skip testing functions with known issues cd ${GITHUB_WORKSPACE}/array-api-tests - pytest array_api_tests/ -v -rxXfE --ci --xfails-file ${GITHUB_WORKSPACE}/heat/heat/array_api/test/xfails.txt --skips-file ${GITHUB_WORKSPACE}/heat/heat/array_api/test/skips.txt --disable-extension linalg + pytest array_api_tests/ -v -rxXfE --ci --xfails-file ${GITHUB_WORKSPACE}/heat/heat/array_api/test/xfails.txt --skips-file ${GITHUB_WORKSPACE}/heat/heat/array_api/test/skips.txt --disable-extension linalg --disable-extension fft From 5acb17e820038b5c8a7c25c6d925846036ba8443 Mon Sep 17 00:00:00 2001 From: mtar <18899420+mtar@users.noreply.github.com> Date: Mon, 31 Aug 2026 16:36:00 +0200 Subject: [PATCH 3/8] delete array_api namespace --- heat/array_api/__init__.py | 276 ------ heat/array_api/_array_object.py | 942 ------------------ heat/array_api/_creation_functions.py | 477 ---------- heat/array_api/_data_type_functions.py | 178 ---- heat/array_api/_dtypes.py | 203 ---- heat/array_api/_elementwise_functions.py | 1054 --------------------- heat/array_api/_inspection.py | 197 ---- heat/array_api/_manipulation_functions.py | 167 ---- heat/array_api/_searching_functions.py | 89 -- heat/array_api/_set_functions.py | 46 - heat/array_api/_sorting_functions.py | 32 - heat/array_api/_statistical_functions.py | 244 ----- heat/array_api/_typing.py | 35 - heat/array_api/_utility_functions.py | 63 -- heat/array_api/linalg.py | 100 -- heat/array_api/test/skips.txt | 89 -- heat/array_api/test/xfails.txt | 269 ------ 17 files changed, 4461 deletions(-) delete mode 100644 heat/array_api/__init__.py delete mode 100644 heat/array_api/_array_object.py delete mode 100644 heat/array_api/_creation_functions.py delete mode 100644 heat/array_api/_data_type_functions.py delete mode 100644 heat/array_api/_dtypes.py delete mode 100644 heat/array_api/_elementwise_functions.py delete mode 100644 heat/array_api/_inspection.py delete mode 100644 heat/array_api/_manipulation_functions.py delete mode 100644 heat/array_api/_searching_functions.py delete mode 100644 heat/array_api/_set_functions.py delete mode 100644 heat/array_api/_sorting_functions.py delete mode 100644 heat/array_api/_statistical_functions.py delete mode 100644 heat/array_api/_typing.py delete mode 100644 heat/array_api/_utility_functions.py delete mode 100644 heat/array_api/linalg.py delete mode 100644 heat/array_api/test/skips.txt delete mode 100644 heat/array_api/test/xfails.txt diff --git a/heat/array_api/__init__.py b/heat/array_api/__init__.py deleted file mode 100644 index 8fcca5d4c2..0000000000 --- a/heat/array_api/__init__.py +++ /dev/null @@ -1,276 +0,0 @@ -""" -A Heat sub-namespace that conforms to the Python array API standard. -""" - -import warnings - -warnings.warn("The heat.array_api submodule is not fully implemented.", stacklevel=2) - -__array_api_version__ = "2025.12" - -__all__ = ["__array_api_version__"] - -from ._inspection import __array_namespace_info__ -from .core.constants import e, inf, nan, newaxis, pi - -__all__ += ["e", "inf", "nan", "newaxis", "pi"] - -from ._creation_functions import ( - arange, - asarray, - empty, - empty_like, - eye, - from_dlpack, - full, - full_like, - linspace, - meshgrid, - ones, - ones_like, - tril, - triu, - zeros, - zeros_like, -) - -__all__ += [ - "arange", - "asarray", - "empty", - "empty_like", - "eye", - "from_dlpack", - "full", - "full_like", - "linspace", - "meshgrid", - "ones", - "ones_like", - "tril", - "triu", - "zeros", - "zeros_like", -] - -from ._data_type_functions import ( - astype, - broadcast_arrays, - broadcast_to, - can_cast, - finfo, - iinfo, - result_type, -) - -__all__ += [ - "astype", - "broadcast_arrays", - "broadcast_to", - "can_cast", - "finfo", - "iinfo", - "result_type", -] - -from heat.core.devices import cpu - -__all__ += ["cpu"] - -import heat.core.devices - -if hasattr(heat.core.devices, "gpu"): - from heat.core.devices import gpu - - __all__ += ["gpu"] - -from ._dtypes import ( - bool, - int8, - int16, - int32, - int64, - uint8, - # uint16, - # uint32, - # uint64, - float32, - float64, - complex64, - complex128, -) - -__all__ += [ - "bool", - "int8", - "int16", - "int32", - "int64", - "uint8", - # "uint16", - # "uint32", - # "uint64", - "float32", - "float64", - "complex64", - "complex128", -] - -from ._elementwise_functions import ( - abs, - acos, - acosh, - add, - asin, - asinh, - atan, - atan2, - atanh, - bitwise_and, - bitwise_left_shift, - bitwise_invert, - bitwise_or, - bitwise_right_shift, - bitwise_xor, - ceil, - cos, - cosh, - divide, - equal, - exp, - expm1, - floor, - floor_divide, - greater, - greater_equal, - isfinite, - isinf, - isnan, - less, - less_equal, - log, - log1p, - log2, - log10, - logaddexp, - logical_and, - logical_not, - logical_or, - logical_xor, - multiply, - negative, - not_equal, - positive, - pow, - remainder, - round, - sign, - sin, - sinh, - square, - sqrt, - subtract, - tan, - tanh, - trunc, -) - -__all__ += [ - "abs", - "acos", - "acosh", - "add", - "asin", - "asinh", - "atan", - "atan2", - "atanh", - "bitwise_and", - "bitwise_left_shift", - "bitwise_invert", - "bitwise_or", - "bitwise_right_shift", - "bitwise_xor", - "ceil", - "cos", - "cosh", - "divide", - "equal", - "exp", - "expm1", - "floor", - "floor_divide", - "greater", - "greater_equal", - "isfinite", - "isinf", - "isnan", - "less", - "less_equal", - "log", - "log1p", - "log2", - "log10", - "logaddexp", - "logical_and", - "logical_not", - "logical_or", - "logical_xor", - "multiply", - "negative", - "not_equal", - "positive", - "pow", - "remainder", - "round", - "sign", - "sin", - "sinh", - "square", - "sqrt", - "subtract", - "tan", - "tanh", - "trunc", -] - -from . import linalg - -__all__ += ["linalg"] - -from .linalg import matmul, matrix_transpose, tensordot, vecdot - -__all__ += ["matmul", "matrix_transpose", "tensordot", "vecdot"] - -from ._manipulation_functions import ( - concat, - expand_dims, - flip, - permute_dims, - reshape, - roll, - squeeze, - stack, -) - -__all__ += ["concat", "expand_dims", "flip", "permute_dims", "reshape", "roll", "squeeze", "stack"] - -from ._searching_functions import argmax, argmin, nonzero, where - -__all__ += ["argmax", "argmin", "nonzero", "where"] - -from ._set_functions import unique_inverse, unique_values - -__all__ += ["unique_inverse", "unique_values"] - -from ._sorting_functions import sort - -__all__ += ["sort"] - -from ._statistical_functions import max, mean, min, prod, std, sum, var - -__all__ += ["max", "mean", "min", "prod", "std", "sum", "var"] - -from ._utility_functions import all, any - -__all__ += ["all", "any"] diff --git a/heat/array_api/_array_object.py b/heat/array_api/_array_object.py deleted file mode 100644 index 43bcff40f8..0000000000 --- a/heat/array_api/_array_object.py +++ /dev/null @@ -1,942 +0,0 @@ -from __future__ import annotations - -import operator -import enum -from typing import TYPE_CHECKING, Any, Optional, Tuple, Union - -from ._dtypes import ( - _boolean_dtypes, - _integer_dtypes, - _integer_or_boolean_dtypes, - _floating_dtypes, - _numeric_dtypes, - _result_type, - _dtype_categories, -) - -if TYPE_CHECKING: - from ._typing import cpu, Device, Dtype, PyCapsule - - try: - from ._typing import gpu - except ImportError: - pass - from builtins import ellipsis - -import heat as ht -from heat import array_api - - -class Array: - """ - DNDarray object for the array API namespace. - This is a wrapper around ``heat.DNDarray`` that restricts the usage to only - those things that are required by the array API namespace. Note, - attributes on this object that start with a single underscore are not part - of the API specification and should only be used internally. This object - should not be constructed directly. Rather, use one of the creation - functions, such as ``asarray``. - """ - - _array: ht.DNDarray - - @classmethod - def _new(cls, x, /): - """ - Initializes the array API Array - object. - Functions outside of the array_api submodule should not use this - method. Use one of the creation functions instead, such as - ``asarray``. - - Parameters - ---------- - x : DNDarray - Underlying ``DNDarray`` - """ - obj = super().__new__(cls) - obj._array = x - return obj - - def __new__(cls, *args, **kwargs): - """ - Prevent ``Array()`` from working. - """ - raise TypeError( - "The array_api Array object should not be instantiated directly. Use an array creation function, such as asarray(), instead." - ) - - def __str__(self: Array, /) -> str: - """ - Computes a printable representation of the Array. - """ - return self._array.__str__().replace("DNDarray", "Array") - - def __repr__(self: Array, /) -> str: - """ - Computes a printable representation of the Array. - """ - return self._array.__str__().replace("DNDarray", "Array") - - def __len__(self) -> int: - """ - The length of the Array. - """ - return self._array.__len__() - - def _check_allowed_dtypes( - self, other: Union[bool, int, float, Array], dtype_category: str, op: str - ) -> Array: - """ - Helper function for operators to only allow specific input dtypes - Use like - other = self._check_allowed_dtypes(other, 'numeric', '__add__') - if other is NotImplemented: - return other - """ - if self.dtype not in _dtype_categories[dtype_category]: - raise TypeError(f"Only {dtype_category} dtypes are allowed in {op}") - if isinstance(other, (int, float, bool)): - other = self._promote_scalar(other) - elif isinstance(other, Array): - if other.dtype not in _dtype_categories[dtype_category]: - raise TypeError(f"Only {dtype_category} dtypes are allowed in {op}") - else: - return NotImplemented - _result_type(self.dtype, other.dtype) - return other - - def _promote_scalar(self, scalar): - """ - Returns a promoted version of a Python scalar appropriate for use with - operations on self. - This may raise a ``TypeError`` when the scalar type is incompatible with - the dtype of self. - """ - # Note: Only Python scalar types that match the array dtype are - # allowed. - if isinstance(scalar, bool): - if self.dtype not in _boolean_dtypes: - raise TypeError("Python bool scalars can only be promoted with bool arrays") - elif isinstance(scalar, int): - if self.dtype in _boolean_dtypes: - raise TypeError("Python int scalars cannot be promoted with bool arrays") - elif isinstance(scalar, float): - if self.dtype not in _floating_dtypes: - raise TypeError( - "Python float scalars can only be promoted with floating-point arrays." - ) - else: - raise TypeError(f"{scalar} must be a Python scalar") - - return Array._new(ht.array(scalar, self.dtype)) - - @staticmethod - def _normalize_two_args(x1, x2) -> Tuple[Array, Array]: - """ - Normalize inputs to two arg functions to fix type promotion rules - Heat deviates from the spec type promotion rules in cases where one - argument is 0-dimensional and the other is not. For example: - >>> import heat as ht - >>> a = ht.array([1.0], dtype=ht.float32) - >>> b = ht.array(1.0, dtype=ht.float64) - >>> ht.add(a, b) # The spec says this should be float64 - DNDarray([2.], dtype=ht.float32, device=cpu:0, split=None) - To fix this, we add a dimension to the 0-dimension array before passing it - through. This works because a dimension would be added anyway from - broadcasting, so the resulting shape is the same, but this prevents Heat - from not promoting the dtype. - """ - if x1.ndim == 0 and x2.ndim != 0: - x1 = Array._new(x1._array[None]) - elif x2.ndim == 0 and x1.ndim != 0: - x2 = Array._new(x2._array[None]) - return (x1, x2) - - def _validate_index(self, key): - """ - Validate an index according to the array API. - The array API specification only requires a subset of indices that are - supported by Heat. This function will reject any index that is - allowed by Heat but not required by the array API specification. - This function raises IndexError if the index ``key`` is invalid. - """ - _key = key if isinstance(key, tuple) else (key,) - for i in _key: - if isinstance(i, bool) or not ( - isinstance(i, int) # i.e. ints - or isinstance(i, slice) - or i == Ellipsis - or i is None - or isinstance(i, Array) - or isinstance(i, ht.DNDarray) - ): - raise IndexError( - f"Single-axes index {i} has {type(i)=}, but only " - "integers, slices (:), ellipsis (...), newaxis (None), " - "zero-dimensional integer arrays and boolean arrays " - "are specified in the Array API." - ) - - nonexpanding_key = [] - single_axes = [] - n_ellipsis = 0 - key_has_mask = False - for i in _key: - if i is not None: - nonexpanding_key.append(i) - if isinstance(i, Array) or isinstance(i, ht.DNDarray): - if i.dtype in _boolean_dtypes: - key_has_mask = True - single_axes.append(i) - else: - # i must not be an array here, to avoid elementwise equals - if i == Ellipsis: - n_ellipsis += 1 - else: - single_axes.append(i) - - n_single_axes = len(single_axes) - if n_ellipsis > 1: - return # handled by DNDarray - elif n_ellipsis == 0: - # Note boolean masks must be the sole index, which we check for - # later on. - if not key_has_mask and n_single_axes < self.ndim: - raise IndexError( - f"{self.ndim=}, but the multi-axes index only specifies " - f"{n_single_axes} dimensions. If this was intentional, " - "add a trailing ellipsis (...) which expands into as many " - "slices (:) as necessary." - ) - - if n_ellipsis == 0: - indexed_shape = self.shape - else: - ellipsis_start = None - for pos, i in enumerate(nonexpanding_key): - if not (isinstance(i, Array) or isinstance(i, ht.DNDarray)): - if i == Ellipsis: - ellipsis_start = pos - break - assert ellipsis_start is not None # sanity check - ellipsis_end = self.ndim - (n_single_axes - ellipsis_start) - indexed_shape = self.shape[:ellipsis_start] + self.shape[ellipsis_end:] - for i, side in zip(single_axes, indexed_shape): - if isinstance(i, slice): - if side == 0: - f_range = "0 (or None)" - else: - f_range = f"between -{side} and {side - 1} (or None)" - if i.start is not None: - try: - start = operator.index(i.start) - except TypeError: - raise IndexError("Invalid start value in slice") - else: - if not (-side <= start <= side): - raise IndexError( - f"Slice {i} contains {start=}, but should be " - f"{f_range} for an axis of size {side} " - "(out-of-bounds starts are not specified in " - "the Array API)" - ) - if i.stop is not None: - try: - stop = operator.index(i.stop) - except TypeError: - raise IndexError("Invalid stop value in slice") - else: - if not (-side <= stop <= side): - raise IndexError( - f"Slice {i} contains {stop=}, but should be " - f"{f_range} for an axis of size {side} " - "(out-of-bounds stops are not specified in " - "the Array API)" - ) - elif isinstance(i, Array): - if i.dtype in _boolean_dtypes and len(_key) != 1: - assert isinstance(key, tuple) # sanity check - raise IndexError( - f"Single-axes index {i} is a boolean array and " - f"{len(key)=}, but masking is only specified in the " - "Array API when the array is the sole index." - ) - elif i.dtype in _integer_dtypes and i.ndim != 0: - raise IndexError( - f"Single-axes index {i} is a non-zero-dimensional " - "integer array, but advanced integer indexing is not " - "specified in the Array API." - ) - elif isinstance(i, tuple): - raise IndexError( - f"Single-axes index {i} is a tuple, but nested tuple " - "indices are not specified in the Array API." - ) - - def __abs__(self: Array, /) -> Array: - """ - Calculates the absolute value for each element of an array instance - (i.e., the element-wise result has the same magnitude as the respective - element but has positive sign). - """ - if self.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in __abs__") - res = self._array.abs(dtype=self.dtype) - return self.__class__._new(res) - - def __add__(self: Array, other: Union[int, float, Array], /) -> Array: - """ - Calculates the sum for each element of an array instance with the - respective element of the array ``other``. - - Parameters - ---------- - other : Union[int, float, Array] - Addend array. Must have a numeric data type. - """ - other = self._check_allowed_dtypes(other, "numeric", "__add__") - if other is NotImplemented: - return other - self, other = self._normalize_two_args(self, other) - res = self._array.__add__(other._array) - return self.__class__._new(res) - - def __and__(self: Array, other: Union[int, bool, Array], /) -> Array: - """ - Evaluates ``self_i & other_i`` for each element of an array instance - with the respective element of the array ``other``. - - Parameters - ---------- - other : Union[int, bool, Array] - Other array. Must have an integer or boolean data type. - """ - other = self._check_allowed_dtypes(other, "integer or boolean", "__and__") - if other is NotImplemented: - return other - self, other = self._normalize_two_args(self, other) - res = self._array.__and__(other._array) - return self.__class__._new(res) - - # TODO: Ready to Remove - def __array_namespace__(self: Array, /, *, api_version: Optional[str] = None) -> Any: - """ - Returns an object that has all the array API functions on it. - - Parameters - ---------- - api_version : Optional[str] - string representing the version of the array API specification to - be returned, in ``'YYYY.MM'`` form. If it is ``None`` (default), it - returns the namespace corresponding to latest version of the - array API specification. - """ - if api_version is not None and api_version != "2021.12": - raise ValueError(f"Unrecognized array API version: {api_version}") - return array_api - - # TODO: Ready to remove - def __bool__(self: Array, /) -> bool: - """ - Converts a zero-dimensional boolean array to a Python ``bool`` object. - """ - if self._array.ndim != 0: - raise TypeError("bool is only allowed on arrays with 0 dimensions") - if self.dtype not in _boolean_dtypes: - raise ValueError("bool is only allowed on boolean arrays") - res = self._array.__bool__() - return res - - def __dlpack__(self: Array, /, *, stream: Optional[Union[int, Any]] = None) -> PyCapsule: - """ - Exports the array for consumption by ``from_dlpack()`` as a DLPack capsule. - - Parameters - ---------- - stream : Optional[Union[int, Any]] - For CUDA and ROCm, a Python integer representing a pointer to a stream, - on devices that support streams. - """ - return self._array.__array.__dlpack__(stream=stream) - - def __dlpack_device__(self: Array, /) -> Tuple[enum.Enum, int]: - """ - Returns device type and device ID in DLPack format. Meant for use - within ``from_dlpack()``. - """ - return self._array.__array.__dlpack_device__() - - def __eq__(self: Array, other: Union[int, float, bool, Array], /) -> Array: - """ - Computes the truth value of ``self_i == other_i`` for each element of an - array instance with the respective element of the array ``other``. - - Parameters - ---------- - other : Union[int, float, bool, Array] - Other array. - """ - # Even though "all" dtypes are allowed, we still require them to be - # promotable with each other. - other = self._check_allowed_dtypes(other, "all", "__eq__") - if other is NotImplemented: - return other - self, other = self._normalize_two_args(self, other) - res = self._array.__eq__(other._array) - return self.__class__._new(res) - - # TODO: Ready to remove - def __float__(self: Array, /) -> float: - """ - Converts a zero-dimensional floating-point array to a Python ``float`` object. - """ - if self._array.ndim != 0: - raise TypeError("float is only allowed on arrays with 0 dimensions") - if self.dtype not in _floating_dtypes: - raise ValueError("float is only allowed on floating-point arrays") - res = self._array.__float__() - return res - - def __floordiv__(self: Array, other: Union[int, float, Array], /) -> Array: - """ - Evaluates ``self_i // other_i`` for each element of an array instance - with the respective element of the array ``other``. - - Parameters - ---------- - other : Union[int, float, Array] - Other array. Must have a numeric data type. - """ - other = self._check_allowed_dtypes(other, "numeric", "__floordiv__") - if other is NotImplemented: - return other - self, other = self._normalize_two_args(self, other) - res = self._array.__floordiv__(other._array) - return self.__class__._new(res) - - def __ge__(self: Array, other: Union[int, float, Array], /) -> Array: - """ - Computes the truth value of ``self_i >= other_i`` for each element of - an array instance with the respective element of the array ``other``. - - Parameters - ---------- - other : Union[int, float, Array] - Other array. Must have a numeric data type. - """ - other = self._check_allowed_dtypes(other, "numeric", "__ge__") - if other is NotImplemented: - return other - self, other = self._normalize_two_args(self, other) - res = self._array.__ge__(other._array) - return self.__class__._new(res) - - def __getitem__( - self: Array, - key: Union[int, slice, ellipsis, Tuple[Union[int, slice, ellipsis], ...], Array], - /, - ) -> Array: - """ - Returns ``self[key]``. - - Parameters - ---------- - key : Union[int, slice, ellipsis, Tuple[Union[int, slice, ellipsis], ...], Array] - Index key - """ - # Note: Only indices required by the spec are allowed. - self._validate_index(key) - if isinstance(key, Array): - key = key._array - res = self._array.__getitem__(key) - return self._new(res) - - def __gt__(self: Array, other: Union[int, float, Array], /) -> Array: - """ - Computes the truth value of ``self_i > other_i`` for each element - of an array instance with the respective element of the array ``other``. - - Parameters - ---------- - other : Union[int, float, Array] - Other array. Must have a numeric data type. - """ - other = self._check_allowed_dtypes(other, "numeric", "__gt__") - if other is NotImplemented: - return other - self, other = self._normalize_two_args(self, other) - res = self._array.__gt__(other._array) - return self.__class__._new(res) - - # TODO: Ready to remove - def __index__(self: Array, /) -> int: - """ - Converts a zero-dimensional integer array to a Python ``int`` object. - """ - return self.__int__() - - # TODO: Ready to remove - def __int__(self: Array, /) -> int: - """ - Converts a zero-dimensional integer array to a Python ``int`` object. - """ - if self._array.ndim != 0: - raise TypeError("int is only allowed on arrays with 0 dimensions") - if self.dtype not in _integer_dtypes: - raise ValueError("int is only allowed on integer arrays") - res = self._array.__int__() - return res - - def __invert__(self: Array, /) -> Array: - """ - Evaluates ``~self_i`` for each element of an array instance. - """ - if self.dtype not in _integer_or_boolean_dtypes: - raise TypeError("Only integer or boolean dtypes are allowed in __invert__") - res = self._array.__invert__() - return self.__class__._new(res) - - def __le__(self: Array, other: Union[int, float, Array], /) -> Array: - """ - Computes the truth value of ``self_i <= other_i`` for each element of an - array instance with the respective element of the array ``other``. - - Parameters - ---------- - other : Union[int, float, Array] - Other array. Must have a numeric data type. - """ - other = self._check_allowed_dtypes(other, "numeric", "__le__") - if other is NotImplemented: - return other - self, other = self._normalize_two_args(self, other) - res = self._array.__le__(other._array) - return self.__class__._new(res) - - def __lshift__(self: Array, other: Union[int, Array], /) -> Array: - """ - Evaluates ``self_i << other_i`` for each element of an array instance - with the respective element of the array ``other``. - - Parameters - ---------- - other : Union[int, Array] - Other array. Must have an integer data type. Each element - must be greater than or equal to ``0``. - """ - other = self._check_allowed_dtypes(other, "integer", "__lshift__") - if other is NotImplemented: - return other - self, other = self._normalize_two_args(self, other) - res = self._array.__lshift__(other._array) - return self.__class__._new(res) - - def __lt__(self: Array, other: Union[int, float, Array], /) -> Array: - """ - Computes the truth value of ``self_i < other_i`` for each element - of an array instance with the respective element of the array ``other``. - - Parameters - ---------- - other : Union[int, Array] - Other array. Must have a numeric data type. - """ - other = self._check_allowed_dtypes(other, "numeric", "__lt__") - if other is NotImplemented: - return other - self, other = self._normalize_two_args(self, other) - res = self._array.__lt__(other._array) - return self.__class__._new(res) - - def __matmul__(self: Array, other: Array, /) -> Array: - """ - Computes the matrix product. - - Parameters - ---------- - other : Array - Other array. Must have a numeric data type and at least one dimension. - """ - other = self._check_allowed_dtypes(other, "numeric", "__matmul__") - if other is NotImplemented: - return other - res = self._array.__matmul__(other._array) - return self.__class__._new(res) - - def __mod__(self: Array, other: Union[int, float, Array], /) -> Array: - """ - Evaluates ``self_i % other_i`` for each element of an array instance - with the respective element of the array ``other``. - - Parameters - ---------- - other : Union[int, float, Array] - Other array. Must have a numeric data type. - """ - other = self._check_allowed_dtypes(other, "numeric", "__mod__") - if other is NotImplemented: - return other - self, other = self._normalize_two_args(self, other) - res = self._array.__mod__(other._array) - return self.__class__._new(res) - - def __mul__(self: Array, other: Union[int, float, Array], /) -> Array: - """ - Calculates the product for each element of an array instance with - the respective element of the array ``other``. - - Parameters - ---------- - other : Union[int, float, Array] - Other array. Must have a numeric data type. - """ - other = self._check_allowed_dtypes(other, "numeric", "__mul__") - if other is NotImplemented: - return other - self, other = self._normalize_two_args(self, other) - res = self._array.__mul__(other._array) - return self.__class__._new(res) - - def __ne__(self: Array, other: Union[int, float, bool, Array], /) -> Array: - """ - Computes the truth value of ``self_i != other_i`` for each element of - an array instance with the respective element of the array ``other``. - - Parameters - ---------- - other : Union[int, float, bool, Array] - Other array. - """ - other = self._check_allowed_dtypes(other, "all", "__ne__") - if other is NotImplemented: - return other - self, other = self._normalize_two_args(self, other) - res = self._array.__ne__(other._array) - return self.__class__._new(res) - - def __neg__(self: Array, /) -> Array: - """ - Evaluates ``-self_i`` for each element of an array instance. - """ - if self.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in __neg__") - res = self._array.__neg__() - return self.__class__._new(res) - - def __or__(self: Array, other: Union[int, bool, Array], /) -> Array: - """ - Evaluates ``self_i | other_i`` for each element of an array instance - with the respective element of the array ``other``. - - Parameters - ---------- - other : Union[int, bool, Array] - Other array. Must have an integer or boolean data type. - """ - other = self._check_allowed_dtypes(other, "integer or boolean", "__or__") - if other is NotImplemented: - return other - self, other = self._normalize_two_args(self, other) - res = self._array.__or__(other._array) - return self.__class__._new(res) - - def __pos__(self: Array, /) -> Array: - """ - Evaluates ``+self_i`` for each element of an array instance. - """ - if self.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in __pos__") - res = self._array.__pos__() - return self.__class__._new(res) - - def __pow__(self: Array, other: Union[int, float, Array], /) -> Array: - """ - Calculates an approximation of exponentiation by raising each element - (the base) of an array instance to the power of ``other_i`` (the exponent), - where ``other_i`` is the corresponding element of the array ``other``. - - Parameters - ---------- - other : Union[int, float, Array] - Other array. Must have a numeric data type. - """ - other = self._check_allowed_dtypes(other, "numeric", "__pow__") - if other is NotImplemented: - return other - self, other = self._normalize_two_args(self, other) - res = self._array.__pow__(other._array) - return self.__class__._new(res) - - def __rshift__(self: Array, other: Union[int, Array], /) -> Array: - """ - Evaluates ``self_i >> other_i`` for each element of an array instance - with the respective element of the array ``other``. - - Parameters - ---------- - other : Union[int, Array] - Other array. Must have an integer data type. Each element must be - greater than or equal to ``0``. - """ - other = self._check_allowed_dtypes(other, "integer", "__rshift__") - if other is NotImplemented: - return other - self, other = self._normalize_two_args(self, other) - res = self._array.__rshift__(other._array) - return self.__class__._new(res) - - def __setitem__( - self, - key: Union[int, slice, ellipsis, Tuple[Union[int, slice, ellipsis], ...], Array], - value: Union[int, float, bool, Array], - /, - ) -> None: - """ - Sets ``self[key]`` to ``value``. - """ - # Note: Only indices required by the spec are allowed. - self._validate_index(key) - if isinstance(key, Array): - key = key._array - if isinstance(value, Array): - value = value._array - self._array.__setitem__(key, value) - - def __sub__(self: Array, other: Union[int, float, Array], /) -> Array: - """ - Calculates the difference for each element of an array instance - with the respective element of the array ``other``. - - Parameters - ---------- - other : Union[int, float, Array] - Subtrahend array. Must have a numeric data type. - """ - other = self._check_allowed_dtypes(other, "numeric", "__sub__") - if other is NotImplemented: - return other - self, other = self._normalize_two_args(self, other) - res = self._array.__sub__(other._array) - return self.__class__._new(res) - - def __truediv__(self: Array, other: Union[int, float, Array], /) -> Array: - """ - Evaluates ``self_i / other_i`` for each element of an array instance - with the respective element of the array ``other``. - - Parameters - ---------- - other : Union[int, float, Array] - Subtrahend array. Must have a numeric data type. - """ - other = self._check_allowed_dtypes(other, "numeric", "__truediv__") - if other is NotImplemented: - return other - self, other = self._normalize_two_args(self, other) - res = self._array.__truediv__(other._array) - return self.__class__._new(res) - - def __xor__(self: Array, other: Union[int, bool, Array], /) -> Array: - """ - Evaluates ``self_i ^ other_i`` for each element of an array instance - with the respective element of the array ``other``. - - Parameters - ---------- - other : Union[int, bool, Array] - Subtrahend array. Must have an integer or boolean data type. - """ - other = self._check_allowed_dtypes(other, "integer or boolean", "__xor__") - if other is NotImplemented: - return other - self, other = self._normalize_two_args(self, other) - res = self._array.__xor__(other._array) - return self.__class__._new(res) - - def __radd__(self: Array, other: Union[int, float, Array], /) -> Array: - """ - Reflected version of ``__add__``. - - Parameters - ---------- - other : Union[int, float, Array] - Addend array. Must have a numeric data type. - """ - other = self._check_allowed_dtypes(other, "numeric", "__radd__") - if other is NotImplemented: - return other - self, other = self._normalize_two_args(self, other) - res = self._array.__radd__(other._array) - return self.__class__._new(res) - - def __rfloordiv__(self: Array, other: Union[int, float, Array], /) -> Array: - """ - Reflected version of ``__floordiv__``. - - Parameters - ---------- - other : Union[int, float, Array] - Other array. Must have a numeric data type. - """ - other = self._check_allowed_dtypes(other, "numeric", "__rfloordiv__") - if other is NotImplemented: - return other - self, other = self._normalize_two_args(self, other) - res = self._array.__rfloordiv__(other._array) - return self.__class__._new(res) - - def __rmod__(self: Array, other: Union[int, float, Array], /) -> Array: - """ - Reflected version of ``__rmod__``. - """ - other = self._check_allowed_dtypes(other, "numeric", "__rmod__") - if other is NotImplemented: - return other - self, other = self._normalize_two_args(self, other) - res = self._array.__rmod__(other._array) - return self.__class__._new(res) - - def __rmul__(self: Array, other: Union[int, float, Array], /) -> Array: - """ - Reflected version of ``__mul__``. - - Parameters - ---------- - other : Union[int, float, Array] - Other array. Must have a numeric data type. - """ - other = self._check_allowed_dtypes(other, "numeric", "__rmul__") - if other is NotImplemented: - return other - self, other = self._normalize_two_args(self, other) - res = self._array.__rmul__(other._array) - return self.__class__._new(res) - - def __rpow__(self: Array, other: Union[int, float, Array], /) -> Array: - """ - Reflected version of ``__rpow__``. - - Parameters - ---------- - other : Union[int, float, Array] - Other array. Must have a numeric data type. - """ - other = self._check_allowed_dtypes(other, "numeric", "__rpow__") - if other is NotImplemented: - return other - self, other = self._normalize_two_args(self, other) - res = self._array.__rpow__(other._array) - return self.__class__._new(res) - - def __rsub__(self: Array, other: Union[int, float, Array], /) -> Array: - """ - Reflected version of ``__sub__``. - - Parameters - ---------- - other : Union[int, float, Array] - Subtrahend array. Must have a numeric data type. - """ - other = self._check_allowed_dtypes(other, "numeric", "__rsub__") - if other is NotImplemented: - return other - self, other = self._normalize_two_args(self, other) - res = self._array.__rsub__(other._array) - return self.__class__._new(res) - - def __rtruediv__(self: Array, other: Union[float, Array], /) -> Array: - """ - Reflected version of ``__truediv__``. - - Parameters - ---------- - other : Union[int, float, Array] - Subtrahend array. Must have a numeric data type. - """ - other = self._check_allowed_dtypes(other, "floating-point", "__rtruediv__") - if other is NotImplemented: - return other - self, other = self._normalize_two_args(self, other) - res = self._array.__rtruediv__(other._array) - return self.__class__._new(res) - - # TODO: Ready to Remove - def to_device( - self: Array, device: Device, /, stream: Optional[Union[int, Any]] = None - ) -> Array: - """ - Copy the array from the device on which it currently resides to the specified ``device``. - - Parameters - ---------- - device : Device - A ``Device`` object. - stream : Optional[Union[int, Any]] - Stream object to use during copy. - """ - if stream is not None: - raise ValueError("The stream argument to to_device() is not supported") - if device == cpu: - return self._array.cpu() - elif device == gpu: - return self._array.gpu() - raise ValueError(f"Unsupported device {device!r}") - - @property - def dtype(self) -> Dtype: - """ - Data type of the array elements. - """ - return self._array.dtype - - @property - def device(self) -> Device: - """ - Hardware device the array data resides on. - """ - return self._array.device - - @property - def mT(self) -> Array: - """ - Transpose of a matrix (or a stack of matrices). - """ - from .linalg import matrix_transpose - - if self.ndim < 2: - raise ValueError("x.mT requires x to have at least 2 dimensions.") - return matrix_transpose(self) - - @property - def ndim(self) -> int: - """ - Number of array dimensions (axes). - """ - return self._array.ndim - - @property - def shape(self) -> Tuple[Optional[int], ...]: - """ - Array dimensions. - """ - return self._array.shape - - @property - def size(self) -> Optional[int]: - """ - Number of elements in an array. - """ - return self._array.size - - @property - def T(self) -> Array: - """ - Transpose of the array. - """ - # Note: T only works on 2-dimensional arrays, as outlined in the specification: - if self.ndim != 2: - raise ValueError( - "x.T requires x to have 2 dimensions. Use x.mT to transpose stacks of matrices and permute_dims() to permute dimensions." - ) - return self.__class__._new(self._array.T) diff --git a/heat/array_api/_creation_functions.py b/heat/array_api/_creation_functions.py deleted file mode 100644 index 071e6a7c1b..0000000000 --- a/heat/array_api/_creation_functions.py +++ /dev/null @@ -1,477 +0,0 @@ -from __future__ import annotations - -from typing import TYPE_CHECKING, List, Optional, Tuple, Union - -if TYPE_CHECKING: - from ._typing import Array, Device, Dtype, NestedSequence, SupportsBufferProtocol -from ._dtypes import _all_dtypes, _floating_dtypes, default_float, default_int, bool as api_bool - -import heat as ht -import torch - - -def arange( - start: Union[int, float], - /, - stop: Optional[Union[int, float]] = None, - step: Union[int, float] = 1, - *, - dtype: Optional[Dtype] = None, - device: Optional[Device] = None, -) -> Array: - """ - Returns evenly spaced values within the half-open interval ``[start, stop)`` - as a one-dimensional array. - - Parameters - ---------- - start : Union[int, float] - If ``stop`` is specified, the start of interval (inclusive); otherwise, - the end of the interval (exclusive). If ``stop`` is not specified, - the default starting value is ``0``. - stop : Optional[Union[int, float]] - The end of the interval. Default: ``None``. - step : Union[int, float] - the distance between two adjacent elements (``out[i+1] - out[i]``). Must - not be ``0``; may be negative, this results in an empty array if - ``stop >= start``. Default: ``1``. - dtype : Optional[Dtype] - Output array data type. If ``dtype`` is ``None``, the output array data - type is inferred from ``start``, ``stop`` and ``step``. Default: ``None`` - device : Optional[Device] - Device on which to place the created array. Default: ``None``. - """ - from ._array_object import Array - - if dtype is None: - if isinstance(start, float) or isinstance(stop, float) or isinstance(step, float): - dtype = default_float - else: - dtype = default_int - if stop is not None and (stop - start > 0) != (step > 0): - return empty(0, dtype=dtype, device=device) - if stop is None: - return Array._new(ht.arange(0, start, step, dtype=dtype, device=device)) - else: - return Array._new(ht.arange(start, stop, step, dtype=dtype, device=device)) - - -def asarray( - obj: Union[ - Array, - bool, - int, - float, - NestedSequence[bool | int | float], - SupportsBufferProtocol, - ], - /, - *, - dtype: Optional[Dtype] = None, - device: Optional[Device] = None, - copy: Optional[bool] = None, -) -> Array: - """ - Convert the input to an array. - - Parameters - ---------- - obj : Union[Array, bool, int, float, NestedSequence[bool | int | float], SupportsBufferProtocol] - Object to be converted to an array. May be a Python scalar, - a (possibly nested) sequence of Python scalars, or an object - supporting the Python buffer protocol. Default: ``None``. - dtype : Optional[Dtype] - Output array data type. If ``dtype`` is ``None``, the output array data - type is inferred from the data type(s) in ``obj``. - device : Optional[Device] - Device on which to place the created array. If ``device`` is ``None`` and - ``x`` is an array, the output array device is inferred from ``x``. - Default: ``None``. - copy : Optional[bool] - Boolean indicating whether or not to copy the input. - """ - # _array_object imports in this file are inside the functions to avoid - # circular imports - from ._array_object import Array - - if isinstance(obj, Array): - if dtype is not None and obj.dtype != dtype: - copy = True - if not copy: - return obj - obj = obj._array - if dtype is None: - if isinstance(obj, int) and (obj > 2**64 or obj < -(2**63)): - raise OverflowError("Integer out of bounds for array dtypes") - elif isinstance(obj, float): - dtype = default_float - res = ht.asarray(obj, dtype=dtype, device=device) - return Array._new(res) - - -def empty( - shape: Union[int, Tuple[int, ...]], - *, - dtype: Optional[Dtype] = None, - device: Optional[Device] = None, -) -> Array: - """ - Returns an uninitialized array having a specified shape. - - Parameters - ---------- - shape : Union[int, Tuple[int, ...]] - Output array shape. - dtype : Optional[Dtype] - Output array data type. Default: ``None``. - device : Optional[Device] - Device on which to place the created array. Default: ``None``. - """ - from ._array_object import Array - - if dtype is None: - dtype = default_float - return Array._new(ht.empty(shape, dtype=dtype, device=device)) - - -def empty_like( - x: Array, /, *, dtype: Optional[Dtype] = None, device: Optional[Device] = None -) -> Array: - """ - Returns an uninitialized array with the same ``shape`` as an input array ``x``. - - Parameters - ---------- - x : Array - Input array from which to derive the output array shape. - dtype : Optional[Dtype] - Output array data type. If ``dtype`` is ``None``, the output array data - type is inferred from x. Default: ``None``. - device : Optional[Device] - Device on which to place the created array. Default: ``None``. - """ - from ._array_object import Array - - return Array._new(ht.empty_like(x._array, dtype=dtype, device=device)) - - -def eye( - n_rows: int, - n_cols: Optional[int] = None, - /, - *, - k: int = 0, - dtype: Optional[Dtype] = None, - device: Optional[Device] = None, -) -> Array: - """ - Returns a two-dimensional array with ones on the ``k`` h diagonal and zeros elsewhere. - - Parameters - ---------- - n_rows : int - Number of rows in the output array. - n_cols : Optional[int] - Number of columns in the output array. If ``None``, the default number of - columns in the output array is equal to ``n_rows``. Default: ``None``. - k : int - Index of the diagonal. A positive value refers to an upper diagonal, a negative - value to a lower diagonal, and ``0`` to the main diagonal. Default: ``0``. - dtype : Optional[Dtype] - Output array data type. Default: ``None``. - device : Optional[Device] - Device on which to place the created array. Default: ``None``. - """ - from ._array_object import Array - - if k != 0: - raise ValueError("k option not implemented yet") - - if dtype is None: - dtype = default_float - if n_cols is None: - n_cols = n_rows - return Array._new(ht.eye((n_rows, n_cols), dtype=dtype, device=device)) - - -def from_dlpack(x: object, /) -> Array: - """ - Returns a new array containing the data from another (array) object with a - ``__dlpack__`` method. - - Parameters - ---------- - x : object - Input (array) object. - """ - from ._array_object import Array - - return Array._new(torch.from_dlpack(x)) - - -def full( - shape: Union[int, Tuple[int, ...]], - fill_value: Union[int, float], - *, - dtype: Optional[Dtype] = None, - device: Optional[Device] = None, -) -> Array: - """ - Returns a new array having a specified ``shape`` and filled with ``fill_value``. - - Parameters - ---------- - shape : Union[int, Tuple[int, ...]] - Output array shape. - fill_value : Union[int, float] - Fill value. - dtype : Optional[Dtype] - Output array data type. If ``dtype`` is ``None``, the output array data - type is inferred from ``fill_value``. Default: ``None``. - device : Optional[Device] - Device on which to place the created array. - """ - from ._array_object import Array - - if isinstance(fill_value, Array) and fill_value.ndim == 0: - fill_value = fill_value._array - if dtype is None: - if isinstance(fill_value, bool): - dtype = api_bool - elif isinstance(fill_value, int): - dtype = default_int - elif isinstance(fill_value, float): - dtype = default_float - res = ht.full(shape, fill_value, dtype=dtype, device=device) - return Array._new(res) - - -def full_like( - x: Array, - /, - fill_value: Union[int, float], - *, - dtype: Optional[Dtype] = None, - device: Optional[Device] = None, -) -> Array: - """ - Returns a new array filled with ``fill_value`` and having the same ``shape`` - as an input array ``x``. - - Parameters - ---------- - x : Array - Input array from which to derive the output array shape. - fill_value : Union[int, float] - Fill value. - dtype : Optional[Dtype] - Output array data type. If ``dtype`` is ``None``, the output array data - type is inferred from x. Default: ``None``. - device : Optional[Device] - Device on which to place the created array. Default: ``None``. - """ - from ._array_object import Array - - res = ht.full_like(x._array, fill_value, dtype=dtype, device=device) - if res.dtype not in _all_dtypes: - # This will happen if the fill value is not something that Heat - # coerces to one of the acceptable dtypes. - raise TypeError("Invalid input to full_like") - return Array._new(res) - - -def linspace( - start: Union[int, float], - stop: Union[int, float], - /, - num: int, - *, - dtype: Optional[Dtype] = None, - device: Optional[Device] = None, - endpoint: bool = True, -) -> Array: - """ - Returns evenly spaced numbers over a specified interval. - - Parameters - ---------- - start : Union[int, float] - The start of the interval. - stop : Union[int, float] - The end of the interval. - num : int - Number of samples. - dtype : Optional[Dtype] - Output array data type. Must be a floating-point data type. Default: ``None``. - device : Optional[Device] - Device on which to place the created array. Default: ``None``. - endpoint : bool - Boolean indicating whether to include ``stop`` in the interval. Default: ``True``. - """ - from ._array_object import Array - - if dtype is None: - dtype = default_float - elif dtype not in _floating_dtypes: - raise TypeError("Only floating dtypes allowed in linspace") - - return Array._new(ht.linspace(start, stop, num, dtype=dtype, device=device, endpoint=endpoint)) - - -def meshgrid(*arrays: Array, indexing: str = "xy") -> List[Array]: - """ - Returns coordinate matrices from coordinate vectors. - - Parameters - ---------- - arrays : Array - An arbitrary number of one-dimensional arrays representing grid coordinates. - Each array must have the same numeric data type. - indexing : str - Cartesian ``'xy'`` or matrix ``'ij'`` indexing of output. If provided zero or - one one-dimensional vector(s) (i.e., the zero- and one-dimensional cases, - respectively), the ``indexing`` keyword has no effect and is ignored. - Default: ``'xy'``. - """ - from ._array_object import Array - - if len({a.dtype for a in arrays}) > 1: - raise ValueError("meshgrid inputs must all have the same dtype") - - return [ - Array._new(array) for array in ht.meshgrid(*[a._array for a in arrays], indexing=indexing) - ] - - -def ones( - shape: Union[int, Tuple[int, ...]], - *, - dtype: Optional[Dtype] = None, - device: Optional[Device] = None, -) -> Array: - """ - Returns a new array having a specified ``shape`` and filled with ones. - - Parameters - ---------- - shape : Union[int, Tuple[int, ...]] - Output array shape. - dtype : Optional[Dtype] - Output array data type. Default: ``None``. - device : Optional[Device] - Device on which to place the created array. - """ - from ._array_object import Array - - if dtype is None: - dtype = default_float - return Array._new(ht.ones(shape, dtype=dtype, device=device)) - - -def ones_like( - x: Array, /, *, dtype: Optional[Dtype] = None, device: Optional[Device] = None -) -> Array: - """ - Returns a new array filled with ones and having the same shape as an input array ``x``. - - Parameters - ---------- - x : Array - Input array from which to derive the output array shape. - dtype : Optional[Dtype] - Output array data type. If ``dtype`` is ``None``, the output array data - type is inferred from x. Default: ``None``. - device : Optional[Device] - Device on which to place the created array. Default: ``None``. - """ - from ._array_object import Array - - return Array._new(ht.ones_like(x._array, dtype=dtype, device=device)) - - -def tril(x: Array, /, *, k: int = 0) -> Array: - """ - Returns the lower triangular part of a matrix (or a stack of matrices) ``x``. - - Parameters - ---------- - x : Array - Input array having shape ``(..., M, N)`` and whose innermost two dimensions - form ``MxN`` matrices. - k : int - Diagonal above which to zero elements. If ``k = 0``, the diagonal is the - main diagonal. If ``k < 0``, the diagonal is below the main diagonal. - If ``k > 0``, the diagonal is above the main diagonal. Default: ``0``. - """ - from ._array_object import Array - - if x.ndim < 2: - raise ValueError("x must be at least 2-dimensional for tril") - return Array._new(ht.tril(x._array, k=k)) - - -def triu(x: Array, /, *, k: int = 0) -> Array: - """ - Returns the upper triangular part of a matrix (or a stack of matrices) ``x``. - - Parameters - ---------- - x : Array - Input array having shape ``(..., M, N)`` and whose innermost two dimensions - form ``MxN`` matrices. - k : int - Diagonal below which to zero elements. If ``k = 0``, the diagonal is the - main diagonal. If ``k < 0``, the diagonal is below the main diagonal. - If ``k > 0``, the diagonal is above the main diagonal. Default: ``0``. - """ - from ._array_object import Array - - if x.ndim < 2: - raise ValueError("x must be at least 2-dimensional for triu") - return Array._new(ht.triu(x._array, k=k)) - - -def zeros( - shape: Union[int, Tuple[int, ...]], - *, - dtype: Optional[Dtype] = None, - device: Optional[Device] = None, -) -> Array: - """ - Returns a new array having a specified ``shape`` and filled with zeros. - - Parameters - ---------- - shape : Union[int, Tuple[int, ...]] - Output array shape. - dtype : Optional[Dtype] - Output array data type. Default: ``None``. - device : Optional[Device] - Device on which to place the created array. - """ - from ._array_object import Array - - if dtype is None: - dtype = default_float - return Array._new(ht.zeros(shape, dtype=dtype, device=device)) - - -def zeros_like( - x: Array, /, *, dtype: Optional[Dtype] = None, device: Optional[Device] = None -) -> Array: - """ - Returns a new array filled with zeros and having the same shape as an input array x. - - Parameters - ---------- - x : Array - Input array from which to derive the output array shape. - dtype : Optional[Dtype] - Output array data type. If ``dtype`` is ``None``, the output array data - type is inferred from x. Default: ``None``. - device : Optional[Device] - Device on which to place the created array. Default: ``None``. - """ - from ._array_object import Array - - return Array._new(ht.zeros_like(x._array, dtype=dtype)) diff --git a/heat/array_api/_data_type_functions.py b/heat/array_api/_data_type_functions.py deleted file mode 100644 index e8c4c7e95d..0000000000 --- a/heat/array_api/_data_type_functions.py +++ /dev/null @@ -1,178 +0,0 @@ -from __future__ import annotations - -from ._array_object import Array -from ._dtypes import _all_dtypes, _result_type - -from dataclasses import dataclass -from typing import TYPE_CHECKING, Union, List, Tuple - -if TYPE_CHECKING: - from ._typing import Dtype - -import heat as ht -from heat.core.stride_tricks import broadcast_shape - - -def astype(x: Array, dtype: Dtype, /, *, copy: bool = True) -> Array: - """ - Copies an array to a specified data type irrespective of Type Promotion Rules. - - Parameters - ---------- - x : Array - Array to cast. - dtype : Dtype - Desired data type. - copy : bool - If ``True``, a newly allocated array is returned. If ``False`` and the - specified ``dtype`` matches the data type of the input array, the - input array is returned; otherwise, a newly allocated is returned. - Default: ``True``. - """ - if not copy and dtype == x.dtype: - return x - return Array._new(x._array.astype(dtype, copy=True)) - - -def broadcast_arrays(*arrays: Array) -> List[Array]: - """ - Broadcasts one or more arrays against one another. - - Parameters - ---------- - arrays : Array - An arbitrary number of to-be broadcasted arrays. - """ - from ._array_object import Array - - return [Array._new(array) for array in ht.broadcast_arrays(*[a._array for a in arrays])] - - -def broadcast_to(x: Array, /, shape: Tuple[int, ...]) -> Array: - """ - Broadcasts an array to a specified shape. - - Parameters - ---------- - x : Array - Array to broadcast. - shape : Tuple[int, ...] - Array shape. Must be compatible with x. - """ - from ._array_object import Array - - return Array._new(ht.broadcast_to(x._array, shape)) - - -def can_cast(from_: Union[Dtype, Array], to: Dtype, /) -> bool: - """ - Determines if one data type can be cast to another data type according to - Type Promotion Rules. - - - Parameters - ---------- - from_ : Union[Dtype, Array] - Input data type or array from which to cast. - to : Dtype - Desired data type. - """ - if isinstance(from_, Array): - from_ = from_.dtype - elif from_ not in _all_dtypes: - raise TypeError(f"{from_=}, but should be an array_api array or dtype") - if to not in _all_dtypes: - raise TypeError(f"{to=}, but should be a dtype") - try: - # We promote `from_` and `to` together. We then check if the promoted - # dtype is `to`, which indicates if `from_` can (up)cast to `to`. - dtype = _result_type(from_, to) - return to == dtype - except TypeError: - # _result_type() raises if the dtypes don't promote together - return False - - -@dataclass -class finfo_object: - """ - Internal object for return type of ``finfo``. - """ - - bits: int - eps: float - max: float - min: float - smallest_normal: float - - -@dataclass -class iinfo_object: - """ - Internal object for return type of ``iinfo``. - """ - - bits: int - max: int - min: int - - -def finfo(type: Union[Dtype, Array], /) -> finfo_object: - """ - Machine limits for floating-point data types. - - Parameters - ---------- - type : Union[Dtype, Array] - The kind of floating-point data-type about which to get information. - """ - fi = ht.finfo(type) - return finfo_object( - fi.bits, - fi.eps, - fi.max, - fi.min, - fi.tiny, - ) - - -def iinfo(type: Union[Dtype, Array], /) -> iinfo_object: - """ - Machine limits for integer data types. - - Parameters - ---------- - type : Union[Dtype, Array] - The kind of integer data-type about which to get information. - """ - ii = ht.iinfo(type) - return iinfo_object(ii.bits, int(ii.max), int(ii.min)) - - -def result_type(*arrays_and_dtypes: Union[Array, Dtype]) -> Dtype: - """ - Returns the dtype that results from applying the type promotion rules - to the arguments. - - Parameters - ---------- - arrays_and_dtypes : Union[Array, Dtype] - An arbitrary number of input arrays and/or dtypes. - """ - A = [] - for a in arrays_and_dtypes: - if isinstance(a, Array): - a = a.dtype - elif isinstance(a, ht.DNDarray) or a not in _all_dtypes: - raise TypeError("result_type() inputs must be array_api arrays or dtypes") - A.append(a) - - if len(A) == 0: - raise ValueError("at least one array or dtype is required") - elif len(A) == 1: - return A[0] - else: - t = A[0] - for t2 in A[1:]: - t = _result_type(t, t2) - return t diff --git a/heat/array_api/_dtypes.py b/heat/array_api/_dtypes.py deleted file mode 100644 index 19dd9e5bc4..0000000000 --- a/heat/array_api/_dtypes.py +++ /dev/null @@ -1,203 +0,0 @@ -import heat as ht - -bool = ht.bool -"""Boolean (``True`` or ``False``).""" -int8 = ht.int8 -"""An 8-bit signed integer whose values exist on the interval ``[-128, +127]``.""" -int16 = ht.int16 -"""A 16-bit signed integer whose values exist on the interval ``[-32,767, +32,767]``.""" -int32 = ht.int32 -"""A 32-bit signed integer whose values exist on the interval ``[-2,147,483,647, +2,147,483,647]``.""" -int64 = ht.int64 -"""A 64-bit signed integer whose values exist on the interval ``[-9,223,372,036,854,775,807, +9,223,372,036,854,775,807]``.""" -uint8 = ht.uint8 -"""An 8-bit unsigned integer whose values exist on the interval ``[0, +255]``.""" -# For the status of Pytorch support for these 3 data types, -# see https://github.com/pytorch/pytorch/issues/58734 -# uint16 = -# """A 16-bit unsigned integer whose values exist on the interval ``[0, +65,535]``.""" -# uint32 = -# """A 32-bit unsigned integer whose values exist on the interval ``[0, +4,294,967,295]``.""" -# uint64 = -# """A 64-bit unsigned integer whose values exist on the interval ``[0, +18,446,744,073,709,551,615]``.""" -float32 = ht.float32 -"""IEEE 754 single-precision (32-bit) binary floating-point number (see IEEE 754-2019).""" -float64 = ht.float64 -"""IEEE 754 double-precision (64-bit) binary floating-point number (see IEEE 754-2019).""" -complex64 = ht.complex64 -"""Single-precision (64-bit) complex floating-point number whose real and imaginary components must be IEEE 754 single-precision (32-bit) binary floating-point numbers (see IEEE 754-2019).""" -complex128 = ht.complex128 -"""Double-precision (128-bit) complex floating-point number whose real and imaginary components must be IEEE 754 double-precision (64-bit) binary floating-point numbers (see IEEE 754-2019).""" - -default_int = int64 -"""Default integer data type is ``int64``""" -default_float = float64 -"""Default floating-point data type is ``float64``""" - -_all_dtypes = ( - bool, - int8, - int16, - int32, - int64, - uint8, - # uint16, - # uint32, - # uint64, - float32, - float64, - complex64, - complex128, -) -_boolean_dtypes = (bool,) -_real_floating_dtypes = (float32, float64) -_floating_dtypes = (float32, float64, complex64, complex128) -_complex_floating_dtypes = (complex64, complex128) -_integer_dtypes = ( - int8, - int16, - int32, - int64, - uint8, - # uint16, - # uint32, - # uint64 -) -_signed_integer_dtypes = (int8, int16, int32, int64) -_unsigned_integer_dtypes = ( - uint8, - # uint16, - # utnt32, - # uint64 -) -_integer_or_boolean_dtypes = ( - bool, - int8, - int16, - int32, - int64, - uint8, - # uint16, - # uint32, - # uint64, -) -_real_numeric_dtypes = ( - float32, - float64, - int8, - int16, - int32, - int64, - uint8, - # uint16, - # uint32, - # uint64, -) -_numeric_dtypes = ( - float32, - float64, - complex64, - complex128, - int8, - int16, - int32, - int64, - uint8, - # uint16, - # uint32, - # uint64, -) - -_dtype_categories = { - "all": _all_dtypes, - "real numeric": _real_numeric_dtypes, - "numeric": _numeric_dtypes, - "integer": _integer_dtypes, - "integer or boolean": _integer_or_boolean_dtypes, - "boolean": _boolean_dtypes, - "real floating-point": _floating_dtypes, - "complex floating-point": _complex_floating_dtypes, - "floating-point": _floating_dtypes, -} - -_promotion_table = { - (int8, int8): int8, - (int8, int16): int16, - (int8, int32): int32, - (int8, int64): int64, - (int16, int8): int16, - (int16, int16): int16, - (int16, int32): int32, - (int16, int64): int64, - (int32, int8): int32, - (int32, int16): int32, - (int32, int32): int32, - (int32, int64): int64, - (int64, int8): int64, - (int64, int16): int64, - (int64, int32): int64, - (int64, int64): int64, - (uint8, uint8): uint8, - # (uint8, uint16): uint16, - # (uint8, uint32): uint32, - # (uint8, uint64): uint64, - # (uint16, uint8): uint16, - # (uint16, uint16): uint16, - # (uint16, uint32): uint32, - # (uint16, uint64): uint64, - # (uint32, uint8): uint32, - # (uint32, uint16): uint32, - # (uint32, uint32): uint32, - # (uint32, uint64): uint64, - # (uint64, uint8): uint64, - # (uint64, uint16): uint64, - # (uint64, uint32): uint64, - # (uint64, uint64): uint64, - (int8, uint8): int16, - # (int8, uint16): int32, - # (int8, uint32): int64, - (int16, uint8): int16, - # (int16, uint16): int32, - # (int16, uint32): int64, - (int32, uint8): int32, - # (int32, uint16): int32, - # (int32, uint32): int64, - (int64, uint8): int64, - # (int64, uint16): int64, - # (int64, uint32): int64, - (uint8, int8): int16, - # (uint16, int8): int32, - # (uint32, int8): int64, - (uint8, int16): int16, - # (uint16, int16): int32, - # (uint32, int16): int64, - (uint8, int32): int32, - # (uint16, int32): int32, - # (uint32, int32): int64, - (uint8, int64): int64, - # (uint16, int64): int64, - # (uint32, int64): int64, - (float32, float32): float32, - (float32, float64): float64, - (float64, float32): float64, - (float64, float64): float64, - (complex64, complex64): complex64, - (complex128, complex128): complex128, - (complex64, complex128): complex128, - (complex128, complex64): complex128, - (float32, complex64): complex64, - (float32, complex128): complex128, - (float64, complex64): complex128, - (float64, complex128): complex128, - (complex64, float32): complex64, - (complex64, float64): complex128, - (complex128, float32): complex128, - (complex128, float64): complex128, - (bool, bool): bool, -} - - -def _result_type(type1, type2): - if (type1, type2) in _promotion_table: - return _promotion_table[type1, type2] - raise TypeError(f"{type1} and {type2} cannot be type promoted together") diff --git a/heat/array_api/_elementwise_functions.py b/heat/array_api/_elementwise_functions.py deleted file mode 100644 index da6f9e3af9..0000000000 --- a/heat/array_api/_elementwise_functions.py +++ /dev/null @@ -1,1054 +0,0 @@ -from __future__ import annotations - -from ._dtypes import ( - _numeric_dtypes, - _boolean_dtypes, - _integer_dtypes, - _integer_or_boolean_dtypes, - _floating_dtypes, - _result_type, -) -from ._array_object import Array -from ._data_type_functions import astype - -import heat as ht - - -def abs(x: Array, /) -> Array: - """ - Calculates the absolute value for each element ``x_i`` of the input array ``x`` - (i.e., the element-wise result has the same magnitude as the respective - element in ``x`` but has positive sign). - - Parameters - ---------- - x : Array - Input array. Must have a numeric data type. - """ - if x.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in abs") - return Array._new(ht.abs(x._array, dtype=x.dtype)) - - -def acos(x: Array, /) -> Array: - """ - Calculates an approximation of the principal value of the inverse cosine, - having domain ``[-1, +1]`` and codomain ``[+0, +Ï€]``, for each element ``x_i`` - of the input array ``x``. Each element-wise result is expressed in radians. - - Parameters - ---------- - x : Array - Input array. Must have a floating-point data type. - """ - if x.dtype not in _floating_dtypes: - raise TypeError("Only floating-point dtypes are allowed in acos") - return Array._new(ht.acos(x._array)) - - -def acosh(x: Array, /) -> Array: - """ - Calculates an approximation to the inverse hyperbolic cosine, having domain - ``[+1, +infinity]`` and codomain ``[+0, +infinity]``, for each element ``x_i`` - of the input array ``x``. - - Parameters - ---------- - x : Array - Input array whose elements each represent the area of a hyperbolic sector. - Must have a floating-point data type. - """ - if x.dtype not in _floating_dtypes: - raise TypeError("Only floating-point dtypes are allowed in acosh") - return Array._new(ht.acosh(x._array)) - - -def add(x1: Array, x2: Array, /) -> Array: - """ - Calculates the sum for each element ``x1_i`` of the input array ``x1`` with - the respective element ``x2_i`` of the input array ``x2``. - - Parameters - ---------- - x1 : Array - First input array. Must have a numeric data type. - x2 : Array - Second input array. Must be compatible with ``x1`` and have a numeric - data type. - """ - if x1.dtype not in _numeric_dtypes or x2.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in add") - # Call result type here just to raise on disallowed type combinations - _result_type(x1.dtype, x2.dtype) - x1, x2 = Array._normalize_two_args(x1, x2) - return Array._new(ht.add(x1._array, x2._array)) - - -def asin(x: Array, /) -> Array: - """ - Calculates an approximation of the principal value of the inverse sine, having - domain ``[-1, +1]`` and codomain ``[-Ï€/2, +Ï€/2]`` for each element ``x_i`` of - the input array ``x``. Each element-wise result is expressed in radians. - - Parameters - ---------- - x : Array - Input array. Must have a floating-point data type. - """ - if x.dtype not in _floating_dtypes: - raise TypeError("Only floating-point dtypes are allowed in asin") - return Array._new(ht.asin(x._array)) - - -def asinh(x: Array, /) -> Array: - """ - Calculates an approximation to the inverse hyperbolic sine, having domain - ``[-infinity, +infinity]`` and codomain ``[-infinity, +infinity]``, for each - element ``x_i`` in the input array ``x``. - - Parameters - ---------- - x : Array - Input array whose elements each represent the area of a hyperbolic sector. - Must have a floating-point data type. - """ - if x.dtype not in _floating_dtypes: - raise TypeError("Only floating-point dtypes are allowed in asinh") - return Array._new(ht.asinh(x._array)) - - -def atan(x: Array, /) -> Array: - """ - Calculates an implementation-dependent approximation of the principal value of - the inverse tangent, having domain ``[-infinity, +infinity]`` and codomain - ``[-Ï€/2, +Ï€/2]``, for each element ``x_i`` of the input array ``x``. - Each element-wise result is expressed in radians. - - Parameters - ---------- - x : Array - Input array. Must have a floating-point data type. - """ - if x.dtype not in _floating_dtypes: - raise TypeError("Only floating-point dtypes are allowed in atan") - return Array._new(ht.atan(x._array)) - - -def atan2(x1: Array, x2: Array, /) -> Array: - """ - Calculates an approximation of the inverse tangent of the quotient ``x1/x2``, - having domain ``[-infinity, +infinity] x [-infinity, +infinity]`` (where the - ``x`` notation denotes the set of ordered pairs of elements ``(x1_i, x2_i)``) - and codomain ``[-Ï€, +Ï€]``, for each pair of elements ``(x1_i, x2_i)`` of the - input arrays ``x1`` and ``x2``, respectively. Each element-wise result is - expressed in radians. - - The mathematical signs of ``x1_i`` and ``x2_i`` determine the quadrant of each - element-wise result. The quadrant (i.e., branch) is chosen such that each - element-wise result is the signed angle in radians between the ray ending at the - origin and passing through the point ``(1,0)`` and the ray ending at the origin - and passing through the point ``(x2_i, x1_i)``. - - Parameters - ---------- - x1 : Array - Input array corresponding to the y-coordinates. Must have a floating-point - data type. - x2 : Array - Input array corresponding to the x-coordinates. Must be compatible with ``x1`` - and have a floating-point data type. - """ - if x1.dtype not in _floating_dtypes or x2.dtype not in _floating_dtypes: - raise TypeError("Only floating-point dtypes are allowed in atan2") - # Call result type here just to raise on disallowed type combinations - _result_type(x1.dtype, x2.dtype) - x1, x2 = Array._normalize_two_args(x1, x2) - return Array._new(ht.atan2(x1._array, x2._array)) - - -def atanh(x: Array, /) -> Array: - """ - Calculates an approximation to the inverse hyperbolic tangent, having domain - ``[-1, +1]`` and codomain ``[-infinity, +infinity]``, for each element ``x_i`` - of the input array ``x``. - - Parameters - ---------- - x : Array - Input array whose elements each represent the area of a hyperbolic sector. - Must have a floating-point data type. - """ - if x.dtype not in _floating_dtypes: - raise TypeError("Only floating-point dtypes are allowed in atanh") - return Array._new(ht.atanh(x._array)) - - -def bitwise_and(x1: Array, x2: Array, /) -> Array: - """ - Computes the bitwise AND of the underlying binary representation of each - element ``x1_i`` of the input array ``x1`` with the respective element - ``x2_i`` of the input array ``x2``. - - Parameters - ---------- - x1 : Array - First input array. Must have an integer or boolean data type. - x2 : Array - Second input array. Must be compatible with ``x1`` and have an integer - or boolean data type. - """ - if x1.dtype not in _integer_or_boolean_dtypes or x2.dtype not in _integer_or_boolean_dtypes: - raise TypeError("Only integer or boolean dtypes are allowed in bitwise_and") - # Call result type here just to raise on disallowed type combinations - _result_type(x1.dtype, x2.dtype) - x1, x2 = Array._normalize_two_args(x1, x2) - return Array._new(ht.bitwise_and(x1._array, x2._array)) - - -def bitwise_left_shift(x1: Array, x2: Array, /) -> Array: - """ - Shifts the bits of each element ``x1_i`` of the input array ``x1`` to the - left by appending ``x2_i`` (i.e., the respective element in the input array - ``x2``) zeros to the right of ``x1_i``. - - Parameters - ---------- - x1 : Array - First input array. Must have an integer data type. - x2 : Array - Second input array. Must be compatible with ``x1`` and have an integer - data type. Each element must be greater than or equal to ``0``. - """ - if x1.dtype not in _integer_dtypes or x2.dtype not in _integer_dtypes: - raise TypeError("Only integer dtypes are allowed in bitwise_left_shift") - # Call result type here just to raise on disallowed type combinations - _result_type(x1.dtype, x2.dtype) - x1, x2 = Array._normalize_two_args(x1, x2) - if ht.any(x2._array < 0): - raise ValueError("bitwise_left_shift(x1, x2) is only defined for x2 >= 0") - return Array._new(ht.left_shift(x1._array, x2._array)) - - -def bitwise_invert(x: Array, /) -> Array: - """ - Inverts (flips) each bit for each element ``x_i`` of the input array ``x``. - - Parameters - ---------- - x : Array - Input array. Must have an integer or boolean data type. - """ - if x.dtype not in _integer_or_boolean_dtypes: - raise TypeError("Only integer or boolean dtypes are allowed in bitwise_invert") - return Array._new(ht.invert(x._array)) - - -def bitwise_or(x1: Array, x2: Array, /) -> Array: - """ - Computes the bitwise OR of the underlying binary representation of each - element ``x1_i`` of the input array ``x1`` with the respective element - ``x2_i`` of the input array ``x2``. - - Parameters - ---------- - x1 : Array - First input array. Must have an integer or boolean data type. - x2 : Array - Second input array. Must be compatible with ``x1`` and have an integer - or boolean data type. - """ - if x1.dtype not in _integer_or_boolean_dtypes or x2.dtype not in _integer_or_boolean_dtypes: - raise TypeError("Only integer or boolean dtypes are allowed in bitwise_or") - _result_type(x1.dtype, x2.dtype) - x1, x2 = Array._normalize_two_args(x1, x2) - return Array._new(ht.bitwise_or(x1._array, x2._array)) - - -def bitwise_right_shift(x1: Array, x2: Array, /) -> Array: - """ - Shifts the bits of each element ``x1_i`` of the input array ``x1`` to the - right according to the respective element ``x2_i`` of the input array ``x2``. - - Parameters - ---------- - x1 : Array - First input array. Must have an integer data type. - x2 : Array - Second input array. Must be compatible with ``x1`` and have an integer - data type. Each element must be greater than or equal to ``0``. - """ - if x1.dtype not in _integer_dtypes or x2.dtype not in _integer_dtypes: - raise TypeError("Only integer dtypes are allowed in bitwise_right_shift") - # Call result type here just to raise on disallowed type combinations - _result_type(x1.dtype, x2.dtype) - x1, x2 = Array._normalize_two_args(x1, x2) - # Note: bitwise_right_shift is only defined for x2 nonnegative. - if ht.any(x2._array < 0): - raise ValueError("bitwise_right_shift(x1, x2) is only defined for x2 >= 0") - return Array._new(ht.right_shift(x1._array, x2._array)) - - -def bitwise_xor(x1: Array, x2: Array, /) -> Array: - """ - Computes the bitwise XOR of the underlying binary representation of each element - ``x1_i`` of the input array ``x1`` with the respective element ``x2_i`` of the - input array ``x2``. - - Parameters - ---------- - x1 : Array - First input array. Must have an integer or boolean data type. - x2 : Array - Second input array. Must be compatible with ``x1`` and have an integer - or boolean data type. - """ - if x1.dtype not in _integer_or_boolean_dtypes or x2.dtype not in _integer_or_boolean_dtypes: - raise TypeError("Only integer or boolean dtypes are allowed in bitwise_xor") - # Call result type here just to raise on disallowed type combinations - _result_type(x1.dtype, x2.dtype) - x1, x2 = Array._normalize_two_args(x1, x2) - return Array._new(ht.bitwise_xor(x1._array, x2._array)) - - -def ceil(x: Array, /) -> Array: - """ - Rounds each element ``x_i`` of the input array ``x`` to the smallest (i.e., closest - to ``-infinity``) integer-valued number that is not less than ``x_i``. - - Parameters - ---------- - x : Array - Input array. Must have a numeric data type. - """ - if x.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in ceil") - if x.dtype in _integer_dtypes: - return x - return Array._new(ht.ceil(x._array)) - - -def cos(x: Array, /) -> Array: - """ - Calculates an approximation to the cosine, having domain ``(-infinity, +infinity)`` - and codomain ``[-1, +1]``, for each element ``x_i`` of the input array ``x``. - Each element ``x_i`` is assumed to be expressed in radians. - - Parameters - ---------- - x : Array - Input array whose elements are each expressed in radians. Must have a - floating-point data type. - """ - if x.dtype not in _floating_dtypes: - raise TypeError("Only floating-point dtypes are allowed in cos") - return Array._new(ht.cos(x._array)) - - -def cosh(x: Array, /) -> Array: - """ - Calculates an approximation to the hyperbolic cosine, having domain - ``[-infinity, +infinity]`` and codomain ``[-infinity, +infinity]``, for each - element ``x_i`` in the input array ``x``. - - Parameters - ---------- - x : Array - Input array whose elements each represent a hyperbolic angle. Must have - a floating-point data type. - """ - if x.dtype not in _floating_dtypes: - raise TypeError("Only floating-point dtypes are allowed in cosh") - return Array._new(ht.cosh(x._array)) - - -def divide(x1: Array, x2: Array, /) -> Array: - """ - Calculates the division for each element ``x1_i`` of the input array ``x1`` - with the respective element ``x2_i`` of the input array ``x2``. - - Parameters - ---------- - x1 : Array - Dividend input array. Must have a numeric data type. - x2 : Array - Divisor input array. Must be compatible with ``x1`` and have a numeric - data type. - """ - if x1.dtype not in _floating_dtypes or x2.dtype not in _floating_dtypes: - raise TypeError("Only floating-point dtypes are allowed in divide") - # Call result type here just to raise on disallowed type combinations - _result_type(x1.dtype, x2.dtype) - x1, x2 = Array._normalize_two_args(x1, x2) - return Array._new(ht.divide(x1._array, x2._array)) - - -def equal(x1: Array, x2: Array, /) -> Array: - """ - Computes the truth value of ``x1_i == x2_i`` for each element ``x1_i`` of - the input array ``x1`` with the respective element ``x2_i`` of the input - array ``x2``. - - Parameters - ---------- - x1 : Array - First input array. - x2 : Array - Second input array. Must be compatible with ``x1``. - """ - # Call result type here just to raise on disallowed type combinations - _result_type(x1.dtype, x2.dtype) - x1, x2 = Array._normalize_two_args(x1, x2) - return Array._new(ht.eq(x1._array, x2._array)) - - -def exp(x: Array, /) -> Array: - """ - Calculates an approximation to the exponential function, having domain - ``[-infinity, +infinity]`` and codomain ``[+0, +infinity]``, for each element - ``x_i`` of the input array ``x`` (``e`` raised to the power of ``x_i``, where - ``e`` is the base of the natural logarithm). - - Parameters - ---------- - x : Array - Input array. Must have a floating-point data type. - """ - if x.dtype not in _floating_dtypes: - raise TypeError("Only floating-point dtypes are allowed in exp") - return Array._new(ht.exp(x._array)) - - -def expm1(x: Array, /) -> Array: - """ - Calculates an approximation to ``exp(x)-1``, having domain - ``[-infinity, +infinity]`` and codomain ``[-1, +infinity]``, for each element - ``x_i`` of the input array ``x``. - - Parameters - ---------- - x : Array - Input array. Must have a floating-point data type. - """ - if x.dtype not in _floating_dtypes: - raise TypeError("Only floating-point dtypes are allowed in expm1") - return Array._new(ht.expm1(x._array)) - - -def floor(x: Array, /) -> Array: - """ - Rounds each element ``x_i`` of the input array ``x`` to the greatest - (i.e., closest to ``+infinity``) integer-valued number that is not greater - than ``x_i``. - - Parameters - ---------- - x : Array - Input array. Must have a numeric data type. - """ - if x.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in floor") - if x.dtype in _integer_dtypes: - return x - return Array._new(ht.floor(x._array)) - - -def floor_divide(x1: Array, x2: Array, /) -> Array: - """ - Rounds the result of dividing each element ``x1_i`` of the input array ``x1`` - by the respective element ``x2_i`` of the input array ``x2`` to the greatest - (i.e., closest to ``+infinity``) integer-value number that is not greater than - the division result. - - Parameters - ---------- - x1 : Array - First input array. Must have a numeric data type. - x2 : Array - Second input array. Must be compatible with ``x1`` and have a numeric - data type. - """ - if x1.dtype not in _numeric_dtypes or x2.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in floor_divide") - # Call result type here just to raise on disallowed type combinations - _result_type(x1.dtype, x2.dtype) - x1, x2 = Array._normalize_two_args(x1, x2) - return Array._new(ht.floor_divide(x1._array, x2._array)) - - -def greater(x1: Array, x2: Array, /) -> Array: - """ - Computes the truth value of ``x1_i > x2_i`` for each element ``x1_i`` of - the input array ``x1`` with the respective element ``x2_i`` of the input - array ``x2``. - - Parameters - ---------- - x1 : Array - First input array. Must have a numeric data type. - x2 : Array - Second input array. Must be compatible with ``x1`` and have a numeric - data type. - """ - if x1.dtype not in _numeric_dtypes or x2.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in greater") - # Call result type here just to raise on disallowed type combinations - _result_type(x1.dtype, x2.dtype) - x1, x2 = Array._normalize_two_args(x1, x2) - return Array._new(ht.greater(x1._array, x2._array)) - - -def greater_equal(x1: Array, x2: Array, /) -> Array: - """ - Computes the truth value of ``x1_i >= x2_i`` for each element ``x1_i`` of - the input array ``x1`` with the respective element ``x2_i`` of the input - array ``x2``. - - Parameters - ---------- - x1 : Array - First input array. Must have a numeric data type. - x2 : Array - Second input array. Must be compatible with ``x1`` and have a numeric - data type. - """ - if x1.dtype not in _numeric_dtypes or x2.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in greater_equal") - # Call result type here just to raise on disallowed type combinations - _result_type(x1.dtype, x2.dtype) - x1, x2 = Array._normalize_two_args(x1, x2) - return Array._new(ht.greater_equal(x1._array, x2._array)) - - -def isfinite(x: Array, /) -> Array: - """ - Tests each element ``x_i`` of the input array ``x`` to determine if finite - (i.e., not ``NaN`` and not equal to positive or negative infinity). - - Parameters - ---------- - x : Array - Input array. Must have a numeric data type. - """ - if x.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in isfinite") - return Array._new(ht.isfinite(x._array)) - - -def isinf(x: Array, /) -> Array: - """ - Tests each element ``x_i`` of the input array ``x`` to determine if equal - to positive or negative infinity. - - Parameters - ---------- - x : Array - Input array. Must have a numeric data type. - """ - if x.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in isinf") - return Array._new(ht.isinf(x._array)) - - -def isnan(x: Array, /) -> Array: - """ - Tests each element ``x_i`` of the input array ``x`` to determine whether - the element is ``NaN``. - - Parameters - ---------- - x : Array - Input array. Must have a numeric data type. - """ - if x.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in isnan") - return Array._new(ht.isnan(x._array)) - - -def less(x1: Array, x2: Array, /) -> Array: - """ - Computes the truth value of ``x1_i < x2_i`` for each element ``x1_i`` of - the input array ``x1`` with the respective element ``x2_i`` of the input - array ``x2``. - - Parameters - ---------- - x1 : Array - First input array. Must have a numeric data type. - x2 : Array - Second input array. Must be compatible with ``x1`` and have a numeric - data type. - """ - if x1.dtype not in _numeric_dtypes or x2.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in less") - # Call result type here just to raise on disallowed type combinations - _result_type(x1.dtype, x2.dtype) - x1, x2 = Array._normalize_two_args(x1, x2) - return Array._new(ht.less(x1._array, x2._array)) - - -def less_equal(x1: Array, x2: Array, /) -> Array: - """ - Computes the truth value of ``x1_i <= x2_i`` for each element ``x1_i`` - of the input array ``x1`` with the respective element ``x2_i`` of the - input array ``x2``. - - Parameters - ---------- - x1 : Array - First input array. Must have a numeric data type. - x2 : Array - Second input array. Must be compatible with ``x1`` and have a numeric - data type. - """ - if x1.dtype not in _numeric_dtypes or x2.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in less_equal") - # Call result type here just to raise on disallowed type combinations - _result_type(x1.dtype, x2.dtype) - x1, x2 = Array._normalize_two_args(x1, x2) - return Array._new(ht.less_equal(x1._array, x2._array)) - - -def log(x: Array, /) -> Array: - """ - Calculates an approximation to the natural (base ``e``) logarithm, having domain - ``[0, +infinity]`` and codomain ``[-infinity, +infinity]``, for each element - ``x_i`` of the input array ``x``. - - Parameters - ---------- - x : Array - Input array. Must have a floating-point data type. - """ - if x.dtype not in _floating_dtypes: - raise TypeError("Only floating-point dtypes are allowed in log") - return Array._new(ht.log(x._array)) - - -def log1p(x: Array, /) -> Array: - """ - Calculates an approximation to ``log(1+x)``, where ``log`` refers to the natural - (base ``e``) logarithm, having domain ``[-1, +infinity]`` and codomain - ``[-infinity, +infinity]``, for each element ``x_i`` of the input array ``x``. - - Parameters - ---------- - x : Array - Input array. Must have a floating-point data type. - """ - if x.dtype not in _floating_dtypes: - raise TypeError("Only floating-point dtypes are allowed in log1p") - return Array._new(ht.log1p(x._array)) - - -def log2(x: Array, /) -> Array: - """ - Calculates an approximation to the base ``2`` logarithm, having domain - ``[0, +infinity]`` and codomain ``[-infinity, +infinity]``, for each element - ``x_i`` of the input array ``x``. - - Parameters - ---------- - x : Array - Input array. Must have a floating-point data type. - """ - if x.dtype not in _floating_dtypes: - raise TypeError("Only floating-point dtypes are allowed in log2") - return Array._new(ht.log2(x._array)) - - -def log10(x: Array, /) -> Array: - """ - Calculates an approximation to the base ``10`` logarithm, having domain - ``[0, +infinity]`` and codomain ``[-infinity, +infinity]``, for each element - ``x_i`` of the input array ``x``. - - Parameters - ---------- - x : Array - Input array. Must have a floating-point data type. - """ - if x.dtype not in _floating_dtypes: - raise TypeError("Only floating-point dtypes are allowed in log10") - return Array._new(ht.log10(x._array)) - - -def logaddexp(x1: Array, x2: Array) -> Array: - """ - Calculates the logarithm of the sum of exponentiations ``log(exp(x1) + exp(x2))`` - for each element ``x1_i`` of the input array ``x1`` with the respective element - ``x2_i`` of the input array ``x2``. - - Parameters - ---------- - x1 : Array - First input array. Must have a floating-point data type. - x2 : Array - Second input array. Must be compatible with ``x1`` and have a floating-point - data type. - """ - if x1.dtype not in _floating_dtypes or x2.dtype not in _floating_dtypes: - raise TypeError("Only floating-point dtypes are allowed in logaddexp") - # Call result type here just to raise on disallowed type combinations - _result_type(x1.dtype, x2.dtype) - x1, x2 = Array._normalize_two_args(x1, x2) - return Array._new(ht.logaddexp(x1._array, x2._array)) - - -def logical_and(x1: Array, x2: Array, /) -> Array: - """ - Computes the logical AND for each element ``x1_i`` of the input array ``x1`` - with the respective element ``x2_i`` of the input array ``x2``. - - Parameters - ---------- - x1 : Array - First input array. Must have a boolean data type. - x2 : Array - Second input array. Must be compatible with ``x1`` and have a boolean - data type. - """ - if x1.dtype not in _boolean_dtypes or x2.dtype not in _boolean_dtypes: - raise TypeError("Only boolean dtypes are allowed in logical_and") - # Call result type here just to raise on disallowed type combinations - _result_type(x1.dtype, x2.dtype) - x1, x2 = Array._normalize_two_args(x1, x2) - return Array._new(ht.logical_and(x1._array, x2._array)) - - -def logical_not(x: Array, /) -> Array: - """ - Computes the logical NOT for each element ``x_i`` of the input array ``x``. - - Parameters - ---------- - x : Array - Input array. Must have a boolean data type. - """ - if x.dtype not in _boolean_dtypes: - raise TypeError("Only boolean dtypes are allowed in logical_not") - return Array._new(ht.logical_not(x._array)) - - -def logical_or(x1: Array, x2: Array, /) -> Array: - """ - Computes the logical OR for each element ``x1_i`` of the input array ``x1`` - with the respective element ``x2_i`` of the input array ``x2``. - - Parameters - ---------- - x1 : Array - First input array. Must have a boolean data type. - x2 : Array - Second input array. Must be compatible with ``x1`` and have a boolean - data type. - """ - if x1.dtype not in _boolean_dtypes or x2.dtype not in _boolean_dtypes: - raise TypeError("Only boolean dtypes are allowed in logical_or") - # Call result type here just to raise on disallowed type combinations - _result_type(x1.dtype, x2.dtype) - x1, x2 = Array._normalize_two_args(x1, x2) - return Array._new(ht.logical_or(x1._array, x2._array)) - - -def logical_xor(x1: Array, x2: Array, /) -> Array: - """ - Computes the logical XOR for each element ``x1_i`` of the input array ``x1`` - with the respective element ``x2_i`` of the input array ``x2``. - - Parameters - ---------- - x1 : Array - First input array. Must have a boolean data type. - x2 : Array - Second input array. Must be compatible with ``x1`` and have a boolean - data type. - """ - if x1.dtype not in _boolean_dtypes or x2.dtype not in _boolean_dtypes: - raise TypeError("Only boolean dtypes are allowed in logical_xor") - # Call result type here just to raise on disallowed type combinations - _result_type(x1.dtype, x2.dtype) - x1, x2 = Array._normalize_two_args(x1, x2) - return Array._new(ht.logical_xor(x1._array, x2._array)) - - -def multiply(x1: Array, x2: Array, /) -> Array: - """ - Calculates the product for each element ``x1_i`` of the input array ``x1`` - with the respective element ``x2_i`` of the input array ``x2``. - - Parameters - ---------- - x1 : Array - First input array. Must have a numeric data type. - x2 : Array - Second input array. Must be compatible with ``x1`` and have a numeric - data type. - """ - if x1.dtype not in _numeric_dtypes or x2.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in multiply") - # Call result type here just to raise on disallowed type combinations - _result_type(x1.dtype, x2.dtype) - x1, x2 = Array._normalize_two_args(x1, x2) - return Array._new(ht.multiply(x1._array, x2._array)) - - -def negative(x: Array, /) -> Array: - """ - Computes the numerical negative of each element ``x_i`` - (i.e., ``y_i = -x_i``) of the input array ``x``. - - Parameters - ---------- - x : Array - Input array. Must have a numeric data type. - """ - if x.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in negative") - return Array._new(ht.negative(x._array)) - - -def not_equal(x1: Array, x2: Array, /) -> Array: - """ - Computes the truth value of ``x1_i != x2_i`` for each element ``x1_i`` - of the input array ``x1`` with the respective element ``x2_i`` of the - input array ``x2``. - - Parameters - ---------- - x1 : Array - First input array. - x2 : Array - Second input array. Must be compatible with ``x1``. - """ - # Call result type here just to raise on disallowed type combinations - _result_type(x1.dtype, x2.dtype) - x1, x2 = Array._normalize_two_args(x1, x2) - return Array._new(ht.not_equal(x1._array, x2._array)) - - -def positive(x: Array, /) -> Array: - """ - Computes the numerical positive of each element ``x_i`` - (i.e., ``y_i = +x_i``) of the input array ``x``. - - Parameters - ---------- - x : Array - Input array. Must have a numeric data type. - """ - if x.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in positive") - return Array._new(ht.positive(x._array)) - - -def pow(x1: Array, x2: Array, /) -> Array: - """ - Calculates an approximation of exponentiation by raising each element - ``x1_i`` (the base) of the input array ``x1`` to the power of - ``x2_i`` (the exponent), where ``x2_i`` is the corresponding element of - the input array ``x2``. - - Parameters - ---------- - x1 : Array - First input array whose elements correspond to the exponentiation base. - Must have a numeric data type. - x2 : Array - Second input array whose elements correspond to the exponentiation exponent. - Must be compatible with ``x1`` and have a numeric - data type. - """ - if x1.dtype not in _numeric_dtypes or x2.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in pow") - # Call result type here just to raise on disallowed type combinations - _result_type(x1.dtype, x2.dtype) - x1, x2 = Array._normalize_two_args(x1, x2) - return Array._new(ht.pow(x1._array, x2._array)) - - -def remainder(x1: Array, x2: Array, /) -> Array: - """ - Returns the remainder of division for each element ``x1_i`` of the input - array ``x1`` and the respective element ``x2_i`` of the input array ``x2``. - - Parameters - ---------- - x1 : Array - Dividend input array. Must have a numeric data type. - x2 : Array - Divisor input array. Must be compatible with ``x1`` and have a numeric - data type. - """ - if x1.dtype not in _numeric_dtypes or x2.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in remainder") - # Call result type here just to raise on disallowed type combinations - _result_type(x1.dtype, x2.dtype) - x1, x2 = Array._normalize_two_args(x1, x2) - return Array._new(ht.remainder(x1._array, x2._array)) - - -def round(x: Array, /) -> Array: - """ - Rounds each element ``x_i`` of the input array ``x`` to the nearest - integer-valued number. - - Parameters - ---------- - x : Array - Input array. Must have a numeric data type. - """ - if x.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in round") - elif x.dtype in _integer_dtypes: - return x - return Array._new(ht.round(x._array)) - - -def sign(x: Array, /) -> Array: - """ - Returns an indication of the sign of a number for each element ``x_i`` of - the input array ``x``. - - Parameters - ---------- - x : Array - Input array. Must have a numeric data type. - """ - if x.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in sign") - return astype(Array._new(ht.sign(x._array)), x.dtype) - - -def sin(x: Array, /) -> Array: - """ - Calculates an approximation to the sine, having domain ``(-infinity, +infinity)`` - and codomain ``[-1, +1]``, for each element ``x_i`` of the input array ``x``. - Each element ``x_i`` is assumed to be expressed in radians. - - Parameters - ---------- - x : Array - Input array whose elements are each expressed in radians. Must have a - floating-point data type. - """ - if x.dtype not in _floating_dtypes: - raise TypeError("Only floating-point dtypes are allowed in sin") - return Array._new(ht.sin(x._array)) - - -def sinh(x: Array, /) -> Array: - """ - Calculates an approximation to the hyperbolic sine, having domain - ``[-infinity, +infinity]`` and codomain ``[-infinity, +infinity]``, for - each element ``x_i`` of the input array ``x``. - - Parameters - ---------- - x : Array - Input array whose elements each represent a hyperbolic angle. Must have - a floating-point data type. - """ - if x.dtype not in _floating_dtypes: - raise TypeError("Only floating-point dtypes are allowed in sinh") - return Array._new(ht.sinh(x._array)) - - -def square(x: Array, /) -> Array: - """ - Squares ``(x_i * x_i)`` each element ``x_i`` of the input array ``x``. - - Parameters - ---------- - x : Array - Input array. Must have a numeric data type. - """ - if x.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in square") - return astype(Array._new(ht.square(x._array)), x.dtype) - - -def sqrt(x: Array, /) -> Array: - """ - Calculates the square root, having domain ``[0, +infinity]`` and codomain - ``[0, +infinity]``, for each element ``x_i`` of the input array ``x``. - - Parameters - ---------- - x : Array - Input array. Must have a floating-point data type. - """ - if x.dtype not in _floating_dtypes: - raise TypeError("Only floating-point dtypes are allowed in sqrt") - return Array._new(ht.sqrt(x._array)) - - -def subtract(x1: Array, x2: Array, /) -> Array: - """ - Calculates the difference for each element ``x1_i`` of the input array - ``x1`` with the respective element ``x2_i`` of the input array ``x2``. - - Parameters - ---------- - x1 : Array - First input array. Must have a numeric data type. - x2 : Array - Second input array. Must be compatible with ``x1`` and have a numeric - data type. - """ - if x1.dtype not in _numeric_dtypes or x2.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in subtract") - # Call result type here just to raise on disallowed type combinations - _result_type(x1.dtype, x2.dtype) - x1, x2 = Array._normalize_two_args(x1, x2) - return Array._new(ht.subtract(x1._array, x2._array)) - - -def tan(x: Array, /) -> Array: - """ - Calculates an approximation to the tangent, having domain ``(-infinity, +infinity)`` - and codomain ``(-infinity, +infinity)``, for each element ``x_i`` of the - input array ``x``. Each element ``x_i`` is assumed to be expressed in radians. - - Parameters - ---------- - x : Array - Input array whose elements are each expressed in radians. Must have a - floating-point data type. - """ - if x.dtype not in _floating_dtypes: - raise TypeError("Only floating-point dtypes are allowed in tan") - return Array._new(ht.tan(x._array)) - - -def tanh(x: Array, /) -> Array: - """ - Calculates an approximation to the hyperbolic tangent, having domain - ``[-infinity, +infinity]`` and codomain ``[-1, +1]``, for each element ``x_i`` - of the input array ``x``. - - Parameters - ---------- - x : Array - Input array whose elements each represent a hyperbolic angle. Must have - a floating-point data type. - """ - if x.dtype not in _floating_dtypes: - raise TypeError("Only floating-point dtypes are allowed in tanh") - return Array._new(ht.tanh(x._array)) - - -def trunc(x: Array, /) -> Array: - """ - Rounds each element ``x_i`` of the input array ``x`` to the integer-valued - number that is closest to but no greater than ``x_i``. - - Parameters - ---------- - x : Array - Input array. Must have a numeric data type. - """ - if x.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in trunc") - if x.dtype in _integer_dtypes: - return x - return Array._new(ht.trunc(x._array)) diff --git a/heat/array_api/_inspection.py b/heat/array_api/_inspection.py deleted file mode 100644 index 410536365b..0000000000 --- a/heat/array_api/_inspection.py +++ /dev/null @@ -1,197 +0,0 @@ -# NOTE: Ported over. Will be removed. - -import heat.core.devices as ht_devices - -from types import SimpleNamespace -from heat.core.types import ( - bool, - complex64, - complex128, - float16, - float32, - float64, - int8, - int16, - int32, - int64, - uint8, -) - - -def __array_namespace_info__(): - """Returns a namespace with Array API namespace inspection utilities.""" - info = SimpleNamespace() - info.capabilities = capabilities - info.default_device = default_device - info.default_dtypes = default_dtypes - info.devices = devices - info.dtypes = dtypes - return info - - -def capabilities(): - """Returns a dictionary of array library capabilities.""" - return {"boolean indexing": True, "data-dependent shapes": True, "max dimensions": 64} - - -def default_device(): - """Returns the default device.""" - return ht_devices.get_device() - - -def default_dtypes(*, device=None): - """Returns a dictionary containing default data types.""" - if device is None: - device = default_device() - - if not isinstance(device, ht_devices.Device): - raise ValueError(f"Device not understood: {device}") - - if "mps" in device.torch_device: - return { - "real floating": float32, - "complex floating": complex64, - "integral": int32, - "indexing": int32, - } - - return { - "real floating": float32, - "complex floating": complex64, - "integral": int64, - "indexing": int64, - } - - raise ValueError(f"Unsupported device: {device}") - - -def devices(): - """Returns a list of supported devices which are available at runtime.""" - if hasattr(ht_devices, "gpu"): - return (ht_devices.cpu, ht_devices.gpu) - else: - return (ht_devices.cpu,) - - -def dtypes(*, device=None, kind=None): - """Returns a dictionary of supported Array API data types""" - if device is None: - device = default_device() - - if not isinstance(device, ht_devices.Device): - raise ValueError(f"Device not understood: {device}") - - if "mps" in device.torch_device: - if kind is None: - return { - "bool": bool, - "int8": int8, - "int16": int16, - "int32": int32, - "uint8": uint8, - "float32": float32, - "complex64": complex64, - } - if kind == "bool": - return { - "bool": bool, - } - if kind == "signed integer": - return { - "int8": int8, - "int16": int16, - "int32": int32, - } - if kind == "unsigned integer": - return { - "uint8": uint8, - } - if kind == "integral": - return { - "int8": int8, - "int16": int16, - "int32": int32, - "uint8": uint8, - } - if kind == "real floating": - return { - "float32": float32, - } - if kind == "complex floating": - return { - "complex64": complex64, - } - if kind == "numeric": - return { - "int8": int8, - "int16": int16, - "int32": int32, - "uint8": uint8, - "float32": float32, - "complex64": complex64, - } - - if kind is None: - return { - "bool": bool, - "int8": int8, - "int16": int16, - "int32": int32, - "int64": int64, - "uint8": uint8, - "float32": float32, - "float64": float64, - "complex64": complex64, - "complex128": complex128, - } - if kind == "bool": - return { - "bool": bool, - } - if kind == "signed integer": - return { - "int8": int8, - "int16": int16, - "int32": int32, - "int64": int64, - } - if kind == "unsigned integer": - return { - "uint8": uint8, - } - if kind == "integral": - return { - "int8": int8, - "int16": int16, - "int32": int32, - "int64": int64, - "uint8": uint8, - } - if kind == "real floating": - return { - "float32": float32, - "float64": float64, - } - if kind == "complex floating": - return { - "complex64": complex64, - "complex128": complex128, - } - if kind == "numeric": - return { - "int8": int8, - "int16": int16, - "int32": int32, - "int64": int64, - "uint8": uint8, - "float32": float32, - "float64": float64, - "complex64": complex64, - "complex128": complex128, - } - if isinstance(kind, tuple): - res = {} - for k in kind: - res |= dtypes(device=device, kind=k) - return res - raise ValueError(f"Unsupported kind: {kind}") diff --git a/heat/array_api/_manipulation_functions.py b/heat/array_api/_manipulation_functions.py deleted file mode 100644 index aaa7b89e9e..0000000000 --- a/heat/array_api/_manipulation_functions.py +++ /dev/null @@ -1,167 +0,0 @@ -from __future__ import annotations - -from ._array_object import Array -from ._data_type_functions import result_type - -from typing import Optional, Tuple, Union, List - -import heat as ht - - -def concat(arrays: Union[Tuple[Array, ...], List[Array]], /, *, axis: Optional[int] = 0) -> Array: - """ - Joins a sequence of arrays along an existing axis. - - Parameters - ---------- - arrays : Union[Tuple[Array, ...], List[Array]] - Input arrays to join. The arrays must have the same shape, - except in the dimension specified by ``axis``. - axis : Optional[int] - Axis along which the arrays will be joined. If ``axis`` is ``None``, - arrays are flattened before concatenation. Default: ``0``. - """ - result_type(*arrays) - arrays = tuple(a._array for a in arrays) - if axis is None: - arrays = tuple(ht.flatten(a) for a in arrays) - axis = 0 - return Array._new(ht.concatenate(arrays, axis=axis)) - - -def expand_dims(x: Array, /, *, axis: int = 0) -> Array: - """ - Expands the shape of an array by inserting a new axis (dimension) of - size one at the position specified by ``axis``. - - Parameters - ---------- - x : Array - Input array. - axis : int - Axis position (zero-based). If ``x`` has rank (i.e, number of dimensions) ``N``, - a valid ``axis`` must reside on the closed-interval ``[-N-1, N]``. - """ - if axis < -x.ndim - 1 or axis > x.ndim: - raise IndexError("Invalid axis") - return Array._new(ht.expand_dims(x._array, axis)) - - -def flip(x: Array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None) -> Array: - """ - Reverses the order of elements in an array along the given ``axis``. The - shape of the array is preserved. - - Parameters - ---------- - x : Array - Input array. - axis : Optional[Union[int, Tuple[int, ...]]] - Axis (or axes) along which to flip. If ``axis`` is ``None``, the function - flips all input array axes. - """ - return Array._new(ht.flip(x._array, axis=axis)) - - -def permute_dims(x: Array, /, axes: Tuple[int, ...]) -> Array: - """ - Permutes the axes (dimensions) of an array ``x``. - - Parameters - ---------- - x : Array - Input array. - axes : Tuple[int, ...] - Tuple containing a permutation of ``(0, 1, ..., N-1)`` where ``N`` is the - number of axes (dimensions) of ``x``. - """ - return Array._new(ht.transpose(x._array, list(axes))) - - -def reshape(x: Array, /, shape: Tuple[int, ...], *, copy: Optional[bool] = None) -> Array: - """ - Reshapes an array without changing its data. - - Parameters - ---------- - x : Array - Input array to reshape. - shape : Tuple[int, ...] - A new shape compatible with the original shape. One shape dimension - is allowed to be ``-1``. When a shape dimension is ``-1``, the - corresponding output array shape dimension is inferred from the length - of the array and the remaining dimensions. - copy : Optional[bool] - Boolean indicating whether or not to copy the input array. - """ - res = ht.reshape(x._array, shape) - if not copy: - x._array = res - return x - return Array._new(res) - - -def roll( - x: Array, - /, - shift: Union[int, Tuple[int, ...]], - *, - axis: Optional[Union[int, Tuple[int, ...]]] = None, -) -> Array: - """ - Rolls array elements along a specified axis. Array elements that roll - beyond the last position are re-introduced at the first position. - Array elements that roll beyond the first position are re-introduced - at the last position. - - Parameters - ---------- - x : Array - Input array. - shift : Union[int, Tuple[int, ...]] - Number of places by which the elements are shifted. If ``shift`` is a - tuple, then ``axis`` must be a tuple of the same size, and each of the - given axes is shifted by the corresponding element in ``shift``. - If ``shift`` is an ``int`` and ``axis`` a tuple, then the same ``shift`` - is used for all specified axes. - axis : Optional[Union[int, Tuple[int, ...]]] - Axis (or axes) along which elements to shift. If ``axis`` is ``None``, - the array is flattened, shifted, and then restored to its original shape. - Default: ``None``. - """ - return Array._new(ht.roll(x._array, shift, axis=axis)) - - -def squeeze(x: Array, /, axis: Union[int, Tuple[int, ...]]) -> Array: - """ - Removes singleton dimensions (axes) from ``x``. - - Parameters - ---------- - x : Array - Input array. - axis : Union[int, Tuple[int, ...]] - Axis (or axes) to squeeze. - - Raises - ------ - ``ValueError``, if an axis is selected with shape entry greater than one. - """ - return Array._new(ht.squeeze(x._array, axis=axis)) - - -def stack(arrays: Union[Tuple[Array, ...], List[Array]], /, *, axis: int = 0) -> Array: - """ - Joins a sequence of arrays along a new axis. - - Parameters - ---------- - arrays : Union[Tuple[array, ...], List[array]] - Input arrays to join. Each array must have the same shape. - axis : int - Axis along which the arrays will be joined. - """ - # Call result type here just to raise on disallowed type combinations - result_type(*arrays) - arrays = tuple(a._array for a in arrays) - return Array._new(ht.stack(arrays, axis=axis)) diff --git a/heat/array_api/_searching_functions.py b/heat/array_api/_searching_functions.py deleted file mode 100644 index d9631745e5..0000000000 --- a/heat/array_api/_searching_functions.py +++ /dev/null @@ -1,89 +0,0 @@ -from __future__ import annotations - -from ._array_object import Array -from ._dtypes import _result_type, _numeric_dtypes - -from typing import Optional, Tuple - -import heat as ht - - -def argmax(x: Array, /, *, axis: Optional[int] = None, keepdims: bool = False) -> Array: - """ - Returns the indices of the maximum values along a specified axis. When the - maximum value occurs multiple times, only the indices corresponding to the - first occurrence are returned. - - Parameters - ---------- - x : Array - Input array. Must have a numeric data type. - axis : Optional[int] - Axis along which to search. If ``None``, the function returns the index of - the maximum value of the flattened array. Default: ``None``. - keepdims : bool - If ``True``, the reduced axes (dimensions) are included in the result as - singleton dimensions. Otherwise, if ``False``, the reduced axes (dimensions) - are not be included in the result. Default: ``False``. - """ - if x.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in argmax") - res = ht.argmax(x._array, axis=axis, keepdim=keepdims) - return Array._new(res) - - -def argmin(x: Array, /, *, axis: Optional[int] = None, keepdims: bool = False) -> Array: - """ - Returns the indices of the minimum values along a specified axis. When the - minimum value occurs multiple times, only the indices corresponding to the - first occurrence are returned. - - Parameters - ---------- - x : Array - Input array. Must have a numeric data type. - axis : Optional[int] - Axis along which to search. If ``None``, the function returns the index of - the minimum value of the flattened array. Default: ``None``. - keepdims : bool - If ``True``, the reduced axes (dimensions) are included in the result as - singleton dimensions. Otherwise, if ``False``, the reduced axes (dimensions) - are not be included in the result. Default: ``False``. - """ - if x.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in argmin") - res = ht.argmin(x._array, axis=axis, keepdim=keepdims) - return Array._new(res) - - -def nonzero(x: Array, /) -> Tuple[Array, ...]: - """ - Returns the indices of the array elements which are non-zero. - - Parameters - ---------- - x : Array - Input array. Must have a positive rank. - """ - # See PR #914 for overhaul - return tuple(Array._new(i) for i in ht.nonzero(x._array)) - - -def where(condition: Array, x1: Array, x2: Array, /) -> Array: - """ - Returns elements chosen from ``x1`` or ``x2`` depending on ``condition``. - - Parameters - ---------- - condition : Array - When ``True``, yield ``x1_i``; otherwise, yield ``x2_i``. Must be - compatible with ``x1`` and ``x2``. - x1 : Array - First input array. Must be compatible with ``condition`` and ``x2``. - x2 : Array - Second input array. Must be compatible with ``condition`` and ``x1``. - """ - # Call result type here just to raise on disallowed type combinations - _result_type(x1.dtype, x2.dtype) - x1, x2 = Array._normalize_two_args(x1, x2) - return Array._new(ht.where(condition._array, x1._array, x2._array)) diff --git a/heat/array_api/_set_functions.py b/heat/array_api/_set_functions.py deleted file mode 100644 index 1d975a4a13..0000000000 --- a/heat/array_api/_set_functions.py +++ /dev/null @@ -1,46 +0,0 @@ -from __future__ import annotations - -from ._array_object import Array - -from typing import NamedTuple -from ._typing import int64 - -import heat as ht - - -class UniqueInverseResult(NamedTuple): - """ - Internal object for return type of ``unique_inverse``. - """ - - values: Array - inverse_indices: Array - - -def unique_inverse(x: Array, /) -> UniqueInverseResult: - """ - Returns the unique elements of an input array ``x`` and the indices from the - set of unique elements that reconstruct ``x``. - - Parameters - ---------- - x : Array - Input array. If ``x`` has more than one dimension, the function flattens ``x`` - and returns the unique elements of the flattened array. - """ - values, inverse_indices = ht.unique(x._array, return_inverse=True) - inverse_indices = inverse_indices.astype(int64) - return UniqueInverseResult(Array._new(values), Array._new(inverse_indices)) - - -def unique_values(x: Array, /) -> Array: - """ - Returns the unique elements of an input array ``x``. - - Parameters - ---------- - x : Array - Input array. If ``x`` has more than one dimension, the function flattens ``x`` - and returns the unique elements of the flattened array. - """ - return Array._new(ht.unique(x._array)) diff --git a/heat/array_api/_sorting_functions.py b/heat/array_api/_sorting_functions.py deleted file mode 100644 index 62dd7c9a82..0000000000 --- a/heat/array_api/_sorting_functions.py +++ /dev/null @@ -1,32 +0,0 @@ -from __future__ import annotations - -from ._array_object import Array - -import heat as ht - - -def sort(x: Array, /, *, axis: int = -1, descending: bool = False, stable: bool = True) -> Array: - """ - Returns a sorted copy of an input array x. - - Parameters - ---------- - x : Array - Input array. - axis : int - Axis along which to sort. If set to ``-1``, the function must sort along the - last axis. Default: ``-1``. - descending : bool - Sort order. If ``True``, the array must be sorted in descending order (by - value). If ``False``, the array must be sorted in ascending order (by value). - Default: ``False``. - stable : bool - Sort stability. If ``True``, the returned array maintains the relative order - of ``x`` values which compare as equal. If ``False``, the returned array may - or may not maintain the relative order of ``x`` values which compare as equal. - Default: ``True``. - """ - if stable: - raise ValueError("Stable sorting not yet implemented") - res = ht.sort(x._array, axis=axis, descending=descending) - return Array._new(res[0]) diff --git a/heat/array_api/_statistical_functions.py b/heat/array_api/_statistical_functions.py deleted file mode 100644 index 11df80890f..0000000000 --- a/heat/array_api/_statistical_functions.py +++ /dev/null @@ -1,244 +0,0 @@ -from __future__ import annotations - -from ._dtypes import _numeric_dtypes, _floating_dtypes, _integer_dtypes, default_float, default_int -from ._array_object import Array - -from typing import TYPE_CHECKING, Optional, Tuple, Union - -if TYPE_CHECKING: - from ._typing import Dtype - -import heat as ht - - -def max( - x: Array, - /, - *, - axis: Optional[Union[int, Tuple[int, ...]]] = None, - keepdims: bool = False, -) -> Array: - """ - Calculates the maximum value of the input array ``x``. - - Parameters - ---------- - x : Array - Input array. Must have a numeric data type. - axis : Optional[Union[int, Tuple[int, ...]]] - Axis or axes along which maximum values are computed. By default, the maximum - value is computed over the entire array. If a tuple of integers, maximum - values are computed over multiple axes. Default: ``None``. - keepdims : bool - If ``True``, the reduced axes (dimensions) are included in the result as - singleton dimensions. Otherwise, if ``False``, the reduced axes - (dimensions) are be included in the result. Default: ``False``. - """ - if x.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in max") - res = ht.max(x._array, axis=axis, keepdim=keepdims) - return Array._new(res) - - -def mean( - x: Array, - /, - *, - axis: Optional[Union[int, Tuple[int, ...]]] = None, - keepdims: bool = False, -) -> Array: - """ - Calculates the arithmetic mean of the input array ``x``. - - Parameters - ---------- - x : Array - Input array. Must have a floating-point data type. - axis : Optional[Union[int, Tuple[int, ...]]] - Axis or axes along which arithmetic means are computed. By default, the mean - is computed over the entire array. If a tuple of integers, arithmetic means - are computed over multiple axes. Default: ``None``. - keepdims : bool - If ``True``, the reduced axes (dimensions) are included in the result as - singleton dimensions. Otherwise, if ``False``, the reduced axes - (dimensions) are be included in the result. Default: ``False``. - """ - if x.dtype not in _floating_dtypes: - raise TypeError("Only floating-point dtypes are allowed in mean") - if axis == (): - return x - res = ht.mean(x._array, axis=axis) - return Array._new(res.astype(x.dtype)) - - -def min( - x: Array, - /, - *, - axis: Optional[Union[int, Tuple[int, ...]]] = None, - keepdims: bool = False, -) -> Array: - """ - Calculates the minimum value of the input array ``x``. - - Parameters - ---------- - x : Array - Input array. Must have a numeric data type. - axis : Optional[Union[int, Tuple[int, ...]]] - Axis or axes along which minimum values are computed. By default, the minimum - value is computed over the entire array. If a tuple of integers, minimum - values are computed over multiple axes. Default: ``None``. - keepdims : bool - If ``True``, the reduced axes (dimensions) are included in the result as - singleton dimensions. Otherwise, if ``False``, the reduced axes - (dimensions) are be included in the result. Default: ``False``. - """ - if x.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in min") - res = ht.min(x._array, axis=axis, keepdim=keepdims) - return Array._new(res) - - -def prod( - x: Array, - /, - *, - axis: Optional[Union[int, Tuple[int, ...]]] = None, - dtype: Optional[Dtype] = None, - keepdims: bool = False, -) -> Array: - """ - Calculates the product of input array ``x`` elements. - - Parameters - ---------- - x : Array - Input array. Must have a numeric data type. - axis : Optional[Union[int, Tuple[int, ...]]] - Axis or axes along which products are computed. By default, the product is - computed over the entire array. If a tuple of integers, products are computed - over multiple axes. Default: ``None``. - dtype : Optional[Dtype] - Data type of the returned array. - keepdims : bool - If ``True``, the reduced axes (dimensions) are included in the result as - singleton dimensions. Otherwise, if ``False``, the reduced axes - (dimensions) are be included in the result. Default: ``False``. - """ - if x.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in prod") - res = ht.prod(x._array, axis=axis, keepdim=keepdims) - if dtype is None: - if x.dtype in _floating_dtypes: - dtype = default_float - elif x.dtype in _integer_dtypes: - dtype = default_int - if dtype is not None: - res.astype(dtype, copy=False) - return Array._new(res) - - -def std( - x: Array, - /, - *, - axis: Optional[Union[int, Tuple[int, ...]]] = None, - correction: Union[int, float] = 0.0, - keepdims: bool = False, -) -> Array: - """ - Calculates the standard deviation of the input array ``x``. - - Parameters - ---------- - x : Array - Input array. Must have a floating-point data type. - axis : Optional[Union[int, Tuple[int, ...]]] - Axis or axes along which standard deviations are computed. By default, the - standard deviation is computed over the entire array. If a tuple of integers, - standard deviations are computed over multiple axes. Default: ``None``. - correction : Union[int, float] - Degrees of freedom adjustment. - keepdims : bool - If ``True``, the reduced axes (dimensions) are included in the result as - singleton dimensions. Otherwise, if ``False``, the reduced axes - (dimensions) are be included in the result. Default: ``False``. - """ - if x.dtype not in _floating_dtypes: - raise TypeError("Only floating-point dtypes are allowed in std") - res = ht.std(x._array, axis=axis, ddof=int(correction)) - return Array._new(res) - - -def sum( - x: Array, - /, - *, - axis: Optional[Union[int, Tuple[int, ...]]] = None, - dtype: Optional[Dtype] = None, - keepdims: bool = False, -) -> Array: - """ - Calculates the sum of the input array ``x``. - - Parameters - ---------- - x : Array - Input array. Must have a numeric data type. - axis : Optional[Union[int, Tuple[int, ...]]] - Axis or axes along which sums are computed. By default, the sum is - computed over the entire array. If a tuple of integers, sums are computed - over multiple axes. Default: ``None``. - dtype : Optional[Dtype] - Data type of the returned array. - keepdims : bool - If ``True``, the reduced axes (dimensions) are included in the result as - singleton dimensions. Otherwise, if ``False``, the reduced axes - (dimensions) are be included in the result. Default: ``False``. - """ - if x.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in sum") - res = ht.sum(x._array, axis=axis, keepdim=keepdims) - if dtype is None: - if x.dtype in _floating_dtypes: - dtype = default_float - elif x.dtype in _integer_dtypes: - dtype = default_int - if dtype is not None: - res.astype(dtype, copy=False) - return Array._new(res) - - -def var( - x: Array, - /, - *, - axis: Optional[Union[int, Tuple[int, ...]]] = None, - correction: Union[int, float] = 0.0, - keepdims: bool = False, -) -> Array: - """ - Calculates the variance of the input array ``x``. - - Parameters - ---------- - x : Array - Input array. Must have a floating-point data type. - axis : Optional[Union[int, Tuple[int, ...]]] - Axis or axes along which variances are computed. By default, the - variance is computed over the entire array. If a tuple of integers, - variances are computed over multiple axes. Default: ``None``. - correction : Union[int, float] - Degrees of freedom adjustment. - keepdims : bool - If ``True``, the reduced axes (dimensions) are included in the result as - singleton dimensions. Otherwise, if ``False``, the reduced axes - (dimensions) are be included in the result. Default: ``False``. - """ - if x.dtype not in _floating_dtypes: - raise TypeError("Only floating-point dtypes are allowed in var") - if axis == (): - return x - res = ht.var(x._array, axis=axis, ddof=int(correction)) - return Array._new(res.astype(x.dtype)) diff --git a/heat/array_api/_typing.py b/heat/array_api/_typing.py deleted file mode 100644 index efbb37fc64..0000000000 --- a/heat/array_api/_typing.py +++ /dev/null @@ -1,35 +0,0 @@ -from typing import Union -from ._dtypes import ( - int8, - int16, - int32, - int64, - uint8, - # uint16, - # uint32, - # uint64, - float32, - float64, - bool, -) - -from heat.core.devices import Device, cpu - -try: - from heat.core.devices import gpu -except ImportError: - pass - -Dtype = Union[ - int8, - int16, - int32, - int64, - uint8, - # uint16, - # uint32, - # uint64, - float32, - float64, - bool, -] diff --git a/heat/array_api/_utility_functions.py b/heat/array_api/_utility_functions.py deleted file mode 100644 index ced0b3fda6..0000000000 --- a/heat/array_api/_utility_functions.py +++ /dev/null @@ -1,63 +0,0 @@ -from __future__ import annotations - -from ._array_object import Array - -from typing import Optional, Tuple, Union - -import heat as ht - - -def all( - x: Array, - /, - *, - axis: Optional[Union[int, Tuple[int, ...]]] = None, - keepdims: bool = False, -) -> Array: - """ - Tests whether all input array elements evaluate to ``True`` along a - specified axis. - - Parameters - ---------- - x : Array - Input array. - axis : Optional[Union[int, Tuple[int, ...]]] - Axis or axes along which to perform a logical AND reduction. By - default, a logical AND reduction is performed over the entire array. - keepdims : bool - If ``True``, the reduced axes (dimensions) are included in the result - as singleton dimensions. Otherwise, if ``False``, the reduced axes - (dimensions) are be included in the result. Default: ``False``. - """ - res = ht.all(x._array, axis=axis, keepdim=keepdims) - - return Array._new(res) - - -def any( - x: Array, - /, - *, - axis: Optional[Union[int, Tuple[int, ...]]] = None, - keepdims: bool = False, -) -> Array: - """ - Tests whether any input array element evaluates to ``True`` along a specified - axis. - - Parameters - ---------- - x : Array - Input array. - axis : Optional[Union[int, Tuple[int, ...]]] - Axis or axes along which to perform a logical OR reduction. By - default, a logical OR reduction is performed over the entire array. - keepdims : bool - If ``True``, the reduced axes (dimensions) are included in the result - as singleton dimensions. Otherwise, if ``False``, the reduced axes - (dimensions) are be included in the result. Default: ``False``. - """ - res = ht.any(x._array, axis=axis, keepdim=keepdims) - - return Array._new(res) diff --git a/heat/array_api/linalg.py b/heat/array_api/linalg.py deleted file mode 100644 index 8f74bad03d..0000000000 --- a/heat/array_api/linalg.py +++ /dev/null @@ -1,100 +0,0 @@ -""" -Linear Algebra Extension for the Array API standard. -""" - -from __future__ import annotations - -from ._dtypes import _numeric_dtypes, _result_type -from ._array_object import Array - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._typing import Sequence, Tuple, Union - -import heat as ht - - -def matmul(x1: Array, x2: Array, /) -> Array: - """ - Computes the matrix product. - - Parameters - ---------- - x1 : Array - First input array. Must have a numeric data type and at least one dimension. - x2 : Array - Second input array. Must have a numeric data type and at least one dimension. - """ - if x1.dtype not in _numeric_dtypes or x2.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in matmul") - return Array._new(ht.matmul(x1._array, x2._array)) - - -def matrix_transpose(x: Array, /) -> Array: - """ - Transposes a matrix (or a stack of matrices) ``x``. - - Parameters - ---------- - x : Array - Input array having shape ``(..., M, N)`` and whose innermost two - dimensions form ``MxN`` matrices. - """ - if x.ndim < 2: - raise ValueError("x must be at least 2-dimensional for matrix_transpose") - return Array._new(ht.swapaxes(x._array, -1, -2)) - - -def tensordot( - x1: Array, x2: Array, /, *, axes: Union[int, Tuple[Sequence[int], Sequence[int]]] = 2 -) -> Array: - """ - Return a tensor contraction of ``x1`` and ``x2`` over specific axes. - - Parameters - ---------- - x1 : Array - First input array. Must have a numeric data type. - x2 : Array - Second input array. Must have a numeric data type. Corresponding contracted axes of ``x1`` - and ``x2`` must be equal. - axes : Union[int, Tuple[Sequence[int], Sequence[int]]] - Number of axes (dimensions) to contract or explicit sequences of axes (dimensions) for - ``x1`` and ``x2``, respectively. If ``axes`` is an ``int`` equal to ``N``, then contraction is - performed over the last ``N`` axes of ``x1`` and the first ``N`` axes of ``x2`` in order. - The size of each corresponding axis (dimension) must match. Must be nonnegative. - If ``axes`` is a tuple of two sequences ``(x1_axes, x2_axes)``, the first sequence must apply - to ``x1`` and the second sequence to ``x2``. Both sequences must have the same length. - Each axis (dimension) ``x1_axes[i]`` for ``x1`` must have the same size as the respective axis - (dimension) ``x2_axes[i]`` for ``x2``. Each sequence must consist of unique (nonnegative) - integers that specify valid axes for each respective array. - """ - if x1.dtype not in _numeric_dtypes or x2.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in tensordot") - return Array._new(ht.tensordot(x1._array, x2._array, axes=axes)) - - -def vecdot(x1: Array, x2: Array, /, *, axis: int = -1) -> Array: - """ - Computes the (vector) dot product of two arrays. - - Parameters - ---------- - x1 : Array - First input array. Must have a numeric data type. - x2 : Array - Second input array. Must be compatible with ``x1`` and have a numeric data type. - axis : int - Axis over which to compute the dot product. Must be an integer on the interval - ``[-N, N)``, where ``N`` is the rank (number of dimensions) of the shape - determined according to Broadcasting. If specified as a negative integer, the - function determines the axis along which to compute the dot product by counting - backward from the last dimension (where ``-1`` refers to the last dimension). - By default, the function computes the dot product over the last axis. - Default: ``-1``. - """ - if x1.dtype not in _numeric_dtypes or x2.dtype not in _numeric_dtypes: - raise TypeError("Only numeric dtypes are allowed in vecdot") - res = ht.vecdot(x1._array, x2._array, axis=axis) - return Array._new(res.astype(_result_type(x1.dtype, x2.dtype))) diff --git a/heat/array_api/test/skips.txt b/heat/array_api/test/skips.txt deleted file mode 100644 index 3fb57d77f3..0000000000 --- a/heat/array_api/test/skips.txt +++ /dev/null @@ -1,89 +0,0 @@ -# fails sometimes -array_api_tests/test_creation_functions.py::test_asarray_scalars -array_api_tests/test_linalg.py::test_matmul -array_api_tests/test_manipulation_functions.py::test_concat -array_api_tests/test_manipulation_functions.py::test_expand_dims -array_api_tests/test_manipulation_functions.py::test_squeeze -array_api_tests/test_manipulation_functions.py::test_flip -array_api_tests/test_manipulation_functions.py::test_permute_dims -array_api_tests/test_manipulation_functions.py::test_roll -array_api_tests/test_manipulation_functions.py::test_stack -array_api_tests/test_operators_and_elementwise_functions.py::test_add[add(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_add[__add__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_add[__add__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_add[__iadd__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_add[__iadd__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_atan2 -array_api_tests/test_operators_and_elementwise_functions.py::test_ceil -array_api_tests/test_operators_and_elementwise_functions.py::test_equal[equal(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_equal[__eq__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_equal[__eq__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_floor -array_api_tests/test_operators_and_elementwise_functions.py::test_greater[greater(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_greater[__gt__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_greater[__gt__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_greater_equal[greater_equal(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_greater_equal[__ge__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_greater_equal[__ge__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_isfinite -array_api_tests/test_operators_and_elementwise_functions.py::test_isinf -array_api_tests/test_operators_and_elementwise_functions.py::test_isnan -array_api_tests/test_operators_and_elementwise_functions.py::test_less[less(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_less[__lt__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_less[__lt__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_less_equal[less_equal(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_less_equal[__le__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_less_equal[__le__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_log2 -array_api_tests/test_operators_and_elementwise_functions.py::test_logaddexp -array_api_tests/test_operators_and_elementwise_functions.py::test_multiply[multiply(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_multiply[__mul__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_multiply[__mul__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_multiply[__imul__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_multiply[__imul__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_not_equal[not_equal(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_not_equal[__ne__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_not_equal[__ne__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_pow[__pow__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_pow[__ipow__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_round -array_api_tests/test_operators_and_elementwise_functions.py::test_sign -array_api_tests/test_operators_and_elementwise_functions.py::test_square -array_api_tests/test_operators_and_elementwise_functions.py::test_subtract[subtract(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_subtract[__sub__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_subtract[__sub__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_subtract[__isub__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_subtract[__isub__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_trunc -array_api_tests/test_searching_functions.py::test_where -array_api_tests/test_set_functions.py::test_unique_inverse -array_api_tests/test_set_functions.py::test_unique_values -array_api_tests/test_special_cases.py::test_unary[acos(x_i < -1) -> NaN] -array_api_tests/test_special_cases.py::test_unary[acos(x_i > 1) -> NaN] -array_api_tests/test_special_cases.py::test_unary[asin(x_i > 1) -> NaN] -array_api_tests/test_special_cases.py::test_unary[asin(x_i < -1) -> NaN] -array_api_tests/test_special_cases.py::test_unary[atanh(x_i < -1) -> NaN] -array_api_tests/test_special_cases.py::test_unary[ceil(x_i.is_integer()) -> x_i] -array_api_tests/test_special_cases.py::test_unary[floor(x_i.is_integer()) -> x_i] -array_api_tests/test_special_cases.py::test_unary[log(x_i < 0) -> NaN] -array_api_tests/test_special_cases.py::test_unary[log2(x_i < 0) -> NaN] -array_api_tests/test_special_cases.py::test_unary[log10(x_i < 0) -> NaN] -array_api_tests/test_special_cases.py::test_unary[round(x_i.is_integer()) -> x_i] -array_api_tests/test_special_cases.py::test_unary[round(modf(i)[0] == 0.5) -> Decimal(i).to_integral_exact(ROUND_HALF_EVEN)] -array_api_tests/test_special_cases.py::test_unary[sign(x_i < 0) -> -1] -array_api_tests/test_special_cases.py::test_unary[sign(x_i > 0) -> +1] -array_api_tests/test_special_cases.py::test_unary[sqrt(x_i < 0) -> NaN] -array_api_tests/test_special_cases.py::test_unary[trunc(x_i.is_integer()) -> x_i] -array_api_tests/test_special_cases.py::test_binary[add((x1_i is +0 or x1_i == -0) and isfinite(x2_i) and x2_i != 0) -> x2_i] -array_api_tests/test_special_cases.py::test_binary[add(isfinite(x1_i) and x1_i != 0 and (x2_i is +0 or x2_i == -0)) -> x1_i] -array_api_tests/test_special_cases.py::test_binary[add(isfinite(x1_i) and x1_i != 0 and x2_i == -x1_i) -> +0] -array_api_tests/test_special_cases.py::test_binary[__add__((x1_i is +0 or x1_i == -0) and isfinite(x2_i) and x2_i != 0) -> x2_i] -array_api_tests/test_special_cases.py::test_binary[__add__(isfinite(x1_i) and x1_i != 0 and (x2_i is +0 or x2_i == -0)) -> x1_i] -array_api_tests/test_special_cases.py::test_binary[__add__(isfinite(x1_i) and x1_i != 0 and x2_i == -x1_i) -> +0] -array_api_tests/test_special_cases.py::test_binary[pow(x1_i < 0 and isfinite(x1_i) and isfinite(x2_i) and not x2_i.is_integer()) -> NaN] -array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i is NaN and not x2_i == 0) -> NaN] -array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i < 0 and isfinite(x1_i) and isfinite(x2_i) and not x2_i.is_integer()) -> NaN] -array_api_tests/test_special_cases.py::test_iop[__iadd__((x1_i is +0 or x1_i == -0) and isfinite(x2_i) and x2_i != 0) -> x2_i] -array_api_tests/test_special_cases.py::test_iop[__iadd__(isfinite(x1_i) and x1_i != 0 and (x2_i is +0 or x2_i == -0)) -> x1_i] -array_api_tests/test_special_cases.py::test_iop[__iadd__(isfinite(x1_i) and x1_i != 0 and x2_i == -x1_i) -> +0] -array_api_tests/test_special_cases.py::test_iop[__ipow__(x1_i < 0 and isfinite(x1_i) and isfinite(x2_i) and not x2_i.is_integer()) -> NaN] diff --git a/heat/array_api/test/xfails.txt b/heat/array_api/test/xfails.txt deleted file mode 100644 index a69262c2c4..0000000000 --- a/heat/array_api/test/xfails.txt +++ /dev/null @@ -1,269 +0,0 @@ -# fails every time -array_api_tests/test_array_object.py::test_getitem -array_api_tests/test_array_object.py::test_setitem -array_api_tests/test_array_object.py::test_getitem_masking -array_api_tests/test_array_object.py::test_setitem_masking -array_api_tests/test_array_object.py::test_getitem_arrays_and_ints_1[None] -array_api_tests/test_array_object.py::test_getitem_arrays_and_ints_2[None] -array_api_tests/test_creation_functions.py::test_asarray_arrays -array_api_tests/test_creation_functions.py::test_empty -array_api_tests/test_creation_functions.py::test_empty_like -array_api_tests/test_creation_functions.py::test_eye -array_api_tests/test_creation_functions.py::test_full -array_api_tests/test_creation_functions.py::test_full_like -array_api_tests/test_creation_functions.py::test_linspace -array_api_tests/test_creation_functions.py::test_meshgrid -array_api_tests/test_creation_functions.py::test_ones -array_api_tests/test_creation_functions.py::test_ones_like -array_api_tests/test_creation_functions.py::test_tril -array_api_tests/test_creation_functions.py::test_triu -array_api_tests/test_creation_functions.py::test_zeros -array_api_tests/test_creation_functions.py::test_zeros_like -array_api_tests/test_has_names.py::test_has_names[linalg-cholesky] -array_api_tests/test_has_names.py::test_has_names[linalg-cross] -array_api_tests/test_has_names.py::test_has_names[linalg-det] -array_api_tests/test_has_names.py::test_has_names[linalg-diagonal] -array_api_tests/test_has_names.py::test_has_names[linalg-eigh] -array_api_tests/test_has_names.py::test_has_names[linalg-eigvalsh] -array_api_tests/test_has_names.py::test_has_names[linalg-inv] -array_api_tests/test_has_names.py::test_has_names[linalg-matrix_norm] -array_api_tests/test_has_names.py::test_has_names[linalg-matrix_power] -array_api_tests/test_has_names.py::test_has_names[linalg-matrix_rank] -array_api_tests/test_has_names.py::test_has_names[linalg-outer] -array_api_tests/test_has_names.py::test_has_names[linalg-pinv] -array_api_tests/test_has_names.py::test_has_names[linalg-qr] -array_api_tests/test_has_names.py::test_has_names[linalg-slogdet] -array_api_tests/test_has_names.py::test_has_names[linalg-solve] -array_api_tests/test_has_names.py::test_has_names[linalg-svd] -array_api_tests/test_has_names.py::test_has_names[linalg-svdvals] -array_api_tests/test_has_names.py::test_has_names[linalg-trace] -array_api_tests/test_has_names.py::test_has_names[linalg-vector_norm] -array_api_tests/test_has_names.py::test_has_names[fft-fft] -array_api_tests/test_has_names.py::test_has_names[fft-ifft] -array_api_tests/test_has_names.py::test_has_names[fft-fftn] -array_api_tests/test_has_names.py::test_has_names[fft-ifftn] -array_api_tests/test_has_names.py::test_has_names[fft-rfft] -array_api_tests/test_has_names.py::test_has_names[fft-irfft] -array_api_tests/test_has_names.py::test_has_names[fft-rfftn] -array_api_tests/test_has_names.py::test_has_names[fft-irfftn] -array_api_tests/test_has_names.py::test_has_names[fft-hfft] -array_api_tests/test_has_names.py::test_has_names[fft-ihfft] -array_api_tests/test_has_names.py::test_has_names[fft-fftfreq] -array_api_tests/test_has_names.py::test_has_names[fft-rfftfreq] -array_api_tests/test_has_names.py::test_has_names[fft-fftshift] -array_api_tests/test_has_names.py::test_has_names[fft-ifftshift] -array_api_tests/test_has_names.py::test_has_names[indexing-take] -array_api_tests/test_has_names.py::test_has_names[set-unique_all] -array_api_tests/test_has_names.py::test_has_names[set-unique_counts] -array_api_tests/test_has_names.py::test_has_names[manipulation-moveaxis] -array_api_tests/test_has_names.py::test_has_names[manipulation-repeat] -array_api_tests/test_has_names.py::test_has_names[manipulation-tile] -array_api_tests/test_has_names.py::test_has_names[manipulation-unstack] -array_api_tests/test_has_names.py::test_has_names[searching-searchsorted] -array_api_tests/test_has_names.py::test_has_names[elementwise-clip] -array_api_tests/test_has_names.py::test_has_names[elementwise-conj] -array_api_tests/test_has_names.py::test_has_names[elementwise-copysign] -array_api_tests/test_has_names.py::test_has_names[elementwise-hypot] -array_api_tests/test_has_names.py::test_has_names[elementwise-imag] -array_api_tests/test_has_names.py::test_has_names[elementwise-maximum] -array_api_tests/test_has_names.py::test_has_names[elementwise-minimum] -array_api_tests/test_has_names.py::test_has_names[elementwise-real] -array_api_tests/test_has_names.py::test_has_names[elementwise-signbit] -array_api_tests/test_has_names.py::test_has_names[statistical-cumulative_sum] -array_api_tests/test_has_names.py::test_has_names[sorting-argsort] -array_api_tests/test_has_names.py::test_has_names[data_type-isdtype] -array_api_tests/test_has_names.py::test_has_names[info-__array_namespace_info__] -array_api_tests/test_has_names.py::test_has_names[array_method-__complex__] -array_api_tests/test_indexing_functions.py::test_take -array_api_tests/test_inspection_functions.py::test_array_namespace_info -array_api_tests/test_inspection_functions.py::test_array_namespace_info_dtypes -array_api_tests/test_linalg.py::test_matrix_transpose -array_api_tests/test_linalg.py::test_tensordot -array_api_tests/test_linalg.py::test_vecdot -array_api_tests/test_manipulation_functions.py::test_moveaxis -array_api_tests/test_manipulation_functions.py::test_repeat -array_api_tests/test_manipulation_functions.py::test_tile -array_api_tests/test_manipulation_functions.py::test_unstack -array_api_tests/test_operators_and_elementwise_functions.py::test_abs[abs] -array_api_tests/test_operators_and_elementwise_functions.py::test_abs[__abs__] -array_api_tests/test_operators_and_elementwise_functions.py::test_acos -array_api_tests/test_operators_and_elementwise_functions.py::test_acosh -array_api_tests/test_operators_and_elementwise_functions.py::test_asin -array_api_tests/test_operators_and_elementwise_functions.py::test_asinh -array_api_tests/test_operators_and_elementwise_functions.py::test_atan -array_api_tests/test_operators_and_elementwise_functions.py::test_atanh -array_api_tests/test_operators_and_elementwise_functions.py::test_bitwise_left_shift[bitwise_left_shift(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_bitwise_left_shift[__lshift__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_bitwise_left_shift[__ilshift__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_bitwise_right_shift[bitwise_right_shift(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_bitwise_right_shift[__rshift__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_bitwise_right_shift[__irshift__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_clip -array_api_tests/test_operators_and_elementwise_functions.py::test_conj -array_api_tests/test_operators_and_elementwise_functions.py::test_copysign -array_api_tests/test_operators_and_elementwise_functions.py::test_cos -array_api_tests/test_operators_and_elementwise_functions.py::test_cosh -array_api_tests/test_operators_and_elementwise_functions.py::test_divide[divide(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_divide[__truediv__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_divide[__truediv__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_divide[__itruediv__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_divide[__itruediv__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_exp -array_api_tests/test_operators_and_elementwise_functions.py::test_expm1 -array_api_tests/test_operators_and_elementwise_functions.py::test_floor_divide[floor_divide(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_floor_divide[__floordiv__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_floor_divide[__floordiv__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_floor_divide[__ifloordiv__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_floor_divide[__ifloordiv__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_hypot -array_api_tests/test_operators_and_elementwise_functions.py::test_imag -array_api_tests/test_operators_and_elementwise_functions.py::test_log -array_api_tests/test_operators_and_elementwise_functions.py::test_log1p -array_api_tests/test_operators_and_elementwise_functions.py::test_log10 -array_api_tests/test_operators_and_elementwise_functions.py::test_maximum -array_api_tests/test_operators_and_elementwise_functions.py::test_minimum -array_api_tests/test_operators_and_elementwise_functions.py::test_negative[negative] -array_api_tests/test_operators_and_elementwise_functions.py::test_negative[__neg__] -array_api_tests/test_operators_and_elementwise_functions.py::test_positive[positive] -array_api_tests/test_operators_and_elementwise_functions.py::test_positive[__pos__] -array_api_tests/test_operators_and_elementwise_functions.py::test_pow[pow(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_pow[__pow__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_pow[__ipow__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_real -array_api_tests/test_operators_and_elementwise_functions.py::test_signbit -array_api_tests/test_operators_and_elementwise_functions.py::test_sin -array_api_tests/test_operators_and_elementwise_functions.py::test_sinh -array_api_tests/test_operators_and_elementwise_functions.py::test_sqrt -array_api_tests/test_operators_and_elementwise_functions.py::test_tan -array_api_tests/test_operators_and_elementwise_functions.py::test_tanh -array_api_tests/test_searching_functions.py::test_argmax -array_api_tests/test_searching_functions.py::test_argmin -array_api_tests/test_searching_functions.py::test_nonzero_zerodim_error -array_api_tests/test_searching_functions.py::test_nonzero -array_api_tests/test_searching_functions.py::test_searchsorted -array_api_tests/test_set_functions.py::test_unique_all -array_api_tests/test_set_functions.py::test_unique_counts -array_api_tests/test_signatures.py::test_func_signature[from_dlpack] -array_api_tests/test_signatures.py::test_func_signature[take] -array_api_tests/test_signatures.py::test_func_signature[unique_all] -array_api_tests/test_signatures.py::test_func_signature[unique_counts] -array_api_tests/test_signatures.py::test_func_signature[moveaxis] -array_api_tests/test_signatures.py::test_func_signature[repeat] -array_api_tests/test_signatures.py::test_func_signature[tile] -array_api_tests/test_signatures.py::test_func_signature[unstack] -array_api_tests/test_signatures.py::test_func_signature[searchsorted] -array_api_tests/test_signatures.py::test_func_signature[clip] -array_api_tests/test_signatures.py::test_func_signature[conj] -array_api_tests/test_signatures.py::test_func_signature[copysign] -array_api_tests/test_signatures.py::test_func_signature[hypot] -array_api_tests/test_signatures.py::test_func_signature[imag] -array_api_tests/test_signatures.py::test_func_signature[maximum] -array_api_tests/test_signatures.py::test_func_signature[minimum] -array_api_tests/test_signatures.py::test_func_signature[real] -array_api_tests/test_signatures.py::test_func_signature[signbit] -array_api_tests/test_signatures.py::test_func_signature[cumulative_sum] -array_api_tests/test_signatures.py::test_func_signature[argsort] -array_api_tests/test_signatures.py::test_func_signature[astype] -array_api_tests/test_signatures.py::test_func_signature[isdtype] -array_api_tests/test_signatures.py::test_func_signature[__array_namespace_info__] -array_api_tests/test_signatures.py::test_array_method_signature[__complex__] -array_api_tests/test_signatures.py::test_array_method_signature[__dlpack__] -array_api_tests/test_signatures.py::test_info_func_signature[capabilities] -array_api_tests/test_signatures.py::test_info_func_signature[default_device] -array_api_tests/test_signatures.py::test_info_func_signature[default_dtypes] -array_api_tests/test_signatures.py::test_info_func_signature[devices] -array_api_tests/test_signatures.py::test_info_func_signature[dtypes] -array_api_tests/test_sorting_functions.py::test_argsort -array_api_tests/test_sorting_functions.py::test_sort -array_api_tests/test_special_cases.py::test_unary[isfinite((x_i is +infinity or x_i == -infinity)) -> False] -array_api_tests/test_special_cases.py::test_unary[isfinite(x_i is NaN) -> False] -array_api_tests/test_special_cases.py::test_unary[isfinite(isfinite(x_i)) -> True] -array_api_tests/test_special_cases.py::test_unary[isinf((x_i is +infinity or x_i == -infinity)) -> True] -array_api_tests/test_special_cases.py::test_unary[isnan(x_i is NaN) -> True] -array_api_tests/test_special_cases.py::test_unary[sign(x_i is NaN) -> NaN] -array_api_tests/test_special_cases.py::test_unary[signbit(x_i is +0) -> False] -array_api_tests/test_special_cases.py::test_unary[signbit(x_i is -0) -> True] -array_api_tests/test_special_cases.py::test_unary[signbit(x_i is +infinity) -> False] -array_api_tests/test_special_cases.py::test_unary[signbit(x_i is -infinity) -> True] -array_api_tests/test_special_cases.py::test_unary[signbit(isfinite(x_i) and x_i > 0) -> False] -array_api_tests/test_special_cases.py::test_unary[signbit(isfinite(x_i) and x_i < 0) -> True] -array_api_tests/test_special_cases.py::test_unary[signbit(x_i is +NaN) -> False] -array_api_tests/test_special_cases.py::test_unary[signbit(x_i is -NaN) -> True] -array_api_tests/test_special_cases.py::test_binary[copysign(x1_i is NaN and x2_i < 0) -> NaN] -array_api_tests/test_special_cases.py::test_binary[copysign(x1_i is NaN and x2_i is -0) -> NaN] -array_api_tests/test_special_cases.py::test_binary[copysign(x1_i is NaN and x2_i is +0) -> NaN] -array_api_tests/test_special_cases.py::test_binary[copysign(x1_i is NaN and x2_i > 0) -> NaN] -array_api_tests/test_special_cases.py::test_binary[divide(x1_i is +0 and x2_i > 0) -> +0] -array_api_tests/test_special_cases.py::test_binary[divide(x1_i is -0 and x2_i > 0) -> -0] -array_api_tests/test_special_cases.py::test_binary[divide(x1_i is +0 and x2_i < 0) -> -0] -array_api_tests/test_special_cases.py::test_binary[divide(x1_i is -0 and x2_i < 0) -> +0] -array_api_tests/test_special_cases.py::test_binary[divide(x1_i > 0 and x2_i is +0) -> +infinity] -array_api_tests/test_special_cases.py::test_binary[divide(x1_i > 0 and x2_i is -0) -> -infinity] -array_api_tests/test_special_cases.py::test_binary[divide(x1_i < 0 and x2_i is +0) -> -infinity] -array_api_tests/test_special_cases.py::test_binary[divide(x1_i < 0 and x2_i is -0) -> +infinity] -array_api_tests/test_special_cases.py::test_binary[__truediv__(x1_i is +0 and x2_i > 0) -> +0] -array_api_tests/test_special_cases.py::test_binary[__truediv__(x1_i is -0 and x2_i > 0) -> -0] -array_api_tests/test_special_cases.py::test_binary[__truediv__(x1_i is +0 and x2_i < 0) -> -0] -array_api_tests/test_special_cases.py::test_binary[__truediv__(x1_i is -0 and x2_i < 0) -> +0] -array_api_tests/test_special_cases.py::test_binary[__truediv__(x1_i > 0 and x2_i is +0) -> +infinity] -array_api_tests/test_special_cases.py::test_binary[__truediv__(x1_i > 0 and x2_i is -0) -> -infinity] -array_api_tests/test_special_cases.py::test_binary[__truediv__(x1_i < 0 and x2_i is +0) -> -infinity] -array_api_tests/test_special_cases.py::test_binary[__truediv__(x1_i < 0 and x2_i is -0) -> +infinity] -array_api_tests/test_special_cases.py::test_binary[maximum(x1_i is NaN or x2_i is NaN) -> NaN] -array_api_tests/test_special_cases.py::test_binary[minimum(x1_i is NaN or x2_i is NaN) -> NaN] -array_api_tests/test_special_cases.py::test_binary[pow(abs(x1_i) > 1 and x2_i is +infinity) -> +infinity] -array_api_tests/test_special_cases.py::test_binary[pow(abs(x1_i) > 1 and x2_i is -infinity) -> +0] -array_api_tests/test_special_cases.py::test_binary[pow(x1_i is +infinity and x2_i > 0) -> +infinity] -array_api_tests/test_special_cases.py::test_binary[pow(x1_i is +infinity and x2_i < 0) -> +0] -array_api_tests/test_special_cases.py::test_binary[pow(x1_i is -infinity and x2_i > 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +infinity] -array_api_tests/test_special_cases.py::test_binary[pow(x1_i is -infinity and x2_i < 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +0] -array_api_tests/test_special_cases.py::test_binary[pow(x1_i is +0 and x2_i > 0) -> +0] -array_api_tests/test_special_cases.py::test_binary[pow(x1_i is +0 and x2_i < 0) -> +infinity] -array_api_tests/test_special_cases.py::test_binary[pow(x1_i is -0 and x2_i > 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +0] -array_api_tests/test_special_cases.py::test_binary[pow(x1_i is -0 and x2_i < 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +infinity] -array_api_tests/test_special_cases.py::test_binary[__pow__(abs(x1_i) > 1 and x2_i is +infinity) -> +infinity] -array_api_tests/test_special_cases.py::test_binary[__pow__(abs(x1_i) > 1 and x2_i is -infinity) -> +0] -array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i is +infinity and x2_i > 0) -> +infinity] -array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i is +infinity and x2_i < 0) -> +0] -array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i is -infinity and x2_i > 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +infinity] -array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i is -infinity and x2_i < 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +0] -array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i is +0 and x2_i > 0) -> +0] -array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i is +0 and x2_i < 0) -> +infinity] -array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i is -0 and x2_i > 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +0] -array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i is -0 and x2_i < 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +infinity] -array_api_tests/test_special_cases.py::test_iop[__itruediv__(x1_i is +0 and x2_i > 0) -> +0] -array_api_tests/test_special_cases.py::test_iop[__itruediv__(x1_i is -0 and x2_i > 0) -> -0] -array_api_tests/test_special_cases.py::test_iop[__itruediv__(x1_i is +0 and x2_i < 0) -> -0] -array_api_tests/test_special_cases.py::test_iop[__itruediv__(x1_i is -0 and x2_i < 0) -> +0] -array_api_tests/test_special_cases.py::test_iop[__itruediv__(x1_i > 0 and x2_i is +0) -> +infinity] -array_api_tests/test_special_cases.py::test_iop[__itruediv__(x1_i > 0 and x2_i is -0) -> -infinity] -array_api_tests/test_special_cases.py::test_iop[__itruediv__(x1_i < 0 and x2_i is +0) -> -infinity] -array_api_tests/test_special_cases.py::test_iop[__itruediv__(x1_i < 0 and x2_i is -0) -> +infinity] -array_api_tests/test_special_cases.py::test_iop[__ipow__(abs(x1_i) > 1 and x2_i is +infinity) -> +infinity] -array_api_tests/test_special_cases.py::test_iop[__ipow__(abs(x1_i) > 1 and x2_i is -infinity) -> +0] -array_api_tests/test_special_cases.py::test_iop[__ipow__(x1_i is +infinity and x2_i > 0) -> +infinity] -array_api_tests/test_special_cases.py::test_iop[__ipow__(x1_i is +infinity and x2_i < 0) -> +0] -array_api_tests/test_special_cases.py::test_iop[__ipow__(x1_i is -infinity and x2_i > 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +infinity] -array_api_tests/test_special_cases.py::test_iop[__ipow__(x1_i is -infinity and x2_i < 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +0] -array_api_tests/test_special_cases.py::test_iop[__ipow__(x1_i is +0 and x2_i > 0) -> +0] -array_api_tests/test_special_cases.py::test_iop[__ipow__(x1_i is +0 and x2_i < 0) -> +infinity] -array_api_tests/test_special_cases.py::test_iop[__ipow__(x1_i is -0 and x2_i > 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +0] -array_api_tests/test_special_cases.py::test_iop[__ipow__(x1_i is -0 and x2_i < 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +infinity] -array_api_tests/test_special_cases.py::test_empty_arrays[prod] -array_api_tests/test_special_cases.py::test_empty_arrays[std] -array_api_tests/test_special_cases.py::test_empty_arrays[sum] -array_api_tests/test_special_cases.py::test_nan_propagation[max] -array_api_tests/test_special_cases.py::test_nan_propagation[mean] -array_api_tests/test_special_cases.py::test_nan_propagation[min] -array_api_tests/test_special_cases.py::test_nan_propagation[prod] -array_api_tests/test_special_cases.py::test_nan_propagation[std] -array_api_tests/test_special_cases.py::test_nan_propagation[sum] -array_api_tests/test_special_cases.py::test_nan_propagation[var] -array_api_tests/test_statistical_functions.py::test_cumulative_sum -array_api_tests/test_statistical_functions.py::test_max -array_api_tests/test_statistical_functions.py::test_mean -array_api_tests/test_statistical_functions.py::test_min -array_api_tests/test_statistical_functions.py::test_prod -array_api_tests/test_statistical_functions.py::test_sum -array_api_tests/test_utility_functions.py::test_all -array_api_tests/test_utility_functions.py::test_any From 0320dd84b1d495db2d524ceae924d616d0bfa368 Mon Sep 17 00:00:00 2001 From: mtar <18899420+mtar@users.noreply.github.com> Date: Tue, 1 Sep 2026 08:54:53 +0200 Subject: [PATCH 4/8] update skipping paths --- .github/workflows/array-api.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/array-api.yml b/.github/workflows/array-api.yml index e41499ffe3..f59d791117 100644 --- a/.github/workflows/array-api.yml +++ b/.github/workflows/array-api.yml @@ -45,4 +45,4 @@ jobs: export PYTHONPATH="${GITHUB_WORKSPACE}/heat" # Skip testing functions with known issues cd ${GITHUB_WORKSPACE}/array-api-tests - pytest array_api_tests/ -v -rxXfE --ci --xfails-file ${GITHUB_WORKSPACE}/heat/heat/array_api/test/xfails.txt --skips-file ${GITHUB_WORKSPACE}/heat/heat/array_api/test/skips.txt --disable-extension linalg --disable-extension fft + pytest array_api_tests/ -v -rxXfE --ci --xfails-file ${GITHUB_WORKSPACE}/heat/.github/array_api_test/xfails.txt --skips-file ${GITHUB_WORKSPACE}/heat/.github/array_api_test/test/skips.txt --disable-extension linalg --disable-extension fft From e8648c4c727649ca2af04cb91901a538746b23cc Mon Sep 17 00:00:00 2001 From: mtar <18899420+mtar@users.noreply.github.com> Date: Tue, 1 Sep 2026 10:26:01 +0200 Subject: [PATCH 5/8] short path one dir --- .github/workflows/array-api.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/array-api.yml b/.github/workflows/array-api.yml index f59d791117..287668f4bb 100644 --- a/.github/workflows/array-api.yml +++ b/.github/workflows/array-api.yml @@ -45,4 +45,4 @@ jobs: export PYTHONPATH="${GITHUB_WORKSPACE}/heat" # Skip testing functions with known issues cd ${GITHUB_WORKSPACE}/array-api-tests - pytest array_api_tests/ -v -rxXfE --ci --xfails-file ${GITHUB_WORKSPACE}/heat/.github/array_api_test/xfails.txt --skips-file ${GITHUB_WORKSPACE}/heat/.github/array_api_test/test/skips.txt --disable-extension linalg --disable-extension fft + pytest array_api_tests/ -v -rxXfE --ci --xfails-file ${GITHUB_WORKSPACE}/.github/array_api_test/xfails.txt --skips-file ${GITHUB_WORKSPACE}/.github/array_api_test/test/skips.txt --disable-extension linalg --disable-extension fft From eb4f80ce1c08b6063c15d651bd719b69a1dfafd5 Mon Sep 17 00:00:00 2001 From: mtar <18899420+mtar@users.noreply.github.com> Date: Tue, 1 Sep 2026 15:15:00 +0200 Subject: [PATCH 6/8] fix path sktps.txt --- .github/workflows/array-api.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/array-api.yml b/.github/workflows/array-api.yml index 287668f4bb..10f6931153 100644 --- a/.github/workflows/array-api.yml +++ b/.github/workflows/array-api.yml @@ -45,4 +45,4 @@ jobs: export PYTHONPATH="${GITHUB_WORKSPACE}/heat" # Skip testing functions with known issues cd ${GITHUB_WORKSPACE}/array-api-tests - pytest array_api_tests/ -v -rxXfE --ci --xfails-file ${GITHUB_WORKSPACE}/.github/array_api_test/xfails.txt --skips-file ${GITHUB_WORKSPACE}/.github/array_api_test/test/skips.txt --disable-extension linalg --disable-extension fft + pytest array_api_tests/ -v -rxXfE --ci --xfails-file ${GITHUB_WORKSPACE}/.github/array_api_test/xfails.txt --skips-file ${GITHUB_WORKSPACE}/.github/array_api_test/skips.txt --disable-extension linalg --disable-extension fft From 3c4cd9aa6f0ac1750b4a64359852acce74aa5b6f Mon Sep 17 00:00:00 2001 From: mtar <18899420+mtar@users.noreply.github.com> Date: Tue, 1 Sep 2026 15:15:55 +0200 Subject: [PATCH 7/8] delete array_api in agents.md --- AGENTS.md | 1 - 1 file changed, 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index c78a936d74..63115ff641 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -25,7 +25,6 @@ - Do not install missing dependencies and do not edit any files by yourself. First check whether an environment is active. If not load the environment and try the tests again. Otherwise ask for permission. ## Project Structure -- `heat/array_api` - Additional module following Python array API standard. Only look when asked for the module explicitly. - `heat/classification` - Classification models like kneighbours - `heat/cluster` - Clustering models like kmeans, kmedians, kmediods, and spectral clustering - `heat/core` - DNDarray class and numeric functions From d784622cd5a9bdb46704866933272a81f3edf53f Mon Sep 17 00:00:00 2001 From: mtar <18899420+mtar@users.noreply.github.com> Date: Tue, 1 Sep 2026 15:35:17 +0200 Subject: [PATCH 8/8] remove skips.txt and xfails.txt --- .github/array_api_test/skips.txt | 89 ---------- .github/array_api_test/xfails.txt | 269 ------------------------------ .github/workflows/array-api.yml | 2 +- 3 files changed, 1 insertion(+), 359 deletions(-) delete mode 100644 .github/array_api_test/skips.txt delete mode 100644 .github/array_api_test/xfails.txt diff --git a/.github/array_api_test/skips.txt b/.github/array_api_test/skips.txt deleted file mode 100644 index 3fb57d77f3..0000000000 --- a/.github/array_api_test/skips.txt +++ /dev/null @@ -1,89 +0,0 @@ -# fails sometimes -array_api_tests/test_creation_functions.py::test_asarray_scalars -array_api_tests/test_linalg.py::test_matmul -array_api_tests/test_manipulation_functions.py::test_concat -array_api_tests/test_manipulation_functions.py::test_expand_dims -array_api_tests/test_manipulation_functions.py::test_squeeze -array_api_tests/test_manipulation_functions.py::test_flip -array_api_tests/test_manipulation_functions.py::test_permute_dims -array_api_tests/test_manipulation_functions.py::test_roll -array_api_tests/test_manipulation_functions.py::test_stack -array_api_tests/test_operators_and_elementwise_functions.py::test_add[add(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_add[__add__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_add[__add__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_add[__iadd__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_add[__iadd__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_atan2 -array_api_tests/test_operators_and_elementwise_functions.py::test_ceil -array_api_tests/test_operators_and_elementwise_functions.py::test_equal[equal(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_equal[__eq__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_equal[__eq__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_floor -array_api_tests/test_operators_and_elementwise_functions.py::test_greater[greater(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_greater[__gt__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_greater[__gt__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_greater_equal[greater_equal(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_greater_equal[__ge__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_greater_equal[__ge__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_isfinite -array_api_tests/test_operators_and_elementwise_functions.py::test_isinf -array_api_tests/test_operators_and_elementwise_functions.py::test_isnan -array_api_tests/test_operators_and_elementwise_functions.py::test_less[less(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_less[__lt__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_less[__lt__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_less_equal[less_equal(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_less_equal[__le__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_less_equal[__le__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_log2 -array_api_tests/test_operators_and_elementwise_functions.py::test_logaddexp -array_api_tests/test_operators_and_elementwise_functions.py::test_multiply[multiply(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_multiply[__mul__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_multiply[__mul__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_multiply[__imul__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_multiply[__imul__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_not_equal[not_equal(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_not_equal[__ne__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_not_equal[__ne__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_pow[__pow__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_pow[__ipow__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_round -array_api_tests/test_operators_and_elementwise_functions.py::test_sign -array_api_tests/test_operators_and_elementwise_functions.py::test_square -array_api_tests/test_operators_and_elementwise_functions.py::test_subtract[subtract(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_subtract[__sub__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_subtract[__sub__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_subtract[__isub__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_subtract[__isub__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_trunc -array_api_tests/test_searching_functions.py::test_where -array_api_tests/test_set_functions.py::test_unique_inverse -array_api_tests/test_set_functions.py::test_unique_values -array_api_tests/test_special_cases.py::test_unary[acos(x_i < -1) -> NaN] -array_api_tests/test_special_cases.py::test_unary[acos(x_i > 1) -> NaN] -array_api_tests/test_special_cases.py::test_unary[asin(x_i > 1) -> NaN] -array_api_tests/test_special_cases.py::test_unary[asin(x_i < -1) -> NaN] -array_api_tests/test_special_cases.py::test_unary[atanh(x_i < -1) -> NaN] -array_api_tests/test_special_cases.py::test_unary[ceil(x_i.is_integer()) -> x_i] -array_api_tests/test_special_cases.py::test_unary[floor(x_i.is_integer()) -> x_i] -array_api_tests/test_special_cases.py::test_unary[log(x_i < 0) -> NaN] -array_api_tests/test_special_cases.py::test_unary[log2(x_i < 0) -> NaN] -array_api_tests/test_special_cases.py::test_unary[log10(x_i < 0) -> NaN] -array_api_tests/test_special_cases.py::test_unary[round(x_i.is_integer()) -> x_i] -array_api_tests/test_special_cases.py::test_unary[round(modf(i)[0] == 0.5) -> Decimal(i).to_integral_exact(ROUND_HALF_EVEN)] -array_api_tests/test_special_cases.py::test_unary[sign(x_i < 0) -> -1] -array_api_tests/test_special_cases.py::test_unary[sign(x_i > 0) -> +1] -array_api_tests/test_special_cases.py::test_unary[sqrt(x_i < 0) -> NaN] -array_api_tests/test_special_cases.py::test_unary[trunc(x_i.is_integer()) -> x_i] -array_api_tests/test_special_cases.py::test_binary[add((x1_i is +0 or x1_i == -0) and isfinite(x2_i) and x2_i != 0) -> x2_i] -array_api_tests/test_special_cases.py::test_binary[add(isfinite(x1_i) and x1_i != 0 and (x2_i is +0 or x2_i == -0)) -> x1_i] -array_api_tests/test_special_cases.py::test_binary[add(isfinite(x1_i) and x1_i != 0 and x2_i == -x1_i) -> +0] -array_api_tests/test_special_cases.py::test_binary[__add__((x1_i is +0 or x1_i == -0) and isfinite(x2_i) and x2_i != 0) -> x2_i] -array_api_tests/test_special_cases.py::test_binary[__add__(isfinite(x1_i) and x1_i != 0 and (x2_i is +0 or x2_i == -0)) -> x1_i] -array_api_tests/test_special_cases.py::test_binary[__add__(isfinite(x1_i) and x1_i != 0 and x2_i == -x1_i) -> +0] -array_api_tests/test_special_cases.py::test_binary[pow(x1_i < 0 and isfinite(x1_i) and isfinite(x2_i) and not x2_i.is_integer()) -> NaN] -array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i is NaN and not x2_i == 0) -> NaN] -array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i < 0 and isfinite(x1_i) and isfinite(x2_i) and not x2_i.is_integer()) -> NaN] -array_api_tests/test_special_cases.py::test_iop[__iadd__((x1_i is +0 or x1_i == -0) and isfinite(x2_i) and x2_i != 0) -> x2_i] -array_api_tests/test_special_cases.py::test_iop[__iadd__(isfinite(x1_i) and x1_i != 0 and (x2_i is +0 or x2_i == -0)) -> x1_i] -array_api_tests/test_special_cases.py::test_iop[__iadd__(isfinite(x1_i) and x1_i != 0 and x2_i == -x1_i) -> +0] -array_api_tests/test_special_cases.py::test_iop[__ipow__(x1_i < 0 and isfinite(x1_i) and isfinite(x2_i) and not x2_i.is_integer()) -> NaN] diff --git a/.github/array_api_test/xfails.txt b/.github/array_api_test/xfails.txt deleted file mode 100644 index a69262c2c4..0000000000 --- a/.github/array_api_test/xfails.txt +++ /dev/null @@ -1,269 +0,0 @@ -# fails every time -array_api_tests/test_array_object.py::test_getitem -array_api_tests/test_array_object.py::test_setitem -array_api_tests/test_array_object.py::test_getitem_masking -array_api_tests/test_array_object.py::test_setitem_masking -array_api_tests/test_array_object.py::test_getitem_arrays_and_ints_1[None] -array_api_tests/test_array_object.py::test_getitem_arrays_and_ints_2[None] -array_api_tests/test_creation_functions.py::test_asarray_arrays -array_api_tests/test_creation_functions.py::test_empty -array_api_tests/test_creation_functions.py::test_empty_like -array_api_tests/test_creation_functions.py::test_eye -array_api_tests/test_creation_functions.py::test_full -array_api_tests/test_creation_functions.py::test_full_like -array_api_tests/test_creation_functions.py::test_linspace -array_api_tests/test_creation_functions.py::test_meshgrid -array_api_tests/test_creation_functions.py::test_ones -array_api_tests/test_creation_functions.py::test_ones_like -array_api_tests/test_creation_functions.py::test_tril -array_api_tests/test_creation_functions.py::test_triu -array_api_tests/test_creation_functions.py::test_zeros -array_api_tests/test_creation_functions.py::test_zeros_like -array_api_tests/test_has_names.py::test_has_names[linalg-cholesky] -array_api_tests/test_has_names.py::test_has_names[linalg-cross] -array_api_tests/test_has_names.py::test_has_names[linalg-det] -array_api_tests/test_has_names.py::test_has_names[linalg-diagonal] -array_api_tests/test_has_names.py::test_has_names[linalg-eigh] -array_api_tests/test_has_names.py::test_has_names[linalg-eigvalsh] -array_api_tests/test_has_names.py::test_has_names[linalg-inv] -array_api_tests/test_has_names.py::test_has_names[linalg-matrix_norm] -array_api_tests/test_has_names.py::test_has_names[linalg-matrix_power] -array_api_tests/test_has_names.py::test_has_names[linalg-matrix_rank] -array_api_tests/test_has_names.py::test_has_names[linalg-outer] -array_api_tests/test_has_names.py::test_has_names[linalg-pinv] -array_api_tests/test_has_names.py::test_has_names[linalg-qr] -array_api_tests/test_has_names.py::test_has_names[linalg-slogdet] -array_api_tests/test_has_names.py::test_has_names[linalg-solve] -array_api_tests/test_has_names.py::test_has_names[linalg-svd] -array_api_tests/test_has_names.py::test_has_names[linalg-svdvals] -array_api_tests/test_has_names.py::test_has_names[linalg-trace] -array_api_tests/test_has_names.py::test_has_names[linalg-vector_norm] -array_api_tests/test_has_names.py::test_has_names[fft-fft] -array_api_tests/test_has_names.py::test_has_names[fft-ifft] -array_api_tests/test_has_names.py::test_has_names[fft-fftn] -array_api_tests/test_has_names.py::test_has_names[fft-ifftn] -array_api_tests/test_has_names.py::test_has_names[fft-rfft] -array_api_tests/test_has_names.py::test_has_names[fft-irfft] -array_api_tests/test_has_names.py::test_has_names[fft-rfftn] -array_api_tests/test_has_names.py::test_has_names[fft-irfftn] -array_api_tests/test_has_names.py::test_has_names[fft-hfft] -array_api_tests/test_has_names.py::test_has_names[fft-ihfft] -array_api_tests/test_has_names.py::test_has_names[fft-fftfreq] -array_api_tests/test_has_names.py::test_has_names[fft-rfftfreq] -array_api_tests/test_has_names.py::test_has_names[fft-fftshift] -array_api_tests/test_has_names.py::test_has_names[fft-ifftshift] -array_api_tests/test_has_names.py::test_has_names[indexing-take] -array_api_tests/test_has_names.py::test_has_names[set-unique_all] -array_api_tests/test_has_names.py::test_has_names[set-unique_counts] -array_api_tests/test_has_names.py::test_has_names[manipulation-moveaxis] -array_api_tests/test_has_names.py::test_has_names[manipulation-repeat] -array_api_tests/test_has_names.py::test_has_names[manipulation-tile] -array_api_tests/test_has_names.py::test_has_names[manipulation-unstack] -array_api_tests/test_has_names.py::test_has_names[searching-searchsorted] -array_api_tests/test_has_names.py::test_has_names[elementwise-clip] -array_api_tests/test_has_names.py::test_has_names[elementwise-conj] -array_api_tests/test_has_names.py::test_has_names[elementwise-copysign] -array_api_tests/test_has_names.py::test_has_names[elementwise-hypot] -array_api_tests/test_has_names.py::test_has_names[elementwise-imag] -array_api_tests/test_has_names.py::test_has_names[elementwise-maximum] -array_api_tests/test_has_names.py::test_has_names[elementwise-minimum] -array_api_tests/test_has_names.py::test_has_names[elementwise-real] -array_api_tests/test_has_names.py::test_has_names[elementwise-signbit] -array_api_tests/test_has_names.py::test_has_names[statistical-cumulative_sum] -array_api_tests/test_has_names.py::test_has_names[sorting-argsort] -array_api_tests/test_has_names.py::test_has_names[data_type-isdtype] -array_api_tests/test_has_names.py::test_has_names[info-__array_namespace_info__] -array_api_tests/test_has_names.py::test_has_names[array_method-__complex__] -array_api_tests/test_indexing_functions.py::test_take -array_api_tests/test_inspection_functions.py::test_array_namespace_info -array_api_tests/test_inspection_functions.py::test_array_namespace_info_dtypes -array_api_tests/test_linalg.py::test_matrix_transpose -array_api_tests/test_linalg.py::test_tensordot -array_api_tests/test_linalg.py::test_vecdot -array_api_tests/test_manipulation_functions.py::test_moveaxis -array_api_tests/test_manipulation_functions.py::test_repeat -array_api_tests/test_manipulation_functions.py::test_tile -array_api_tests/test_manipulation_functions.py::test_unstack -array_api_tests/test_operators_and_elementwise_functions.py::test_abs[abs] -array_api_tests/test_operators_and_elementwise_functions.py::test_abs[__abs__] -array_api_tests/test_operators_and_elementwise_functions.py::test_acos -array_api_tests/test_operators_and_elementwise_functions.py::test_acosh -array_api_tests/test_operators_and_elementwise_functions.py::test_asin -array_api_tests/test_operators_and_elementwise_functions.py::test_asinh -array_api_tests/test_operators_and_elementwise_functions.py::test_atan -array_api_tests/test_operators_and_elementwise_functions.py::test_atanh -array_api_tests/test_operators_and_elementwise_functions.py::test_bitwise_left_shift[bitwise_left_shift(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_bitwise_left_shift[__lshift__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_bitwise_left_shift[__ilshift__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_bitwise_right_shift[bitwise_right_shift(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_bitwise_right_shift[__rshift__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_bitwise_right_shift[__irshift__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_clip -array_api_tests/test_operators_and_elementwise_functions.py::test_conj -array_api_tests/test_operators_and_elementwise_functions.py::test_copysign -array_api_tests/test_operators_and_elementwise_functions.py::test_cos -array_api_tests/test_operators_and_elementwise_functions.py::test_cosh -array_api_tests/test_operators_and_elementwise_functions.py::test_divide[divide(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_divide[__truediv__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_divide[__truediv__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_divide[__itruediv__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_divide[__itruediv__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_exp -array_api_tests/test_operators_and_elementwise_functions.py::test_expm1 -array_api_tests/test_operators_and_elementwise_functions.py::test_floor_divide[floor_divide(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_floor_divide[__floordiv__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_floor_divide[__floordiv__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_floor_divide[__ifloordiv__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_floor_divide[__ifloordiv__(x, s)] -array_api_tests/test_operators_and_elementwise_functions.py::test_hypot -array_api_tests/test_operators_and_elementwise_functions.py::test_imag -array_api_tests/test_operators_and_elementwise_functions.py::test_log -array_api_tests/test_operators_and_elementwise_functions.py::test_log1p -array_api_tests/test_operators_and_elementwise_functions.py::test_log10 -array_api_tests/test_operators_and_elementwise_functions.py::test_maximum -array_api_tests/test_operators_and_elementwise_functions.py::test_minimum -array_api_tests/test_operators_and_elementwise_functions.py::test_negative[negative] -array_api_tests/test_operators_and_elementwise_functions.py::test_negative[__neg__] -array_api_tests/test_operators_and_elementwise_functions.py::test_positive[positive] -array_api_tests/test_operators_and_elementwise_functions.py::test_positive[__pos__] -array_api_tests/test_operators_and_elementwise_functions.py::test_pow[pow(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_pow[__pow__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_pow[__ipow__(x1, x2)] -array_api_tests/test_operators_and_elementwise_functions.py::test_real -array_api_tests/test_operators_and_elementwise_functions.py::test_signbit -array_api_tests/test_operators_and_elementwise_functions.py::test_sin -array_api_tests/test_operators_and_elementwise_functions.py::test_sinh -array_api_tests/test_operators_and_elementwise_functions.py::test_sqrt -array_api_tests/test_operators_and_elementwise_functions.py::test_tan -array_api_tests/test_operators_and_elementwise_functions.py::test_tanh -array_api_tests/test_searching_functions.py::test_argmax -array_api_tests/test_searching_functions.py::test_argmin -array_api_tests/test_searching_functions.py::test_nonzero_zerodim_error -array_api_tests/test_searching_functions.py::test_nonzero -array_api_tests/test_searching_functions.py::test_searchsorted -array_api_tests/test_set_functions.py::test_unique_all -array_api_tests/test_set_functions.py::test_unique_counts -array_api_tests/test_signatures.py::test_func_signature[from_dlpack] -array_api_tests/test_signatures.py::test_func_signature[take] -array_api_tests/test_signatures.py::test_func_signature[unique_all] -array_api_tests/test_signatures.py::test_func_signature[unique_counts] -array_api_tests/test_signatures.py::test_func_signature[moveaxis] -array_api_tests/test_signatures.py::test_func_signature[repeat] -array_api_tests/test_signatures.py::test_func_signature[tile] -array_api_tests/test_signatures.py::test_func_signature[unstack] -array_api_tests/test_signatures.py::test_func_signature[searchsorted] -array_api_tests/test_signatures.py::test_func_signature[clip] -array_api_tests/test_signatures.py::test_func_signature[conj] -array_api_tests/test_signatures.py::test_func_signature[copysign] -array_api_tests/test_signatures.py::test_func_signature[hypot] -array_api_tests/test_signatures.py::test_func_signature[imag] -array_api_tests/test_signatures.py::test_func_signature[maximum] -array_api_tests/test_signatures.py::test_func_signature[minimum] -array_api_tests/test_signatures.py::test_func_signature[real] -array_api_tests/test_signatures.py::test_func_signature[signbit] -array_api_tests/test_signatures.py::test_func_signature[cumulative_sum] -array_api_tests/test_signatures.py::test_func_signature[argsort] -array_api_tests/test_signatures.py::test_func_signature[astype] -array_api_tests/test_signatures.py::test_func_signature[isdtype] -array_api_tests/test_signatures.py::test_func_signature[__array_namespace_info__] -array_api_tests/test_signatures.py::test_array_method_signature[__complex__] -array_api_tests/test_signatures.py::test_array_method_signature[__dlpack__] -array_api_tests/test_signatures.py::test_info_func_signature[capabilities] -array_api_tests/test_signatures.py::test_info_func_signature[default_device] -array_api_tests/test_signatures.py::test_info_func_signature[default_dtypes] -array_api_tests/test_signatures.py::test_info_func_signature[devices] -array_api_tests/test_signatures.py::test_info_func_signature[dtypes] -array_api_tests/test_sorting_functions.py::test_argsort -array_api_tests/test_sorting_functions.py::test_sort -array_api_tests/test_special_cases.py::test_unary[isfinite((x_i is +infinity or x_i == -infinity)) -> False] -array_api_tests/test_special_cases.py::test_unary[isfinite(x_i is NaN) -> False] -array_api_tests/test_special_cases.py::test_unary[isfinite(isfinite(x_i)) -> True] -array_api_tests/test_special_cases.py::test_unary[isinf((x_i is +infinity or x_i == -infinity)) -> True] -array_api_tests/test_special_cases.py::test_unary[isnan(x_i is NaN) -> True] -array_api_tests/test_special_cases.py::test_unary[sign(x_i is NaN) -> NaN] -array_api_tests/test_special_cases.py::test_unary[signbit(x_i is +0) -> False] -array_api_tests/test_special_cases.py::test_unary[signbit(x_i is -0) -> True] -array_api_tests/test_special_cases.py::test_unary[signbit(x_i is +infinity) -> False] -array_api_tests/test_special_cases.py::test_unary[signbit(x_i is -infinity) -> True] -array_api_tests/test_special_cases.py::test_unary[signbit(isfinite(x_i) and x_i > 0) -> False] -array_api_tests/test_special_cases.py::test_unary[signbit(isfinite(x_i) and x_i < 0) -> True] -array_api_tests/test_special_cases.py::test_unary[signbit(x_i is +NaN) -> False] -array_api_tests/test_special_cases.py::test_unary[signbit(x_i is -NaN) -> True] -array_api_tests/test_special_cases.py::test_binary[copysign(x1_i is NaN and x2_i < 0) -> NaN] -array_api_tests/test_special_cases.py::test_binary[copysign(x1_i is NaN and x2_i is -0) -> NaN] -array_api_tests/test_special_cases.py::test_binary[copysign(x1_i is NaN and x2_i is +0) -> NaN] -array_api_tests/test_special_cases.py::test_binary[copysign(x1_i is NaN and x2_i > 0) -> NaN] -array_api_tests/test_special_cases.py::test_binary[divide(x1_i is +0 and x2_i > 0) -> +0] -array_api_tests/test_special_cases.py::test_binary[divide(x1_i is -0 and x2_i > 0) -> -0] -array_api_tests/test_special_cases.py::test_binary[divide(x1_i is +0 and x2_i < 0) -> -0] -array_api_tests/test_special_cases.py::test_binary[divide(x1_i is -0 and x2_i < 0) -> +0] -array_api_tests/test_special_cases.py::test_binary[divide(x1_i > 0 and x2_i is +0) -> +infinity] -array_api_tests/test_special_cases.py::test_binary[divide(x1_i > 0 and x2_i is -0) -> -infinity] -array_api_tests/test_special_cases.py::test_binary[divide(x1_i < 0 and x2_i is +0) -> -infinity] -array_api_tests/test_special_cases.py::test_binary[divide(x1_i < 0 and x2_i is -0) -> +infinity] -array_api_tests/test_special_cases.py::test_binary[__truediv__(x1_i is +0 and x2_i > 0) -> +0] -array_api_tests/test_special_cases.py::test_binary[__truediv__(x1_i is -0 and x2_i > 0) -> -0] -array_api_tests/test_special_cases.py::test_binary[__truediv__(x1_i is +0 and x2_i < 0) -> -0] -array_api_tests/test_special_cases.py::test_binary[__truediv__(x1_i is -0 and x2_i < 0) -> +0] -array_api_tests/test_special_cases.py::test_binary[__truediv__(x1_i > 0 and x2_i is +0) -> +infinity] -array_api_tests/test_special_cases.py::test_binary[__truediv__(x1_i > 0 and x2_i is -0) -> -infinity] -array_api_tests/test_special_cases.py::test_binary[__truediv__(x1_i < 0 and x2_i is +0) -> -infinity] -array_api_tests/test_special_cases.py::test_binary[__truediv__(x1_i < 0 and x2_i is -0) -> +infinity] -array_api_tests/test_special_cases.py::test_binary[maximum(x1_i is NaN or x2_i is NaN) -> NaN] -array_api_tests/test_special_cases.py::test_binary[minimum(x1_i is NaN or x2_i is NaN) -> NaN] -array_api_tests/test_special_cases.py::test_binary[pow(abs(x1_i) > 1 and x2_i is +infinity) -> +infinity] -array_api_tests/test_special_cases.py::test_binary[pow(abs(x1_i) > 1 and x2_i is -infinity) -> +0] -array_api_tests/test_special_cases.py::test_binary[pow(x1_i is +infinity and x2_i > 0) -> +infinity] -array_api_tests/test_special_cases.py::test_binary[pow(x1_i is +infinity and x2_i < 0) -> +0] -array_api_tests/test_special_cases.py::test_binary[pow(x1_i is -infinity and x2_i > 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +infinity] -array_api_tests/test_special_cases.py::test_binary[pow(x1_i is -infinity and x2_i < 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +0] -array_api_tests/test_special_cases.py::test_binary[pow(x1_i is +0 and x2_i > 0) -> +0] -array_api_tests/test_special_cases.py::test_binary[pow(x1_i is +0 and x2_i < 0) -> +infinity] -array_api_tests/test_special_cases.py::test_binary[pow(x1_i is -0 and x2_i > 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +0] -array_api_tests/test_special_cases.py::test_binary[pow(x1_i is -0 and x2_i < 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +infinity] -array_api_tests/test_special_cases.py::test_binary[__pow__(abs(x1_i) > 1 and x2_i is +infinity) -> +infinity] -array_api_tests/test_special_cases.py::test_binary[__pow__(abs(x1_i) > 1 and x2_i is -infinity) -> +0] -array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i is +infinity and x2_i > 0) -> +infinity] -array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i is +infinity and x2_i < 0) -> +0] -array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i is -infinity and x2_i > 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +infinity] -array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i is -infinity and x2_i < 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +0] -array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i is +0 and x2_i > 0) -> +0] -array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i is +0 and x2_i < 0) -> +infinity] -array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i is -0 and x2_i > 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +0] -array_api_tests/test_special_cases.py::test_binary[__pow__(x1_i is -0 and x2_i < 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +infinity] -array_api_tests/test_special_cases.py::test_iop[__itruediv__(x1_i is +0 and x2_i > 0) -> +0] -array_api_tests/test_special_cases.py::test_iop[__itruediv__(x1_i is -0 and x2_i > 0) -> -0] -array_api_tests/test_special_cases.py::test_iop[__itruediv__(x1_i is +0 and x2_i < 0) -> -0] -array_api_tests/test_special_cases.py::test_iop[__itruediv__(x1_i is -0 and x2_i < 0) -> +0] -array_api_tests/test_special_cases.py::test_iop[__itruediv__(x1_i > 0 and x2_i is +0) -> +infinity] -array_api_tests/test_special_cases.py::test_iop[__itruediv__(x1_i > 0 and x2_i is -0) -> -infinity] -array_api_tests/test_special_cases.py::test_iop[__itruediv__(x1_i < 0 and x2_i is +0) -> -infinity] -array_api_tests/test_special_cases.py::test_iop[__itruediv__(x1_i < 0 and x2_i is -0) -> +infinity] -array_api_tests/test_special_cases.py::test_iop[__ipow__(abs(x1_i) > 1 and x2_i is +infinity) -> +infinity] -array_api_tests/test_special_cases.py::test_iop[__ipow__(abs(x1_i) > 1 and x2_i is -infinity) -> +0] -array_api_tests/test_special_cases.py::test_iop[__ipow__(x1_i is +infinity and x2_i > 0) -> +infinity] -array_api_tests/test_special_cases.py::test_iop[__ipow__(x1_i is +infinity and x2_i < 0) -> +0] -array_api_tests/test_special_cases.py::test_iop[__ipow__(x1_i is -infinity and x2_i > 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +infinity] -array_api_tests/test_special_cases.py::test_iop[__ipow__(x1_i is -infinity and x2_i < 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +0] -array_api_tests/test_special_cases.py::test_iop[__ipow__(x1_i is +0 and x2_i > 0) -> +0] -array_api_tests/test_special_cases.py::test_iop[__ipow__(x1_i is +0 and x2_i < 0) -> +infinity] -array_api_tests/test_special_cases.py::test_iop[__ipow__(x1_i is -0 and x2_i > 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +0] -array_api_tests/test_special_cases.py::test_iop[__ipow__(x1_i is -0 and x2_i < 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +infinity] -array_api_tests/test_special_cases.py::test_empty_arrays[prod] -array_api_tests/test_special_cases.py::test_empty_arrays[std] -array_api_tests/test_special_cases.py::test_empty_arrays[sum] -array_api_tests/test_special_cases.py::test_nan_propagation[max] -array_api_tests/test_special_cases.py::test_nan_propagation[mean] -array_api_tests/test_special_cases.py::test_nan_propagation[min] -array_api_tests/test_special_cases.py::test_nan_propagation[prod] -array_api_tests/test_special_cases.py::test_nan_propagation[std] -array_api_tests/test_special_cases.py::test_nan_propagation[sum] -array_api_tests/test_special_cases.py::test_nan_propagation[var] -array_api_tests/test_statistical_functions.py::test_cumulative_sum -array_api_tests/test_statistical_functions.py::test_max -array_api_tests/test_statistical_functions.py::test_mean -array_api_tests/test_statistical_functions.py::test_min -array_api_tests/test_statistical_functions.py::test_prod -array_api_tests/test_statistical_functions.py::test_sum -array_api_tests/test_utility_functions.py::test_all -array_api_tests/test_utility_functions.py::test_any diff --git a/.github/workflows/array-api.yml b/.github/workflows/array-api.yml index 10f6931153..6eb17d704a 100644 --- a/.github/workflows/array-api.yml +++ b/.github/workflows/array-api.yml @@ -45,4 +45,4 @@ jobs: export PYTHONPATH="${GITHUB_WORKSPACE}/heat" # Skip testing functions with known issues cd ${GITHUB_WORKSPACE}/array-api-tests - pytest array_api_tests/ -v -rxXfE --ci --xfails-file ${GITHUB_WORKSPACE}/.github/array_api_test/xfails.txt --skips-file ${GITHUB_WORKSPACE}/.github/array_api_test/skips.txt --disable-extension linalg --disable-extension fft + pytest array_api_tests/ -v -rxXfE --ci