From 035969e74f01ff7163e7ff89b340ee72770aec75 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sat, 18 May 2024 21:44:10 -0700 Subject: [PATCH 01/17] Wrap fft for dask --- array_api_compat/dask/array/fft.py | 29 +++++++++++++++++++++++++++++ dask-skips.txt | 3 --- 2 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 array_api_compat/dask/array/fft.py diff --git a/array_api_compat/dask/array/fft.py b/array_api_compat/dask/array/fft.py new file mode 100644 index 00000000..ad61d4a4 --- /dev/null +++ b/array_api_compat/dask/array/fft.py @@ -0,0 +1,29 @@ +from dask.array.fft import * # noqa: F403 +from numpy.fft import __all__ as fft_all + +from ..common import _fft +from .._internal import get_xp + +import dask.array as da + +fft = get_xp(da)(_fft.fft) +ifft = get_xp(da)(_fft.ifft) +fftn = get_xp(da)(_fft.fftn) +ifftn = get_xp(da)(_fft.ifftn) +rfft = get_xp(da)(_fft.rfft) +irfft = get_xp(da)(_fft.irfft) +rfftn = get_xp(da)(_fft.rfftn) +irfftn = get_xp(da)(_fft.irfftn) +hfft = get_xp(da)(_fft.hfft) +ihfft = get_xp(da)(_fft.ihfft) +fftfreq = get_xp(da)(_fft.fftfreq) +rfftfreq = get_xp(da)(_fft.rfftfreq) +fftshift = get_xp(da)(_fft.fftshift) +ifftshift = get_xp(da)(_fft.ifftshift) + +__all__ = fft_all + _fft.__all__ + +del get_xp +del da +del fft_all +del _fft diff --git a/dask-skips.txt b/dask-skips.txt index 8e884ac0..63a09e4b 100644 --- a/dask-skips.txt +++ b/dask-skips.txt @@ -1,5 +1,2 @@ -# FFT isn't conformant -array_api_tests/test_fft.py - # slow and not implemented in dask array_api_tests/test_linalg.py::test_matrix_power From 8222d1932934f7e5ce0f7b062be907c8f74c2d9d Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 19 May 2024 19:52:19 -0700 Subject: [PATCH 02/17] try numpy 2.0rc2 --- .github/workflows/array-api-tests-dask.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/array-api-tests-dask.yml b/.github/workflows/array-api-tests-dask.yml index b0ce007e..7b58ecb9 100644 --- a/.github/workflows/array-api-tests-dask.yml +++ b/.github/workflows/array-api-tests-dask.yml @@ -8,5 +8,5 @@ jobs: with: package-name: dask module-name: dask.array - extra-requires: numpy + extra-requires: numpy==2.0rc2 pytest-extra-args: --disable-deadline --max-examples=5 From 1f14ba9c4e27bd3553738cdddbd4ade02f0f06ed Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sat, 24 Aug 2024 08:37:23 -0700 Subject: [PATCH 03/17] remove stale condition --- .github/workflows/array-api-tests-dask.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/array-api-tests-dask.yml b/.github/workflows/array-api-tests-dask.yml index 7b58ecb9..b0ce007e 100644 --- a/.github/workflows/array-api-tests-dask.yml +++ b/.github/workflows/array-api-tests-dask.yml @@ -8,5 +8,5 @@ jobs: with: package-name: dask module-name: dask.array - extra-requires: numpy==2.0rc2 + extra-requires: numpy pytest-extra-args: --disable-deadline --max-examples=5 From db22d63bb8a57c50eee27ac5ca463985e3f71c2c Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sat, 24 Aug 2024 08:51:53 -0700 Subject: [PATCH 04/17] try drop 3.9? --- .github/workflows/array-api-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/array-api-tests.yml b/.github/workflows/array-api-tests.yml index 6e709438..c057e9b5 100644 --- a/.github/workflows/array-api-tests.yml +++ b/.github/workflows/array-api-tests.yml @@ -40,7 +40,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.9', '3.10', '3.11', '3.12'] + python-version: ['3.10', '3.11', '3.12'] steps: - name: Checkout array-api-compat From 1e79b847e4f450821f160665fb228f1406f4d07a Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sat, 28 Sep 2024 14:29:57 -0400 Subject: [PATCH 05/17] actually wrap properly --- array_api_compat/dask/array/__init__.py | 1 + array_api_compat/dask/array/fft.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/array_api_compat/dask/array/__init__.py b/array_api_compat/dask/array/__init__.py index 03e0cd72..ce0e609e 100644 --- a/array_api_compat/dask/array/__init__.py +++ b/array_api_compat/dask/array/__init__.py @@ -6,3 +6,4 @@ __array_api_version__ = '2022.12' __import__(__package__ + '.linalg') +__import__(__package__ + '.fft') diff --git a/array_api_compat/dask/array/fft.py b/array_api_compat/dask/array/fft.py index ad61d4a4..d785eab9 100644 --- a/array_api_compat/dask/array/fft.py +++ b/array_api_compat/dask/array/fft.py @@ -1,8 +1,8 @@ from dask.array.fft import * # noqa: F403 from numpy.fft import __all__ as fft_all -from ..common import _fft -from .._internal import get_xp +from ...common import _fft +from ..._internal import get_xp import dask.array as da From 1856ec72c8ec140e7bd70d75facaf5e2c12fe36d Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sat, 28 Sep 2024 14:32:42 -0400 Subject: [PATCH 06/17] add wrappers for only fftfreq --- array_api_compat/dask/array/fft.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/array_api_compat/dask/array/fft.py b/array_api_compat/dask/array/fft.py index d785eab9..23e87778 100644 --- a/array_api_compat/dask/array/fft.py +++ b/array_api_compat/dask/array/fft.py @@ -6,20 +6,20 @@ import dask.array as da -fft = get_xp(da)(_fft.fft) -ifft = get_xp(da)(_fft.ifft) -fftn = get_xp(da)(_fft.fftn) -ifftn = get_xp(da)(_fft.ifftn) -rfft = get_xp(da)(_fft.rfft) -irfft = get_xp(da)(_fft.irfft) -rfftn = get_xp(da)(_fft.rfftn) -irfftn = get_xp(da)(_fft.irfftn) -hfft = get_xp(da)(_fft.hfft) -ihfft = get_xp(da)(_fft.ihfft) +# fft = get_xp(da)(_fft.fft) +# ifft = get_xp(da)(_fft.ifft) +# fftn = get_xp(da)(_fft.fftn) +# ifftn = get_xp(da)(_fft.ifftn) +# rfft = get_xp(da)(_fft.rfft) +# irfft = get_xp(da)(_fft.irfft) +# rfftn = get_xp(da)(_fft.rfftn) +# irfftn = get_xp(da)(_fft.irfftn) +# hfft = get_xp(da)(_fft.hfft) +# ihfft = get_xp(da)(_fft.ihfft) fftfreq = get_xp(da)(_fft.fftfreq) rfftfreq = get_xp(da)(_fft.rfftfreq) -fftshift = get_xp(da)(_fft.fftshift) -ifftshift = get_xp(da)(_fft.ifftshift) +# fftshift = get_xp(da)(_fft.fftshift) +# ifftshift = get_xp(da)(_fft.ifftshift) __all__ = fft_all + _fft.__all__ From b6f4cf8758ae59edfba1ae14081ad385fe201441 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Thu, 3 Oct 2024 15:18:08 -0400 Subject: [PATCH 07/17] try to fix all? --- array_api_compat/dask/array/_aliases.py | 32 ++++--------------------- array_api_compat/dask/array/fft.py | 23 +++++++----------- 2 files changed, 14 insertions(+), 41 deletions(-) diff --git a/array_api_compat/dask/array/_aliases.py b/array_api_compat/dask/array/_aliases.py index d26ec6a2..764afc1d 100644 --- a/array_api_compat/dask/array/_aliases.py +++ b/array_api_compat/dask/array/_aliases.py @@ -7,26 +7,7 @@ import numpy as np from numpy import ( - # Constants - e, - inf, - nan, - pi, - newaxis, # Dtypes - bool_ as bool, - float32, - float64, - int8, - int16, - int32, - int64, - uint8, - uint16, - uint32, - uint64, - complex64, - complex128, iinfo, finfo, can_cast, @@ -173,12 +154,9 @@ def asarray( common_aliases = [alias for alias in _aliases.__all__ if alias not in _da_unsupported] -__all__ = common_aliases + ['asarray', 'bool', 'acos', - 'acosh', 'asin', 'asinh', 'atan', 'atan2', - 'atanh', 'bitwise_left_shift', 'bitwise_invert', - 'bitwise_right_shift', 'concat', 'pow', - 'e', 'inf', 'nan', 'pi', 'newaxis', 'float32', 'float64', 'int8', - 'int16', 'int32', 'int64', 'uint8', 'uint16', 'uint32', 'uint64', - 'complex64', 'complex128', 'iinfo', 'finfo', 'can_cast', 'result_type'] +__all__ = common_aliases + ['asarray', 'acos', + 'acosh', 'asin', 'asinh', 'atan', 'atan2', + 'atanh', 'bitwise_left_shift', 'bitwise_invert', + 'bitwise_right_shift', 'concat', 'pow', 'iinfo', 'finfo', 'can_cast', 'result_type'] -_all_ignore = ['get_xp', 'da', 'partial', 'common_aliases', 'np'] +del get_xp, da, common_aliases, np diff --git a/array_api_compat/dask/array/fft.py b/array_api_compat/dask/array/fft.py index 23e87778..74de1df6 100644 --- a/array_api_compat/dask/array/fft.py +++ b/array_api_compat/dask/array/fft.py @@ -1,27 +1,22 @@ from dask.array.fft import * # noqa: F403 -from numpy.fft import __all__ as fft_all +# cupy.fft doesn't have __all__. If it is added, replace this with +# +# from cupy.fft import __all__ as linalg_all +_n = {} +exec('from dask.array.fft import *', _n) +del _n['__builtins__'] +fft_all = list(_n) +del _n from ...common import _fft from ..._internal import get_xp import dask.array as da -# fft = get_xp(da)(_fft.fft) -# ifft = get_xp(da)(_fft.ifft) -# fftn = get_xp(da)(_fft.fftn) -# ifftn = get_xp(da)(_fft.ifftn) -# rfft = get_xp(da)(_fft.rfft) -# irfft = get_xp(da)(_fft.irfft) -# rfftn = get_xp(da)(_fft.rfftn) -# irfftn = get_xp(da)(_fft.irfftn) -# hfft = get_xp(da)(_fft.hfft) -# ihfft = get_xp(da)(_fft.ihfft) fftfreq = get_xp(da)(_fft.fftfreq) rfftfreq = get_xp(da)(_fft.rfftfreq) -# fftshift = get_xp(da)(_fft.fftshift) -# ifftshift = get_xp(da)(_fft.ifftshift) -__all__ = fft_all + _fft.__all__ +__all__ = [elem for elem in fft_all if elem != "annotations"] + ["fftfreq", "rfftfreq"] del get_xp del da From ec6dcc416a84eb3f55107aabeeff15c688b00920 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Fri, 4 Oct 2024 07:39:17 -0400 Subject: [PATCH 08/17] fix dask.array for real this time --- array_api_compat/dask/array/_aliases.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/array_api_compat/dask/array/_aliases.py b/array_api_compat/dask/array/_aliases.py index 764afc1d..4834ba1c 100644 --- a/array_api_compat/dask/array/_aliases.py +++ b/array_api_compat/dask/array/_aliases.py @@ -152,11 +152,11 @@ def asarray( # exclude these from all since _da_unsupported = ['sort', 'argsort'] -common_aliases = [alias for alias in _aliases.__all__ if alias not in _da_unsupported] +_common_aliases = [alias for alias in _aliases.__all__ if alias not in _da_unsupported] -__all__ = common_aliases + ['asarray', 'acos', +__all__ = _common_aliases + ['asarray', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'bitwise_left_shift', 'bitwise_invert', 'bitwise_right_shift', 'concat', 'pow', 'iinfo', 'finfo', 'can_cast', 'result_type'] -del get_xp, da, common_aliases, np +_all_ignore = ["get_xp", "da", "np"] From 11a92fe05a6fee5d9926656081b6557e5d8d7cc3 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 6 Oct 2024 21:50:44 -0400 Subject: [PATCH 09/17] fixup comment --- array_api_compat/dask/array/_aliases.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/array_api_compat/dask/array/_aliases.py b/array_api_compat/dask/array/_aliases.py index 11983eeb..a52593d3 100644 --- a/array_api_compat/dask/array/_aliases.py +++ b/array_api_compat/dask/array/_aliases.py @@ -187,7 +187,7 @@ def _isscalar(a): return astype(xp.minimum(xp.maximum(x, min), max), x.dtype) -# exclude these from all since +# exclude these from all since dask.array has no sorting functions _da_unsupported = ['sort', 'argsort'] _common_aliases = [alias for alias in _aliases.__all__ if alias not in _da_unsupported] From 2c4502ffc2b95a71f608e86207e7b4d168e38d4b Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Mon, 7 Oct 2024 08:07:20 -0400 Subject: [PATCH 10/17] add back missing dtypes --- .github/workflows/array-api-tests.yml | 2 +- array_api_compat/dask/array/_aliases.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/array-api-tests.yml b/.github/workflows/array-api-tests.yml index 136bfd6d..254e4e61 100644 --- a/.github/workflows/array-api-tests.yml +++ b/.github/workflows/array-api-tests.yml @@ -40,7 +40,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.10', '3.11', '3.12'] + python-version: ['3.9', '3.10', '3.11', '3.12'] steps: - name: Checkout array-api-compat diff --git a/array_api_compat/dask/array/_aliases.py b/array_api_compat/dask/array/_aliases.py index a52593d3..c27a1602 100644 --- a/array_api_compat/dask/array/_aliases.py +++ b/array_api_compat/dask/array/_aliases.py @@ -12,6 +12,9 @@ # Dtypes iinfo, finfo, + float64, + int8, + float32, can_cast, result_type, ) @@ -195,6 +198,7 @@ def _isscalar(a): __all__ = _common_aliases + ['__array_namespace_info__', 'asarray', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'bitwise_left_shift', 'bitwise_invert', - 'bitwise_right_shift', 'concat', 'pow', 'iinfo', 'finfo', 'can_cast', 'result_type'] + 'bitwise_right_shift', 'concat', 'pow', 'iinfo', 'finfo', 'can_cast', 'result_type', + 'float64', 'int8', 'float32'] _all_ignore = ["get_xp", "da", "np"] From 984f05285320ddd8752815c9aa5369aa897479fd Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Mon, 7 Oct 2024 17:52:59 -0400 Subject: [PATCH 11/17] add all dtypes back --- array_api_compat/dask/array/_aliases.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/array_api_compat/dask/array/_aliases.py b/array_api_compat/dask/array/_aliases.py index c27a1602..332bd950 100644 --- a/array_api_compat/dask/array/_aliases.py +++ b/array_api_compat/dask/array/_aliases.py @@ -12,9 +12,19 @@ # Dtypes iinfo, finfo, + bool_ as bool, + float32, float64, int8, - float32, + int16, + int32, + int64, + uint8, + uint16, + uint32, + uint64, + complex64, + complex128, can_cast, result_type, ) From 91ffaaf71e004a77d06e4865d8e3349462eca468 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Thu, 10 Oct 2024 22:17:16 -0400 Subject: [PATCH 12/17] fix all --- array_api_compat/dask/array/_aliases.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/array_api_compat/dask/array/_aliases.py b/array_api_compat/dask/array/_aliases.py index 332bd950..a9fccf14 100644 --- a/array_api_compat/dask/array/_aliases.py +++ b/array_api_compat/dask/array/_aliases.py @@ -208,7 +208,10 @@ def _isscalar(a): __all__ = _common_aliases + ['__array_namespace_info__', 'asarray', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'bitwise_left_shift', 'bitwise_invert', - 'bitwise_right_shift', 'concat', 'pow', 'iinfo', 'finfo', 'can_cast', 'result_type', - 'float64', 'int8', 'float32'] + 'bitwise_right_shift', 'concat', 'pow', 'iinfo', 'finfo', 'can_cast', + 'result_type', 'float32', 'float64', 'int8', 'int16', 'int32', 'int64', + 'uint8', 'uint16', 'uint32', 'uint64', + 'complex64', 'complex128', 'iinfo', 'finfo', + 'can_cast', 'result_type'] _all_ignore = ["get_xp", "da", "np"] From de0a735e856fffabf9e17a5d3492d928e41cfa9c Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Thu, 10 Oct 2024 22:25:36 -0400 Subject: [PATCH 13/17] fix __all__ --- array_api_compat/dask/array/_aliases.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/array_api_compat/dask/array/_aliases.py b/array_api_compat/dask/array/_aliases.py index a9fccf14..a24694f3 100644 --- a/array_api_compat/dask/array/_aliases.py +++ b/array_api_compat/dask/array/_aliases.py @@ -209,7 +209,7 @@ def _isscalar(a): 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'bitwise_left_shift', 'bitwise_invert', 'bitwise_right_shift', 'concat', 'pow', 'iinfo', 'finfo', 'can_cast', - 'result_type', 'float32', 'float64', 'int8', 'int16', 'int32', 'int64', + 'result_type', 'bool', 'float32', 'float64', 'int8', 'int16', 'int32', 'int64', 'uint8', 'uint16', 'uint32', 'uint64', 'complex64', 'complex128', 'iinfo', 'finfo', 'can_cast', 'result_type'] From 54d7c74460a994888c3b7eccf342c2781df70638 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 13 Oct 2024 17:47:41 -0400 Subject: [PATCH 14/17] add lower bound for dask --- .github/workflows/array-api-tests-dask.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/array-api-tests-dask.yml b/.github/workflows/array-api-tests-dask.yml index b0ce007e..78010233 100644 --- a/.github/workflows/array-api-tests-dask.yml +++ b/.github/workflows/array-api-tests-dask.yml @@ -7,6 +7,7 @@ jobs: uses: ./.github/workflows/array-api-tests.yml with: package-name: dask + package-version: '>= 2024.9.0' module-name: dask.array extra-requires: numpy pytest-extra-args: --disable-deadline --max-examples=5 From 25ede3b9ba0f03b51d9c73d190c03d997e762e96 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 13 Oct 2024 18:27:12 -0400 Subject: [PATCH 15/17] drop 3.9 --- .github/workflows/array-api-tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/array-api-tests.yml b/.github/workflows/array-api-tests.yml index 254e4e61..41222d7e 100644 --- a/.github/workflows/array-api-tests.yml +++ b/.github/workflows/array-api-tests.yml @@ -40,7 +40,8 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.9', '3.10', '3.11', '3.12'] + # min version of dask we needs drops support for python 3.9 + python-version: ${{ inputs.package-name == 'dask' && ['3.10', '3.11', '3.12'] || ['3.9', '3.10', '3.11', '3.12'] }} steps: - name: Checkout array-api-compat From 884b6108a2de75056fecd16f4d2f4439e3566280 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Mon, 14 Oct 2024 16:54:38 -0400 Subject: [PATCH 16/17] try using fromjson --- .github/workflows/array-api-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/array-api-tests.yml b/.github/workflows/array-api-tests.yml index 41222d7e..e0d5d84e 100644 --- a/.github/workflows/array-api-tests.yml +++ b/.github/workflows/array-api-tests.yml @@ -41,7 +41,7 @@ jobs: strategy: matrix: # min version of dask we needs drops support for python 3.9 - python-version: ${{ inputs.package-name == 'dask' && ['3.10', '3.11', '3.12'] || ['3.9', '3.10', '3.11', '3.12'] }} + python-version: ${{ inputs.package-name == 'dask' && fromJson('[''3.10'', ''3.11'', ''3.12'']') || fromJson('[''3.9'', ''3.10'', ''3.11'', ''3.12'']') }} steps: - name: Checkout array-api-compat From 2182b4fa6e06b8c967f59f4c205c4842119aa1d1 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Tue, 15 Oct 2024 15:44:21 -0400 Subject: [PATCH 17/17] update comment --- array_api_compat/dask/array/fft.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/array_api_compat/dask/array/fft.py b/array_api_compat/dask/array/fft.py index 74de1df6..aebd86f7 100644 --- a/array_api_compat/dask/array/fft.py +++ b/array_api_compat/dask/array/fft.py @@ -1,7 +1,7 @@ from dask.array.fft import * # noqa: F403 -# cupy.fft doesn't have __all__. If it is added, replace this with +# dask.array.fft doesn't have __all__. If it is added, replace this with # -# from cupy.fft import __all__ as linalg_all +# from dask.array.fft import __all__ as linalg_all _n = {} exec('from dask.array.fft import *', _n) del _n['__builtins__']