CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-pyfftw

A pythonic wrapper around FFTW, the FFT library, presenting a unified interface for all the supported transforms.

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

index.mddocs/

pyFFTW

A pythonic wrapper around FFTW 3, the high-performance FFT library. pyFFTW provides both complex DFT and real DFT support on arbitrary axes of arbitrary shaped and strided arrays, making it nearly feature-equivalent to numpy.fft while offering significantly better performance and additional precision support.

Package Information

  • Package Name: pyFFTW
  • Language: Python
  • Installation: pip install pyfftw
  • Version: 0.15.0

Core Imports

import pyfftw

For direct access to the FFTW class and utilities:

from pyfftw import FFTW, empty_aligned, zeros_aligned, ones_aligned

For numpy-like interfaces:

from pyfftw.interfaces import numpy_fft
from pyfftw.interfaces import scipy_fft

Basic Usage

import pyfftw
import numpy as np

# Create aligned arrays for optimal performance
a = pyfftw.empty_aligned((128, 64), dtype='complex128')
b = pyfftw.empty_aligned((128, 64), dtype='complex128')

# Fill with sample data
a[:] = np.random.randn(128, 64) + 1j * np.random.randn(128, 64)

# Create FFTW object for 2D FFT
fft_object = pyfftw.FFTW(a, b, axes=(0, 1), direction='FFTW_FORWARD')

# Execute the transform
result = fft_object()

# Or use numpy-like interface for simpler usage
from pyfftw.interfaces import numpy_fft
result = numpy_fft.fft2(a)

Architecture

pyFFTW is organized around several key components:

  • FFTW Class: Core wrapper around FFTW plans, providing direct access to FFTW's performance
  • Builders Module: Higher-level functions that create FFTW objects with numpy-like interfaces
  • Interfaces Module: Drop-in replacements for numpy.fft, scipy.fft, and scipy.fftpack
  • Memory Management: Aligned array utilities for optimal SIMD performance
  • Wisdom System: Plan caching and optimization for repeated transforms

This architecture enables both high-performance direct usage and seamless integration with existing code using numpy/scipy FFT functions.

Capabilities

Core FFTW Interface

Direct access to FFTW functionality through the main FFTW class, providing maximum control over transform planning, execution, and memory management.

class FFTW:
    def __init__(self, input_array, output_array, axes=(-1,), direction='FFTW_FORWARD', flags=('FFTW_MEASURE',), threads=1, planning_timelimit=None, normalise_idft=True, ortho=False): ...
    def __call__(self, input_array=None, output_array=None, normalise_idft=None, ortho=None): ...
    def update_arrays(self, new_input_array, new_output_array): ...
    def execute(self): ...

Core FFTW Interface

Memory Management and Alignment

Utilities for creating and managing aligned arrays to maximize SIMD performance, plus functions for checking alignment and converting existing arrays.

def empty_aligned(shape, dtype='float64', order='C', n=None): ...
def zeros_aligned(shape, dtype='float64', order='C', n=None): ...
def ones_aligned(shape, dtype='float64', order='C', n=None): ...
def n_byte_align(array, n, dtype=None): ...
def byte_align(array, n=None, dtype=None): ...
def is_byte_aligned(array, n=None): ...

Memory Management

FFT Builders

High-level functions that create FFTW objects with numpy-like signatures, supporting complex and real transforms in 1D, 2D, and N-D variants.

def fft(a, n=None, axis=-1, overwrite_input=False, planner_effort='FFTW_ESTIMATE', threads=1): ...
def ifft(a, n=None, axis=-1, overwrite_input=False, planner_effort='FFTW_ESTIMATE', threads=1): ...
def rfft(a, n=None, axis=-1, overwrite_input=False, planner_effort='FFTW_ESTIMATE', threads=1): ...
def fft2(a, s=None, axes=(-2,-1), overwrite_input=False, planner_effort='FFTW_ESTIMATE', threads=1): ...
def fftn(a, s=None, axes=None, overwrite_input=False, planner_effort='FFTW_ESTIMATE', threads=1): ...

FFT Builders

numpy.fft Interface

Drop-in replacement for numpy.fft functions with additional optimization parameters, enabling existing code to benefit from FFTW performance with minimal changes.

def fft(a, n=None, axis=-1, norm=None, overwrite_input=False, planner_effort='FFTW_ESTIMATE', threads=1): ...
def fft2(a, s=None, axes=(-2,-1), norm=None, overwrite_input=False, planner_effort='FFTW_ESTIMATE', threads=1): ...
def rfft(a, n=None, axis=-1, norm=None, overwrite_input=False, planner_effort='FFTW_ESTIMATE', threads=1): ...
def hfft(a, n=None, axis=-1, norm=None, overwrite_input=False, planner_effort='FFTW_ESTIMATE', threads=1): ...

numpy.fft Interface

scipy.fft Interface

Compatible interface for scipy.fft functions with FFTW backend, supporting the newer scipy FFT API including workers parameter and context manager compatibility.

def fft(x, n=None, axis=-1, norm=None, overwrite_x=False, workers=None, plan=None): ...
def fft2(x, s=None, axes=(-2,-1), norm=None, overwrite_x=False, workers=None, plan=None): ...
def next_fast_len(target, real=False): ...

scipy.fft Interface

scipy.fftpack Interface (Legacy)

Drop-in replacement for scipy.fftpack functions with FFTW backend, including support for discrete cosine and sine transforms. This interface provides backward compatibility with legacy scipy.fftpack code.

def fft(x, n=None, axis=-1, overwrite_x=False, planner_effort=None, threads=None): ...
def dct(x, type=2, n=None, axis=-1, norm=None, overwrite_x=False, planner_effort=None, threads=None): ...
def dst(x, type=2, n=None, axis=-1, norm=None, overwrite_x=False, planner_effort=None, threads=None): ...
def dctn(x, type=2, shape=None, axes=None, norm=None, overwrite_x=False, planner_effort=None, threads=None): ...

scipy.fftpack Interface

Wisdom Management

Functions for importing, exporting, and managing FFTW wisdom to optimize transform planning across sessions and applications.

def export_wisdom(): ...
def import_wisdom(wisdom): ...
def forget_wisdom(): ...

Wisdom Management

Configuration and Utilities

Global configuration settings, utility functions for finding optimal transform sizes, and system information access.

def next_fast_len(target): ...
# Configuration constants
simd_alignment: int
NUM_THREADS: int
PLANNER_EFFORT: str

Configuration and Utilities

Interface Performance Cache

Caching system for interface functions that stores FFTW objects to eliminate repeated planning overhead, providing significant performance improvements for repeated transforms.

def enable(): ...
def disable(): ...
def is_enabled(): ...
def set_keepalive_time(keepalive_time): ...

Interface Cache

docs

configuration-utilities.md

core-fftw.md

fft-builders.md

index.md

interfaces-cache.md

memory-management.md

numpy-fft-interface.md

scipy-fft-interface.md

scipy-fftpack-interface.md

wisdom-management.md

tile.json