diff --git a/.github/workflows/conda-package-cf.yml b/.github/workflows/conda-package-cf.yml index 08084e0..9658c7c 100644 --- a/.github/workflows/conda-package-cf.yml +++ b/.github/workflows/conda-package-cf.yml @@ -301,8 +301,8 @@ jobs: - name: Report content of test environment shell: cmd /C CALL {0} run: | - echo "Value of CONDA enviroment variable was: " %CONDA% - echo "Value of CONDA_PREFIX enviroment variable was: " %CONDA_PREFIX% + echo "Value of CONDA environment variable was: " %CONDA% + echo "Value of CONDA_PREFIX environment variable was: " %CONDA_PREFIX% conda info && conda list -n ${{ env.TEST_ENV_NAME }} - name: Run tests diff --git a/.github/workflows/conda-package.yml b/.github/workflows/conda-package.yml index 9cbd85c..e430a06 100644 --- a/.github/workflows/conda-package.yml +++ b/.github/workflows/conda-package.yml @@ -301,8 +301,8 @@ jobs: - name: Report content of test environment shell: cmd /C CALL {0} run: | - echo "Value of CONDA enviroment variable was: " %CONDA% - echo "Value of CONDA_PREFIX enviroment variable was: " %CONDA_PREFIX% + echo "Value of CONDA environment variable was: " %CONDA% + echo "Value of CONDA_PREFIX environment variable was: " %CONDA_PREFIX% conda info && conda list -n ${{ env.TEST_ENV_NAME }} - name: Run tests shell: cmd /C CALL {0} diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 00da4d6..b47cb29 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -20,13 +20,18 @@ jobs: with: python-version: '3.12' - - uses: BSFishy/pip-action@v1 + - name: Set up pip packages + uses: BSFishy/pip-action@v1 with: packages: | + codespell pylint - - name: Version of clang-format + - name: Set up clang-format run: | + sudo apt-get install -y clang-format-14 + sudo unlink /usr/bin/clang-format + sudo ln -s /usr/bin/clang-format-14 /usr/bin/clang-format clang-format --version - name: Run pre-commit checks diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d5fa280..1196670 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,6 +15,28 @@ repos: - id: mixed-line-ending - id: trailing-whitespace +- repo: https://github.com/pre-commit/pygrep-hooks + rev: v1.10.0 + hooks: + - id: python-check-blanket-noqa + - id: python-check-blanket-type-ignore + - id: python-check-mock-methods + - id: python-no-eval + - id: python-no-log-warn + - id: python-use-type-annotations + - id: rst-backticks + - id: rst-directive-colons + - id: rst-inline-touching-normal + - id: text-unicode-replacement-char + +- repo: https://github.com/codespell-project/codespell + rev: v2.4.1 + hooks: + - id: codespell + args: ["-L", "nd"] # ignore "nd" used for n-dimensional + additional_dependencies: + - tomli + - repo: https://github.com/psf/black rev: 25.1.0 hooks: diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..5d752a8 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,174 @@ +# changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [dev] (MM/DD/YY) + +### Added +* SciPy interface `mkl_fft.interfaces.scipy_fft` now includes Hermitian FFT functions: `hfft`, `ihfft`, `hfftn`, `ihfftn`, `hfft2`, and `ihfft2` [gh-161](https://github.com/IntelPython/mkl_fft/pull/161) + +## [1.3.14] (04/10/2025) + +resolves gh-152 by adding an explicit `mkl-service` dependency to `mkl-fft` when building the wheel +to ensure the `mkl` Python module is always available at runtime + +resolves gh-115, gh-116, gh-119, gh-135 + +## [1.3.13] (03/25/2025) + +Supported python versions are 3.9, 3.10, 3.11, 3.12 + +migrate from `setup.py` to `pyproject.toml` + +includes support in virtual environment out of the box + +the original `mkl_fft.rfft` and `mkl_fft.irfft` are renamed to `mkl_fft.rfftpack` and `mkl_fft.irfftpack`, +since they replicate the behavior from the deprecated `scipy.fftpack` module. + +`mkl_fft.rfft_numpy`, `mkl_fft.irfft_numpy`, `mkl_fft.rfft2_numpy`, `mkl_fft.irfft2_numpy`, +`mkl_fft.rfftn_numpy`, and `mkl_fft.irfftn_numpy` are renamed to `mkl_fft.rfft`, `mkl_fft.irfft`, +`mkl_fft.rfft2`, `mkl_fft.irfft2`, `mkl_fft.rfftn`, and `mkl_fft.irfftn`, respectively. +(consistent with `numpy.fft` and `scipy.fft` modules) + +file `_scipy_fft_backend.py` is renamed to `_scipy_fft.py` since it replicates `scipy.fft` module +(similar to file `_numpy_fft.py` which replicates `numpy.fft` module) + +## [1.3.11] + +Bugfix release, resolving gh-109 and updating installation instructions + +## [1.3.10] + +Bugfix release, resolving leftover uses of NumPy attributes removed in NumPy 2.0 that break +test suite run on Windows. + +## [1.3.9] + +Updated code and build system to support NumPy 2.0 + +## [1.3.8] + +Added vendored `conv_template.py` from NumPy's distutils submodule to enable building of `mkl_fft` with +NumPy >=1.25 and Python 3.12 + +## [1.3.7] + +Updated build system away from removed in NumPy 1.25 numpy.distutils module. + +Transitioned to Cython 3.0. + +## [1.3.0] + +Updated numpy interface to support new in NumPy 1.20 supported values of norm keyword, such as "forward" and "backward". +To enable this, `mkl_fft` functions now support `forward_scale` parameter that defaults to 1. + +Fixed issue #48. + +## [1.2.1] + +Includes bug fix #54 + +## [1.2.0] + +Due to removal of deprecated real-to-real FFT with `DFTI_CONJUGATE_EVEN_STORAGE=DFTI_COMPLEX_REAL` and +`DFTI_PACKED_FORMAT=DFTI_PACK` from Intel(R) Math Kernel Library, reimplemented `mkl_fft.rfft` and +`mkl_fft.irfft` to use real-to-complex functionality with subsequent copying to rearange the transform as expected +of `mkl_fft.rfft`, with the associated performance penalty. The use of the real-to-complex +transform improves multi-core utilization which may offset the performance loss incurred due to copying. + +## [1.1.0] + +Added `scipy.fft` backend, see #42. Fixed #46. + + +```python +>>> import numpy as np, mkl_fft, mkl_fft._scipy_fft as mkl_be, scipy, scipy.fft, mkl + +>>> mkl.verbose(1) +# True + +>>> x = np.random.randn(8*7).reshape((7, 8)) +>>> with scipy.fft.set_backend(mkl_be, only=True): +>>> ff = scipy.fft.fft2(x, workers=4) +>>> ff2 = scipy.fft.fft2(x) +# MKL_VERBOSE Intel(R) MKL 2020.0 Product build 20191102 for Intel(R) 64 architecture Intel(R) Advanced Vector Extensions 2 (Intel(R) AVX2) enabled processors, Lnx 2.40GHz intel_thread +# MKL_VERBOSE FFT(drfo7:8:8x8:1:1,bScale:0.0178571,tLim:1,desc:0x5629ad31b800) 24.85ms CNR:OFF Dyn:1 FastMM:1 TID:0 NThr:16,FFT:4 + +>>> np.allclose(ff, ff2) +# True +``` + +## [1.0.15] + +Changed tests to not compare against numpy fft, as this broke due to renaming of `np.fft.pocketfft` to +`np.fft._pocketfft`. Instead compare against naive realization of 1D FFT as a sum. + +Setup script is now aware of `MKLROOT` environment variable. If unset, NumPy's mkl_info will be queried. + +## [1.0.14] + +Fixed unreferenced bug in `irfftn_numpy`, and adjusted NumPy interfaces to change to pocketfft in NumPy 1.17 + +## [1.0.13] + +Issue #39 fixed (memory leak with complex FFT on real arrays) + +## [1.0.12] + +Issue #37 fixed. + +Inhibited vectorization of short loops computing pointer to memory referenced by a multi-iterator by Intel (R) C Compiler, +improving performance of ND `fft` and `ifft` on real input arrays. + +## [1.0.11] + +Improvement for performance of ND `fft` on real input arrays by inlining multi-iterators. +This particularly benefits performance of mkl_fft built with Intel (R) C Compiler. + +## [1.0.10] + +Fix for issue #29. + +## [1.0.7] + +Improved exception message raised if MKL is signalling an error. The message now includes MKL's own description of the exception. +This partially improves #24. + +Improved argument validation for ND transforms aligning with scipy 1.2.0 + +## [1.0.6] + +Fixed issues #21, and addressed NumPy 1.15 deprecation warnings from using lists instead of tuples to specify multiple slices. + +## [1.0.5] + +Fixed issues #7, #17, #18. +Consolidated version specification into a single file `mkl_fft/_version.py`. + +## [1.0.4] + +Added CHANGES.rst. Fixed issue #11 by using lock around calls to 1D FFT routines. + +## [1.0.3] + +This is a bug fix release. + +It fixes issues #9, and #13. + +As part of fixing issue #13, out-of-place 1D FFT calls such as `fft`, `ifft`, `rfft_numpy` +and `irfftn_numpy` will allocate Fortran layout array for the output is the input is a Fotran array. + +## [1.0.2] + +Minor update of `mkl_fft`, reflecting renaming of `numpy.core.multiarray_tests` module to +`numpy.core._multiarray_tests` as well as fixing #4. + +## [1.0.1] + +Bug fix release. + +## [1.0.0] + +Initial release of `mkl_fft`. diff --git a/CHANGES.rst b/CHANGES.rst deleted file mode 100644 index f7cd942..0000000 --- a/CHANGES.rst +++ /dev/null @@ -1,211 +0,0 @@ -========================= -:code:`mkl_fft` changelog -========================= - -[dev] (MM/DD/YY) -================== - -scipy interface :code:`mkl_fft.interfaces.scipy_fft` now includes Hermitian FFT functions: -:code:`hfft`, :code:`ihfft`, :code:`hfftn`, :code:`ihfftn`, :code:`hfft2`, and :code:`ihfft2` - -1.3.14 (04/11/2025) -=================== - -resolves gh-152 by adding an explicit :code:`mkl-service` dependency to :code:`mkl-fft` when building the wheel -to ensure the :code:`mkl` Python module is always available at runtime - -resolves gh-115, gh-116, gh-119, gh-135 - - -1.3.13 (03/25/2025) -=================== - -Supported python versions are 3.9, 3.10, 3.11, 3.12 - -migrate from :code:`setup.py` to :code:`pyproject.toml` - -includes support in virtual environment out of the box - -the original :code:`mkl_fft.rfft` and :code:`mkl_fft.irfft` are renamed to :code:`mkl_fft.rfftpack` and :code:`mkl_fft.irfftpack`, -since they replicate the behavior from the deprecated :code:`scipy.fftpack` module. - -:code:`mkl_fft.rfft_numpy`, :code:`mkl_fft.irfft_numpy`, :code:`mkl_fft.rfft2_numpy`, :code:`mkl_fft.irfft2_numpy`, -:code:`mkl_fft.rfftn_numpy`, and :code:`mkl_fft.irfftn_numpy` are renamed to :code:`mkl_fft.rfft`, :code:`mkl_fft.irfft`, -:code:`mkl_fft.rfft2`, :code:`mkl_fft.irfft2`, `mkl_fft.rfftn`, and :code:`mkl_fft.irfftn`, respectively. -(consistent with :code:`numpy.fft` and :code:`scipy.fft` modules) - -file :code:`_scipy_fft_backend.py` is renamed to :code:`_scipy_fft.py` since it replicates :code:`scipy.fft` module -(similar to file :code:`_numpy_fft.py` which replicates :code:`numpy.fft` module) - -1.3.11 -====== - -Bugfix release, resolving gh-109 and updating installation instructions - - -1.3.10 -====== - -Bugfix release, resolving leftover uses of NumPy attributes removed in NumPy 2.0 that break -test suite run on Windows. - -1.3.9 -===== - -Updated code and build system to support NumPy 2.0 - -1.3.8 -===== - -Added vendored :code:`conv_template.py` from NumPy's distutils submodule to enable building of :code:`mkl_fft` with -NumPy >=1.25 and Python 3.12 - -1.3.7 -===== - -Updated build system away from removed in NumPy 1.25 numpy.distutils module. - -Transitioned to Cython 3.0. - - -1.3.0 -===== - -Updated numpy interface to support new in NumPy 1.20 supported values of norm keyword, such as "forward" and "backward". -To enable this, :code:`mkl_fft` functions now support `forward_scale` parameter that defaults to 1. - -Fixed issue #48. - -1.2.1 -===== - -Includes bug fix #54 - -1.2.0 -===== - -Due to removal of deprecated real-to-real FFT with :code:`DFTI_CONJUGATE_EVEN_STORAGE=DFTI_COMPLEX_REAL` and -:code:`DFTI_PACKED_FORMAT=DFTI_PACK` from Intel(R) Math Kernel Library, reimplemented :code:`mkl_fft.rfft` and -:code:`mkl_fft.irfft` to use real-to-complex functionality with subsequent copying to rearange the transform as expected -of :code:`mkl_fft.rfft`, with the associated performance penalty. The use of the real-to-complex -transform improves multi-core utilization which may offset the performance loss incurred due to copying. - - -1.1.0 -===== - -Added :code:`scipy.fft` backend, see #42. Fixed #46. - - -.. code-block:: python - - Python 3.7.5 (default, Nov 23 2019, 04:02:01) - Type 'copyright', 'credits' or 'license' for more information - IPython 7.11.1 -- An enhanced Interactive Python. Type '?' for help. - - In [1]: import numpy as np, mkl_fft, mkl_fft._scipy_fft as mkl_be, scipy, scipy.fft, mkl - - In [2]: mkl.verbose(1) - Out[2]: True - - In [3]: x = np.random.randn(8*7).reshape((7, 8)) - ...: with scipy.fft.set_backend(mkl_be, only=True): - ...: ff = scipy.fft.fft2(x, workers=4) - ...: ff2 = scipy.fft.fft2(x) - MKL_VERBOSE Intel(R) MKL 2020.0 Product build 20191102 for Intel(R) 64 architecture Intel(R) Advanced Vector Extensions 2 (Intel(R) AVX2) enabled processors, Lnx 2.40GHz intel_thread - MKL_VERBOSE FFT(drfo7:8:8x8:1:1,bScale:0.0178571,tLim:1,desc:0x5629ad31b800) 24.85ms CNR:OFF Dyn:1 FastMM:1 TID:0 NThr:16,FFT:4 - - In [4]: np.allclose(ff, ff2) - Out[4]: True - - -1.0.15 -====== - -Changed tests to not compare against numpy fft, as this broke due to renaming of :code:`np.fft.pocketfft` to -:code:`np.fft._pocketfft`. Instead compare against naive realization of 1D FFT as a sum. - -Setup script is now aware of :code:`MKLROOT` environment variable. If unset, NumPy's mkl_info will be queried. - - -1.0.14 -====== - -Fixed unreferenced bug in :code:`irfftn_numpy`, and adjusted NumPy interfaces to change to pocketfft in NumPy 1.17 - - -1.0.13 -====== - -Issue #39 fixed (memory leak with complex FFT on real arrays) - - -1.0.12 -====== -Issue #37 fixed. - -Inhibited vectorization of short loops computing pointer to memory referenced by a multi-iterator by Intel (R) C Compiler, -improving performance of ND :code:`fft` and :code:`ifft` on real input arrays. - - -1.0.11 -====== -Improvement for performance of ND `fft` on real input arrays by inlining multi-iterators. -This particularly benefits performance of mkl_fft built with Intel (R) C Compiler. - - -1.0.10 -====== -Fix for issue #29. - - -1.0.7 -===== -Improved exception message raised if MKL is signalling an error. The message now includes MKL's own description of the exception. -This partially improves #24. - -Improved argument validation for ND transforms aligning with scipy 1.2.0 - -1.0.6 -===== - -Fixed issues #21, and addressed NumPy 1.15 deprecation warnings from using lists instead of tuples to specify multiple slices. - -1.0.5 -===== - -Fixed issues #7, #17, #18. -Consolidated version specification into a single file :code:`mkl_fft/_version.py`. - -1.0.4 -===== - -Added CHANGES.rst. Fixed issue #11 by using lock around calls to 1D FFT routines. - -1.0.3 -===== - -This is a bug fix release. - -It fixes issues #9, and #13. - -As part of fixing issue #13, out-of-place 1D FFT calls such as :code:`fft`, :code:`ifft`, :code:`rfft_numpy` -and :code:`irfftn_numpy` will allocate Fortran layout array for the output is the input is a Fotran array. - - -1.0.2 -===== - -Minor update of :code:`mkl_fft`, reflecting renaming of :code:`numpy.core.multiarray_tests` module to -:code:`numpy.core._multiarray_tests` as well as fixing #4. - - -1.0.1 -===== - -Bug fix release. - -1.0.0 -===== - -Initial release of :code:`mkl_fft`. diff --git a/mkl_fft/_scipy_fft.py b/mkl_fft/_scipy_fft.py index 24eece5..36c165e 100644 --- a/mkl_fft/_scipy_fft.py +++ b/mkl_fft/_scipy_fft.py @@ -43,7 +43,7 @@ from ._float_utils import _supported_array_or_not_implemented __doc__ = """ -This module implements interfaces mimicing `scipy.fft` module. +This module implements interfaces mimicking `scipy.fft` module. It also provides DftiBackend class which can be used to set mkl_fft to be used via `scipy.fft` namespace. diff --git a/mkl_fft/src/mklfft.c.src b/mkl_fft/src/mklfft.c.src index 47f7cf3..6bbe33b 100644 --- a/mkl_fft/src/mklfft.c.src +++ b/mkl_fft/src/mklfft.c.src @@ -363,7 +363,7 @@ compute_strides_and_distances( break; default: /* we must have C- or F- contiguous layout */ - /* TODO: enhance the test to acommodate equal size slices along all axis of a contiguous array, * + /* TODO: enhance the test to accommodate equal size slices along all axis of a contiguous array, * * for example x = contig_r3_arr[::4, ::4, ::4] */ { int any_contig = (PyArray_ISONESEGMENT(x)) ? 1 : 0; diff --git a/mkl_fft/tests/third_party/numpy/test_fft.py b/mkl_fft/tests/third_party/numpy/test_fft.py index 20d0f03..6d5659e 100644 --- a/mkl_fft/tests/third_party/numpy/test_fft.py +++ b/mkl_fft/tests/third_party/numpy/test_fft.py @@ -175,7 +175,7 @@ def test_fft_inplace_out(self, axis): else: assert_array_equal(y3[:, :5], y[:, :5]) assert_array_equal(y3[:, 15:], y[:, 15:]) - # In-place with n > nin; rest should be unchanged. + # In-place with n > n_in; rest should be unchanged. y4 = y.copy() y4_sel = y4[:10] if axis == 0 else y4[:, :10] out4 = y4[:15] if axis == 0 else y4[:, :15]