Skip to content

Commit a162685

Browse files
committed
add test for reentrant behavior with mkl_fft context manager
also use from mkl_fft import interfaces to avoid redundant mkl_fft module in namespace
1 parent 9771697 commit a162685

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

mkl_fft/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
)
4747
from ._version import __version__
4848

49-
import mkl_fft.interfaces # isort: skip
49+
from mkl_fft import interfaces # isort: skip
5050

5151
__all__ = [
5252
"fft",

mkl_fft/tests/test_patch.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,22 @@ def test_patch_redundant_patching():
5959
mkl_fft.restore_numpy_fft()
6060
assert not mkl_fft.is_patched()
6161
assert np.fft.fft.__module__ == old_module
62+
63+
64+
def test_patch_reentrant():
65+
old_module = np.fft.fft.__module__
66+
assert not mkl_fft.is_patched()
67+
68+
with mkl_fft.mkl_fft():
69+
assert mkl_fft.is_patched()
70+
assert np.fft.fft.__module__ == _nfft.fft.__module__
71+
72+
with mkl_fft.mkl_fft():
73+
assert mkl_fft.is_patched()
74+
assert np.fft.fft.__module__ == _nfft.fft.__module__
75+
76+
assert mkl_fft.is_patched()
77+
assert np.fft.fft.__module__ == _nfft.fft.__module__
78+
79+
assert not mkl_fft.is_patched()
80+
assert np.fft.fft.__module__ == old_module

0 commit comments

Comments
 (0)