pyfftw.builders._utils - Helper functions for pyfftw.builders

A set of utility functions for use with the builders. Users should not need to use the functions directly, but they are included here for completeness and to aid with understanding of what is happening behind the scenes.

Certainly, users may encounter instances of _FFTWWrapper.

Everything documented in this module is not part of the public API and may change in future versions.

class pyfftw.builders._utils._FFTWWrapper(input_array, output_array, axes=[- 1], direction='FFTW_FORWARD', flags=['FFTW_MEASURE'], threads=1, input_array_slicer=None, FFTW_array_slicer=None, normalise_idft=True, ortho=False)

A class that wraps pyfftw.FFTW, providing a slicer on the input stage during calls to __call__().

The arguments are as per pyfftw.FFTW, but with the addition of 2 keyword arguments: input_array_slicer and FFTW_array_slicer.

These arguments represent 2 slicers: input_array_slicer slices the input array that is passed in during a call to instances of this class, and FFTW_array_slicer slices the internal array.

The arrays that are returned from both of these slicing operations should be the same size. The data is then copied from the sliced input array into the sliced internal array.

__call__(input_array=None, output_array=None, normalise_idft=None, ortho=None)

Wrap pyfftw.FFTW.__call__() by firstly slicing the passed-in input array and then copying it into a sliced version of the internal array. These slicers are set at instantiation.

When input array is not None, this method always results in a copy. Consequently, the alignment and dtype are maintained in the internal array.

output_array and normalise_idft are passed through to pyfftw.FFTW.__call__() untouched.

pyfftw.builders._utils._Xfftn(a, s, axes, overwrite_input, planner_effort, threads, auto_align_input, auto_contiguous, avoid_copy, inverse, real, normalise_idft=True, ortho=False, real_direction_flag=None)

Generic transform interface for all the transforms. No defaults exist. The transform must be specified exactly.

The argument real_direction_flag is a slight exception to this rule: for backwards compatibility this function defaults to standard Fourier transforms (and not the specialized real to real variants). If this flag is set to one of the standard real transform types (e.g., ‘FFTW_RODFT00’) then the arguments inverse and real are ignored.

pyfftw.builders._utils._compute_array_shapes(a, s, axes, inverse, real)

Given a passed in array a, and the rest of the arguments (that have been fleshed out with _cook_nd_args()), compute the shape the input and output arrays need to be in order to satisfy all the requirements for the transform. The input shape may be different to the shape of a.

returns: (input_shape, output_shape)

pyfftw.builders._utils._cook_nd_args(a, s=None, axes=None, invreal=False)

Similar to numpy.fft.fftpack._cook_nd_args().

pyfftw.builders._utils._precook_1d_args(a, n, axis)

Turn *(n, axis) into (s, axes)

pyfftw.builders._utils._setup_input_slicers(a_shape, input_shape)

This function returns two slicers that are to be used to copy the data from the input array to the FFTW object internal array, which can then be passed to _FFTWWrapper:

(update_input_array_slicer, FFTW_array_slicer)

On calls to _FFTWWrapper objects, the input array is copied in as:

FFTW_array[FFTW_array_slicer] = input_array[update_input_array_slicer]