Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Replaced `fwd_scale` parameter with `norm` in `mkl_fft` [gh-189](https://github.com/IntelPython/mkl_fft/pull/189)
* Dropped support for `scipy.fftpack` interface [gh-185](https://github.com/IntelPython/mkl_fft/pull/185)
* Dropped support for `overwrite_x` parameter in `mkl_fft` [gh-185](https://github.com/IntelPython/mkl_fft/pull/185)
* Added thin wrappers for `fftfreq`, `rfftfreq`, `fftshift`, and `ifftshift` to `scipy_fft` interface [gh-226](https://github.com/IntelPython/mkl_fft/pull/226)

### Fixed
* Fixed a bug for N-D FFTs when both `s` and `out` are given [gh-185](https://github.com/IntelPython/mkl_fft/pull/185)
Expand Down
48 changes: 48 additions & 0 deletions mkl_fft/interfaces/_scipy_fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import mkl
import numpy as np
import scipy

import mkl_fft

Expand All @@ -61,6 +62,10 @@
"ihfft2",
"hfftn",
"ihfftn",
"fftshift",
"ifftshift",
"fftfreq",
"rfftfreq",
"get_workers",
"set_workers",
]
Expand Down Expand Up @@ -650,6 +655,49 @@ def ihfftn(
return result


# define thin wrappers for scipy functions to avoid circular dependencies
def fftfreq(n, d=1.0, *, xp=None, device=None):
"""
Return the Discrete Fourier Transform sample frequencies.

For full documentation refer to `scipy.fft.fftfreq`.

"""
return scipy.fft.fftfreq(n, d=d, xp=xp, device=device)


def rfftfreq(n, d=1.0, *, xp=None, device=None):
"""
Return the Discrete Fourier Transform sample frequencies (for usage with
`rfft`, `irfft`).

For full documentation refer to `scipy.fft.rfftfreq`.

"""
return scipy.fft.rfftfreq(n, d=d, xp=xp, device=device)


def fftshift(x, axes=None):
"""
Shift the zero-frequency component to the center of the spectrum.

For full documentation refer to `scipy.fft.fftshift`.

"""
return scipy.fft.fftshift(x, axes=axes)


def ifftshift(x, axes=None):
"""
The inverse of `fftshift`. Although identical for even-length `x`, the
functions differ by one sample for odd-length `x`.

For full documentation refer to `scipy.fft.ifftshift`.

"""
return scipy.fft.ifftshift(x, axes=axes)


def get_workers():
"""
Gets the number of workers used by mkl_fft by default.
Expand Down
8 changes: 4 additions & 4 deletions mkl_fft/interfaces/scipy_fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,21 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


# Added for completing the namespaces
from scipy.fft import fftfreq, fftshift, ifftshift, rfftfreq

# pylint: disable=no-name-in-module
from ._scipy_fft import (
fft,
fft2,
fftfreq,
fftn,
fftshift,
get_workers,
hfft,
hfft2,
hfftn,
ifft,
ifft2,
ifftn,
ifftshift,
ihfft,
ihfft2,
ihfftn,
Expand All @@ -48,6 +47,7 @@
irfftn,
rfft,
rfft2,
rfftfreq,
rfftn,
set_workers,
)
Expand Down
Loading