← Back
Editing: test_savitzky_golay.cpython-311.pyc
� d�c�0 � � � d dl Z d dlZd dlmZmZmZmZmZ d dl m Z d dlmZm Z d dlmZ d� Zd� Zd� Zd � Zd � Zd� Zd� Zd � Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Z dS )� N)�assert_allclose�assert_equal�assert_almost_equal�assert_array_equal�assert_array_almost_equal)� convolve1d)� savgol_coeffs� savgol_filter)�_polyderc �F � t | |� � }t ||� � d S )N)r r )�p�m�expected�dps �H/usr/lib/python3/dist-packages/scipy/signal/tests/test_savitzky_golay.py� check_polyderr s% � � �!�Q���B��r�8�$�$�$�$�$� c �f � dgddgfdgddgfg d�dg d�fg d�dddgfg d�ddgfg d�ddgfg d�g d�gdg d�g d�gfg d�g d�gdddgd dggfg d�g d�gddgd ggfg d�g d�gddgdggfg } | D ]E\ }}}t t j |� � j |t j |� � j � � �Fd S ) N� r � )� � r � r r )r r � � )r �np�array�T)�casesr r r s r �test_polyderr s: � � ��a�!�� � ��a�!�� � ���A�y�y�y�!� ���A��1�v�� ���A��s�� ���A��s�� �)�)�Y�Y�Y� ��Y�Y�Y� � � �$:�;� �)�)�Y�Y�Y� ��a��V�b�!�W�$5�6� �)�)�Y�Y�Y� ��a�S�2�$�K�0� �)�)�Y�Y�Y� ��a�S�1�#�J�/� �E� � >� >���1�h��b�h�q�k�k�m�Q����(:�(:�(<�=�=�=�=�>� >r c �� � |�| dz }t j | � � }||k � t � � }t j t j |||� � |� � }|S )z�This is an alternative implementation of the SG coefficients. It uses numpy.polyfit and numpy.polyval. The results should be equivalent to those of savgol_coeffs(), but this implementation is slower. window_length should be odd. Nr )r �arange�astype�int�polyval�polyfit)� window_length� polyorder�pos�t�unit�hs r � alt_sg_coeffsr- '