OwlCyberSecurity - MANAGER
Edit File: helper.cpython-38.pyc
U �p�] � @ s� d Z ddlmZmZmZ ddlmZ ddlmZm Z m Z mZmZ ddl mZmZ dddd gZeef Zddd�Zeed d�ddd��Zeed d�ddd��Zed �ddd��Zed �ddd ��Zd S )z* Discrete Fourier Transforms - helper.py � )�division�absolute_import�print_function)� integer_types)�integer�empty�arange�asarray�roll)�array_function_dispatch� set_module�fftshift� ifftshift�fftfreq�rfftfreqNc C s | fS )N� )�x�axesr r �2/usr/lib/python3/dist-packages/numpy/fft/helper.py�_fftshift_dispatcher s r z numpy.fft)�modulec sh t � �� |dkr0tt� j��}dd� � jD �}n,t|t�rJ� j| d }n� fdd�|D �}t� ||�S )ad Shift the zero-frequency component to the center of the spectrum. This function swaps half-spaces for all axes listed (defaults to all). Note that ``y[0]`` is the Nyquist component only if ``len(x)`` is even. Parameters ---------- x : array_like Input array. axes : int or shape tuple, optional Axes over which to shift. Default is None, which shifts all axes. Returns ------- y : ndarray The shifted array. See Also -------- ifftshift : The inverse of `fftshift`. Examples -------- >>> freqs = np.fft.fftfreq(10, 0.1) >>> freqs array([ 0., 1., 2., ..., -3., -2., -1.]) >>> np.fft.fftshift(freqs) array([-5., -4., -3., -2., -1., 0., 1., 2., 3., 4.]) Shift the zero-frequency component only along the second axis: >>> freqs = np.fft.fftfreq(9, d=1./9).reshape(3, 3) >>> freqs array([[ 0., 1., 2.], [ 3., 4., -4.], [-3., -2., -1.]]) >>> np.fft.fftshift(freqs, axes=(1,)) array([[ 2., 0., 1.], [-4., 3., 4.], [-1., -3., -2.]]) Nc S s g | ]}|d �qS �� r ��.0Zdimr r r � <listcomp>F s zfftshift.<locals>.<listcomp>r c s g | ]}� j | d �qS r ��shape�r Zax�r r r r J s �r �tuple�range�ndimr � isinstancer r �r r �shiftr r r r s - c sj t � �� |dkr0tt� j��}dd� � jD �}n.t|t�rL� j| d }n� fdd�|D �}t� ||�S )a/ The inverse of `fftshift`. Although identical for even-length `x`, the functions differ by one sample for odd-length `x`. Parameters ---------- x : array_like Input array. axes : int or shape tuple, optional Axes over which to calculate. Defaults to None, which shifts all axes. Returns ------- y : ndarray The shifted array. See Also -------- fftshift : Shift zero-frequency component to the center of the spectrum. Examples -------- >>> freqs = np.fft.fftfreq(9, d=1./9).reshape(3, 3) >>> freqs array([[ 0., 1., 2.], [ 3., 4., -4.], [-3., -2., -1.]]) >>> np.fft.ifftshift(np.fft.fftshift(freqs)) array([[ 0., 1., 2.], [ 3., 4., -4.], [-3., -2., -1.]]) Nc S s g | ]}|d �qS r r r r r r r u s zifftshift.<locals>.<listcomp>r c s g | ]}� j | d �qS r r r r r r r y s r r% r r r r O s # � �?c C sz t | t�std��d| | }t| t�}| d d d }td|td�}||d|�<