Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 73e7228

Browse filesBrowse files
authored
feat: add dtype kwarg support to fftfreq and rfftfreq
PR-URL: #885 Closes: #717 Reviewed-by: Evgeni Burovski
1 parent 52bbfeb commit 73e7228
Copy full SHA for 73e7228

File tree

Expand file treeCollapse file tree

1 file changed

+23
-5
lines changed
Filter options
  • src/array_api_stubs/_draft
Expand file treeCollapse file tree

1 file changed

+23
-5
lines changed

‎src/array_api_stubs/_draft/fft.py

Copy file name to clipboardExpand all lines: src/array_api_stubs/_draft/fft.py
+23-5Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"ifftshift",
1616
]
1717

18-
from ._types import Tuple, Union, Sequence, array, Optional, Literal, device
18+
from ._types import Tuple, Union, Sequence, array, Optional, Literal, dtype, device
1919

2020

2121
def fft(
@@ -551,7 +551,14 @@ def ihfft(
551551
"""
552552

553553

554-
def fftfreq(n: int, /, *, d: float = 1.0, device: Optional[device] = None) -> array:
554+
def fftfreq(
555+
n: int,
556+
/,
557+
*,
558+
d: float = 1.0,
559+
dtype: Optional[dtype] = None,
560+
device: Optional[device] = None,
561+
) -> array:
555562
"""
556563
Computes the discrete Fourier transform sample frequencies.
557564
@@ -568,13 +575,15 @@ def fftfreq(n: int, /, *, d: float = 1.0, device: Optional[device] = None) -> ar
568575
window length.
569576
d: float
570577
sample spacing between individual samples of the Fourier transform input. Default: ``1.0``.
578+
dtype: Optional[dtype]
579+
output array data type. Must be a real-valued floating-point data type. If ``dtype`` is ``None``, the output array data type must be the default real-valued floating-point data type. Default: ``None``.
571580
device: Optional[device]
572581
device on which to place the created array. Default: ``None``.
573582
574583
Returns
575584
-------
576585
out: array
577-
an array of shape ``(n,)`` containing the sample frequencies. The returned array must have the default real-valued floating-point data type.
586+
an array of shape ``(n,)`` containing the sample frequencies.
578587
579588
Notes
580589
-----
@@ -586,7 +595,14 @@ def fftfreq(n: int, /, *, d: float = 1.0, device: Optional[device] = None) -> ar
586595
"""
587596

588597

589-
def rfftfreq(n: int, /, *, d: float = 1.0, device: Optional[device] = None) -> array:
598+
def rfftfreq(
599+
n: int,
600+
/,
601+
*,
602+
d: float = 1.0,
603+
dtype: Optional[dtype] = None,
604+
device: Optional[device] = None,
605+
) -> array:
590606
"""
591607
Computes the discrete Fourier transform sample frequencies (for ``rfft`` and ``irfft``).
592608
@@ -605,13 +621,15 @@ def rfftfreq(n: int, /, *, d: float = 1.0, device: Optional[device] = None) -> a
605621
window length.
606622
d: float
607623
sample spacing between individual samples of the Fourier transform input. Default: ``1.0``.
624+
dtype: Optional[dtype]
625+
output array data type. Must be a real-valued floating-point data type. If ``dtype`` is ``None``, the output array data type must be the default real-valued floating-point data type. Default: ``None``.
608626
device: Optional[device]
609627
device on which to place the created array. Default: ``None``.
610628
611629
Returns
612630
-------
613631
out: array
614-
an array of shape ``(n//2+1,)`` containing the sample frequencies. The returned array must have the default real-valued floating-point data type.
632+
an array of shape ``(n//2+1,)`` containing the sample frequencies.
615633
616634
Notes
617635
-----

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.