test_fft_function.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import numpy as np
  2. import subprocess
  3. import sys
  4. TEST_BODY = r"""
  5. import pytest
  6. import numpy as np
  7. from numpy.testing import assert_allclose
  8. import scipy
  9. import sys
  10. import pytest
  11. np.random.seed(1234)
  12. x = np.random.randn(10) + 1j * np.random.randn(10)
  13. X = np.fft.fft(x)
  14. # Callable before scipy.fft is imported
  15. with pytest.deprecated_call(match=r'2\.0\.0'):
  16. y = scipy.ifft(X)
  17. assert_allclose(y, x)
  18. # Callable after scipy.fft is imported
  19. import scipy.fft
  20. with pytest.deprecated_call(match=r'2\.0\.0'):
  21. y = scipy.ifft(X)
  22. assert_allclose(y, x)
  23. """
  24. def test_fft_function():
  25. # Historically, scipy.fft was an alias for numpy.fft.fft
  26. # Ensure there are no conflicts with the FFT module (gh-10253)
  27. # Test must run in a subprocess so scipy.fft is not already imported
  28. subprocess.check_call([sys.executable, '-c', TEST_BODY])
  29. # scipy.fft is the correct module
  30. from scipy import fft
  31. assert not callable(fft)
  32. assert fft.__name__ == 'scipy.fft'
  33. from scipy import ifft
  34. assert ifft.__wrapped__ is np.fft.ifft