From d1f2b02046f490c96d1a2c5a7d311feb3e0e8e63 Mon Sep 17 00:00:00 2001 From: Evgeni Burovski Date: Sat, 18 Jan 2025 19:07:43 +0200 Subject: [PATCH 1/5] ENH: allow xp.real and xp.conj of real fp inputs --- src/array_api_stubs/_draft/elementwise_functions.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/array_api_stubs/_draft/elementwise_functions.py b/src/array_api_stubs/_draft/elementwise_functions.py index fa9390a01..795a975e9 100644 --- a/src/array_api_stubs/_draft/elementwise_functions.py +++ b/src/array_api_stubs/_draft/elementwise_functions.py @@ -869,7 +869,7 @@ def conj(x: array, /) -> array: Parameters ---------- x: array - input array. Should have a complex floating-point data type. + input array. Should have a floating-point data type. Returns ------- @@ -880,6 +880,9 @@ def conj(x: array, /) -> array: ----- .. versionadded:: 2022.12 + + If ``x`` array has a real floating-point dtype, the returned array is a copy of ``x``. + """ @@ -2346,7 +2349,7 @@ def real(x: array, /) -> array: Parameters ---------- x: array - input array. Should have a complex floating-point data type. + input array. Should have a floating-point data type. Returns ------- @@ -2357,6 +2360,9 @@ def real(x: array, /) -> array: ----- .. versionadded:: 2022.12 + + If ``x`` array has a real floating-point dtype, the returned array is a copy of ``x``. + """ From dd398c63ed575ccee5dd1e1556b420287a4631bc Mon Sep 17 00:00:00 2001 From: Evgeni Burovski Date: Mon, 20 Jan 2025 20:59:06 +0200 Subject: [PATCH 2/5] MAINT: allow real adn conj return views or copies --- src/array_api_stubs/_draft/elementwise_functions.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/array_api_stubs/_draft/elementwise_functions.py b/src/array_api_stubs/_draft/elementwise_functions.py index 795a975e9..364a0a2c6 100644 --- a/src/array_api_stubs/_draft/elementwise_functions.py +++ b/src/array_api_stubs/_draft/elementwise_functions.py @@ -881,8 +881,9 @@ def conj(x: array, /) -> array: .. versionadded:: 2022.12 - If ``x`` array has a real floating-point dtype, the returned array is a copy of ``x``. - + A conforming implementation may return a "view" into the input array or a copy. Therefore, whether + the output array and the input array share the underlying memory buffer is unspecified and + thus implementation-defined. """ @@ -2361,8 +2362,9 @@ def real(x: array, /) -> array: .. versionadded:: 2022.12 - If ``x`` array has a real floating-point dtype, the returned array is a copy of ``x``. - + A conforming implementation may return a "view" into the input array or a copy. Therefore, whether + the output array and the input array share the underlying memory buffer is unspecified and + thus implementation-defined. """ From 4565e262286140596f141d4f232da09c14b584ea Mon Sep 17 00:00:00 2001 From: Evgeni Burovski Date: Mon, 20 Jan 2025 21:31:24 +0200 Subject: [PATCH 3/5] Allow real and conj of any numeric dtypes Co-authored-by: Athan --- src/array_api_stubs/_draft/elementwise_functions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/array_api_stubs/_draft/elementwise_functions.py b/src/array_api_stubs/_draft/elementwise_functions.py index 364a0a2c6..a049e13db 100644 --- a/src/array_api_stubs/_draft/elementwise_functions.py +++ b/src/array_api_stubs/_draft/elementwise_functions.py @@ -869,7 +869,7 @@ def conj(x: array, /) -> array: Parameters ---------- x: array - input array. Should have a floating-point data type. + input array. Should have a numeric data type. Returns ------- @@ -2350,7 +2350,7 @@ def real(x: array, /) -> array: Parameters ---------- x: array - input array. Should have a floating-point data type. + input array. Should have a numeric data type. Returns ------- From 0b6b3a775ab654fcf8a0978012345ed0969016c3 Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 22 Jan 2025 18:10:53 -0800 Subject: [PATCH 4/5] docs: update copy --- .../_draft/elementwise_functions.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/array_api_stubs/_draft/elementwise_functions.py b/src/array_api_stubs/_draft/elementwise_functions.py index a049e13db..6fad1630c 100644 --- a/src/array_api_stubs/_draft/elementwise_functions.py +++ b/src/array_api_stubs/_draft/elementwise_functions.py @@ -869,7 +869,7 @@ def conj(x: array, /) -> array: Parameters ---------- x: array - input array. Should have a numeric data type. + input array. Must have a numeric data type. Returns ------- @@ -879,11 +879,9 @@ def conj(x: array, /) -> array: Notes ----- - .. versionadded:: 2022.12 + - Whether or not the returned array and the input array share the same underlying memory is unspecified and thus implementation-defined. - A conforming implementation may return a "view" into the input array or a copy. Therefore, whether - the output array and the input array share the underlying memory buffer is unspecified and - thus implementation-defined. + .. versionadded:: 2022.12 """ @@ -2350,7 +2348,7 @@ def real(x: array, /) -> array: Parameters ---------- x: array - input array. Should have a numeric data type. + input array. Must have a numeric data type. Returns ------- @@ -2360,11 +2358,9 @@ def real(x: array, /) -> array: Notes ----- - .. versionadded:: 2022.12 + - Whether or not the returned array and the input array share the same underlying memory is unspecified and thus implementation-defined. - A conforming implementation may return a "view" into the input array or a copy. Therefore, whether - the output array and the input array share the underlying memory buffer is unspecified and - thus implementation-defined. + .. versionadded:: 2022.12 """ From a4a8201e76fb5ca0da8a4adb62c0c0bcc425c967 Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 5 Feb 2025 18:55:08 -0800 Subject: [PATCH 5/5] docs: remove unnecessary words --- src/array_api_stubs/_draft/elementwise_functions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/array_api_stubs/_draft/elementwise_functions.py b/src/array_api_stubs/_draft/elementwise_functions.py index 6fad1630c..119881adc 100644 --- a/src/array_api_stubs/_draft/elementwise_functions.py +++ b/src/array_api_stubs/_draft/elementwise_functions.py @@ -879,7 +879,7 @@ def conj(x: array, /) -> array: Notes ----- - - Whether or not the returned array and the input array share the same underlying memory is unspecified and thus implementation-defined. + - Whether the returned array and the input array share the same underlying memory is unspecified and thus implementation-defined. .. versionadded:: 2022.12 """ @@ -2358,7 +2358,7 @@ def real(x: array, /) -> array: Notes ----- - - Whether or not the returned array and the input array share the same underlying memory is unspecified and thus implementation-defined. + - Whether the returned array and the input array share the same underlying memory is unspecified and thus implementation-defined. .. versionadded:: 2022.12 """