OwlCyberSecurity - MANAGER
Edit File: mlab.cpython-38.pyc
U ��]G� � @ s� d Z ddlZddlZddlZddlmZ ddlmZ dd� Z dd� Z d@dd �ZdAd d�Zej dd d�dBdd��ZdCdd �ZdDdd�Zdd� ZdEdd�ZdFdd�ZdGdd�ZdHdd�Zejje�d�d� ejje�d �d!� ejje�d"�d#� ejdId$d%��ZejdJd&d'��ZejdKd(d)��ZejdLd*d+��ZejdMd,d-��ZejdNd.d/��ZejdOd0d1��Z d2Z!ejd3d4ee ddd5dfd6d7��Z"dPd<d=�Z#G d>d?� d?e$�Z%dS )Qa Numerical python functions written for compatibility with MATLAB commands with the same names. Most numerical python functions can be found in the `numpy` and `scipy` libraries. What remains here is code for performing spectral computations. Spectral functions ------------------- `cohere` Coherence (normalized cross spectral density) `csd` Cross spectral density using Welch's average periodogram `detrend` Remove the mean or best fit line from an array `psd` Power spectral density using Welch's average periodogram `specgram` Spectrogram (spectrum over segments of time) `complex_spectrum` Return the complex-valued frequency spectrum of a signal `magnitude_spectrum` Return the magnitude of the frequency spectrum of a signal `angle_spectrum` Return the angle (wrapped phase) of the frequency spectrum of a signal `phase_spectrum` Return the phase (unwrapped angle) of the frequency spectrum of a signal `detrend_mean` Remove the mean from a line. `detrend_linear` Remove the best fit line from a line. `detrend_none` Return the original line. `stride_windows` Get all windows in an array in a memory-efficient manner `stride_repeat` Repeat an array in a memory-efficient manner `apply_window` Apply a window along a given axis � N)� docstringc C s t �t| ��| S )z} Return x times the hanning window of len(x). See Also -------- window_none : Another window algorithm. )�npZhanning�len��x� r �1/usr/lib/python3/dist-packages/matplotlib/mlab.py�window_hanningA s r c C s | S )zx No window function; simply return x. See Also -------- window_hanning : Another window algorithm. r r r r r �window_noneL s r c C s� t �| �} | jdk s| jdkr&td��|d | jkr@td| ��t| j�}|�|�}t �|�rxt|�|krrtd��|}n|t j || j d��}| jdkr�|r�|| |fS || S |�� }|d d }t|||d�} |r�| | |fS | | S dS ) a Apply the given window to the given 1D or 2D array along the given axis. Parameters ---------- x : 1D or 2D array or sequence Array or sequence containing the data. window : function or array. Either a function to generate a window or an array with length *x*.shape[*axis*] axis : integer The axis over which to do the repetition. Must be 0 or 1. The default is 0 return_window : bool If true, also return the 1D values of the window that was applied � � z only 1D or 2D arrays can be used�axis(=%s) out of boundszFThe len(window) must be the same as the shape of x for the chosen axis��dtype��axisN)r �asarray�ndim� ValueError�list�shape�pop�iterabler Zonesr � stride_repeat) r �windowr � return_windowZxshapeZ xshapetarg� windowValsZxshapeotherZ otheraxisZ windowValsRepr r r �apply_windowW s, r c C s |dks|dkrt | t|d�S |dkr4t | t|d�S |dkrJt | t|d�S t|t�r`td| ��t|�sttd| ��t� | �} |dk r�|d | j kr�td| ��|dkr�| j d ks�|s�| j dkr�|| �S z|| |d �W S tk � r� tj||| d� Y S X dS )a� Return x with its trend removed. Parameters ---------- x : array or sequence Array or sequence containing the data. key : [ 'default' | 'constant' | 'mean' | 'linear' | 'none'] or function Specifies the detrend algorithm to use. 'default' is 'mean', which is the same as `detrend_mean`. 'constant' is the same. 'linear' is the same as `detrend_linear`. 'none' is the same as `detrend_none`. The default is 'mean'. See the corresponding functions for more details regarding the algorithms. Can also be a function that carries out the detrend operation. axis : integer The axis along which to do the detrending. See Also -------- detrend_mean : Implementation of the 'mean' algorithm. detrend_linear : Implementation of the 'linear' algorithm. detrend_none : Implementation of the 'none' algorithm. N)Zconstant�mean�default)�keyr ZlinearZnonez`Unknown value for key %s, must be one of: 'default', 'constant', 'mean', 'linear', or a functionr r r r )r Zarr) �detrend�detrend_mean�detrend_linear�detrend_none� isinstance�strr �callabler r r � TypeErrorZapply_along_axis)r r r r r r r! � s. �� r! z3.1r"