Skip to content

Commit be6330a

Browse files
authored
Apply suggestions from code review
1 parent 46e504a commit be6330a

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

spec/API_specification/array_api/fourier_transform_functions.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,17 @@ def fftn(x: array, /, *, s: Sequence[int] = None, axes: Sequence[int] = None, no
8888
s: Sequence[int]
8989
size of each transformed axis of the output. If
9090
91-
- ``s[i]`` is greater than the size of the input array along a corresponding axis (dimension) ``j``, the corresponding axis of the input array must be zero-padded such that the axis has size ``s[i]``.
92-
- ``s[i]`` is less than the size of the input array along a corresponding axis (dimension) ``j``, the corresponding axis of the input array must be trimmed such that the axis has size``s[i]``.
91+
- ``s[i]`` is greater than the size of the input array along a corresponding axis (dimension) ``i``, the corresponding axis of the input array must be zero-padded such that the axis has size ``s[i]``.
92+
- ``s[i]`` is less than the size of the input array along a corresponding axis (dimension) ``i``, the corresponding axis of the input array must be trimmed such that the axis has size ``s[i]``.
9393
94-
If ``axes`` is ``None``, the last ``len(s)`` axes must be transformed, and, thus, ``j`` represents an axis index computed according to ``N - len(s) + i``, where ``N`` is the number of axes (e.g., if ``N = 4`` and ``s = (256, 256)``, then ``i = 0`` corresponds to axis ``2`` and ``i = 1`` corresponds to axis ``3``, the last axis).
9594
9695
If ``axes`` is not ``None``, size ``s[i]`` corresponds to the size of axis ``axes[j]`` where ``i == j``.
9796
9897
If not provided, the size of each transformed axis (dimension) in the output array must equal the size of the corresponding axis in the input array.
9998
10099
Default: ``None``.
101100
axes: Sequence[int]
102-
axes (dimension) over which to compute the Fourier transform. If ``None`` and ``s`` is not specified, all axes must be transformed. If ``None`` and ``s`` is specified, the last ``len(s)`` axes must be transformed. Default: ``None``.
101+
axes (dimension) over which to compute the Fourier transform. If ``None`` and ``s`` is not specified, all axes must be transformed. If ``s`` is specified, the corresponding ``axes`` to be transformed must be explicitly specified too. Default: ``None``.
103102
norm: Literal['backward', 'ortho', 'forward']
104103
normalization mode. Should be one of the following modes:
105104
@@ -203,8 +202,8 @@ def irfft(x: array, /, *, n: Optional[int] = None, axis: int = -1, norm: Literal
203202
n: int
204203
length of the transformed axis of the **output**. If
205204
206-
- ``n`` is greater than the length of the input array, the input array must be zero-padded such that the input array has length ``n``.
207-
- ``n`` is less than the length of the input array, the input array must be trimmed to length ``n//2+1``.
205+
- ``n//2+1`` is greater than the length of the input array, the input array must be zero-padded.
206+
- ``n//2+1`` is less than the length of the input array, the input array must be trimmed.
208207
209208
If not provided, the length of the transformed axis of the output must equal the length ``2 * (m - 1)`` where ``m`` is the length of the input along the axis specified by ``axis``. Default: ``None``.
210209
axis: int
@@ -343,7 +342,7 @@ def ihfft(x: array, /, *, n: Optional[int] = None, axis: int = -1, norm: Literal
343342
x: array
344343
input array. Should have a real-valued floating-point data type.
345344
n: int
346-
length of the transformed axis of the output. If
345+
length of the transformed axis of the **input**. If
347346
348347
- ``n`` is greater than the length of the input array, the input array must be zero-padded such that the input array has length ``n``.
349348
- ``n`` is less than the length of the input array, the input array must be trimmed to length ``n``.
@@ -365,7 +364,7 @@ def ihfft(x: array, /, *, n: Optional[int] = None, axis: int = -1, norm: Literal
365364
Returns
366365
-------
367366
out: array
368-
an array transformed along the axis (dimension) indicated by ``axis``. The returned array must have a real-valued floating-point data type determined by :ref:`type-promotion`.
367+
an array transformed along the axis (dimension) indicated by ``axis``. The returned array must have a complex-valued floating-point data type determined by :ref:`type-promotion`.
369368
"""
370369

371370

@@ -375,11 +374,10 @@ def fftfreq(n: int, /, *, d: float = 1.0):
375374
376375
For a Fourier transform of length ``n`` and length unit of ``d`` the frequencies are described as:
377376
378-
379377
.. code-block::
380378
381-
f = [0, 1, ..., n/2-1, -n/2, ..., -1] / (d*n) if n is even
382-
f = [0, 1, ..., (n-1)/2, -(n-1)/2, ..., -1] / (d*n) if n is odd
379+
f = [0, 1, ..., n/2-1, -n/2, ..., -1] / (d*n) # if n is even
380+
f = [0, 1, ..., (n-1)/2, -(n-1)/2, ..., -1] / (d*n) # if n is odd
383381
384382
Parameters
385383
----------
@@ -397,13 +395,14 @@ def fftfreq(n: int, /, *, d: float = 1.0):
397395

398396
def rfftfreq(n: int, /, *, d: float = 1.0):
399397
"""
400-
Returns the discrete Fourier transform sample frequencies. For a Fourier transform of length ``n`` and length unit of ``d`` the frequencies are described as:
401-
398+
Returns the discrete Fourier transform sample frequencies (for ``rfft`` and ``irfft``).
399+
400+
For a Fourier transform of length ``n`` and length unit of ``d`` the frequencies are described as:
402401
403402
.. code-block::
404403
405-
f = [0, 1, ..., n/2-1, -n/2, ..., -1] / (d*n) if n is even
406-
f = [0, 1, ..., (n-1)/2, -(n-1)/2, ..., -1] / (d*n) if n is odd
404+
f = [0, 1, ..., n/2-1, n/2] / (d*n) # if n is even
405+
f = [0, 1, ..., (n-1)/2-1, (n-1)/2] / (d*n) # if n is odd
407406
408407
The Nyquist frequency component is considered to be positive.
409408
@@ -417,15 +416,15 @@ def rfftfreq(n: int, /, *, d: float = 1.0):
417416
Returns
418417
-------
419418
out: array
420-
an array of length ``n`` containing the sample frequencies. The returned array must have a floating-point data type determined by :ref:`type-promotion`.
419+
an array of length ``n//2+1`` containing the sample frequencies. The returned array must have a floating-point data type determined by :ref:`type-promotion`.
421420
"""
422421

423422

424423
def fftshift(x: array, /, *, axes: Union[int, Sequence[int]] = None):
425424
"""
426425
Shift the zero-frequency component to the center of the spectrum.
427426
428-
This function swaps half-spaces for all axes (dimensions) specified by `axes`.
427+
This function swaps half-spaces for all axes (dimensions) specified by ``axes``.
429428
430429
.. note::
431430
``out[0]`` is the Nyquist component only if the length of the input is even.
@@ -449,7 +448,7 @@ def ifftshift(x: array, /, *, axes: Union[int, Sequence[int]] = None):
449448
Inverse of ``fftshift``.
450449
451450
.. note::
452-
Although identical for even-length ``x``, ``fftshift`` and `ifftshift`` differ by one sample for odd-length ``x``.
451+
Although identical for even-length ``x``, ``fftshift`` and ``ifftshift`` differ by one sample for odd-length ``x``.
453452
454453
Parameters
455454
----------

0 commit comments

Comments
 (0)