Skip to content

Commit 319b833

Browse files
committed
revert vendoring of scipy functions, which caused circular dependencies in Intel NumPy
1 parent b466be8 commit 319b833

File tree

3 files changed

+53
-94
lines changed

3 files changed

+53
-94
lines changed

mkl_fft/interfaces/_scipy_fft.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from numbers import Number
3636

3737
import mkl
38+
import scipy
3839
import numpy as np
3940

4041
import mkl_fft
@@ -61,6 +62,10 @@
6162
"ihfft2",
6263
"hfftn",
6364
"ihfftn",
65+
"fftshift",
66+
"ifftshift",
67+
"fftfreq",
68+
"rfftfreq",
6469
"get_workers",
6570
"set_workers",
6671
]
@@ -650,6 +655,50 @@ def ihfftn(
650655
return result
651656

652657

658+
# define thin wrappers for scipy functions to avoid circular dependencies
659+
def fftfreq(n, d=1.0, *, xp=None, device=None):
660+
"""
661+
Return the Discrete Fourier Transform sample frequencies.
662+
663+
For full documentation refer to `scipy.fft.fftfreq`.
664+
665+
"""
666+
return scipy.fft.fftfreq(n, d=d, xp=xp, device=device)
667+
668+
669+
def rfftfreq(n, d=1.0, *, xp=None, device=None):
670+
"""
671+
Return the Discrete Fourier Transform sample frequencies (for usage with
672+
`rfft`, `irfft`).
673+
674+
For full documentation refer to `scipy.fft.rfftfreq`.
675+
676+
"""
677+
return scipy.fft.rfftfreq(n, d=d, xp=xp, device=device)
678+
679+
680+
def fftshift(x, axes=None):
681+
"""
682+
Shift the zero-frequency component to the center of the spectrum.
683+
684+
For full documentation refer to `scipy.fft.fftshift`.
685+
686+
"""
687+
from scipy.fft import fftshift
688+
return fftshift(x, axes=axes)
689+
690+
691+
def ifftshift(x, axes=None):
692+
"""
693+
The inverse of `fftshift`. Although identical for even-length `x`, the
694+
functions differ by one sample for odd-length `x`.
695+
696+
For full documentation refer to `scipy.fft.ifftshift`.
697+
698+
"""
699+
return scipy.fft.ifftshift(x, axes=axes)
700+
701+
653702
def get_workers():
654703
"""
655704
Gets the number of workers used by mkl_fft by default.

mkl_fft/interfaces/_scipy_helper.py

Lines changed: 0 additions & 93 deletions
This file was deleted.

mkl_fft/interfaces/scipy_fft.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,17 @@
2828
from ._scipy_fft import (
2929
fft,
3030
fft2,
31+
fftfreq,
3132
fftn,
33+
fftshift,
3234
get_workers,
3335
hfft,
3436
hfft2,
3537
hfftn,
3638
ifft,
3739
ifft2,
3840
ifftn,
41+
ifftshift,
3942
ihfft,
4043
ihfft2,
4144
ihfftn,
@@ -44,10 +47,10 @@
4447
irfftn,
4548
rfft,
4649
rfft2,
50+
rfftfreq,
4751
rfftn,
4852
set_workers,
4953
)
50-
from ._scipy_helper import fftfreq, fftshift, ifftshift, rfftfreq
5154

5255
__all__ = [
5356
"fft",

0 commit comments

Comments
 (0)