


import doctest
from collections import deque

import numpy as np






class     UpperCAmelCase__       :



    """simple docstring"""






    def __init__(			self    )  ->       None:
         __UpperCamelCase    							=[2, 1, 2, -1]
         __UpperCamelCase    							=[1, 2, 3, 4]






    def _a					(			self    )  ->       list[float]:
         __UpperCamelCase    							=len(self.first_signal    )
         __UpperCamelCase    							=len(self.second_signal    )

         __UpperCamelCase    							=max(A_					,   A_    )

         # create a zero matrix of max_length x max_length
         __UpperCamelCase    							=[[0] * max_length for i in range(A_    )]

         # fills the smaller signal with zeros to make both signals of same length
         if length_first_signal < length_second_signal:
              self.first_signal += [0] * (max_length - length_first_signal)
         elif length_first_signal > length_second_signal:
              self.second_signal += [0] * (max_length - length_second_signal)
         for i in range(A_    ):
              __UpperCamelCase    							=deque(self.second_signal    )
              rotated_signal.rotate(A_    )
              for j, item in enumerate(A_    ):
                   matrix[i][j] += item

        # multiply the matrix with the first signal
         __UpperCamelCase    							=np.matmul(np.transpose(A_    )					,   np.transpose(self.first_signal    )    )

         # rounding-off to two decimal places
         return [round(A_					,   2    ) for i in final_signal]


if __name__ == "__main__":
   doctest.testmod()









from __future__ import annotations

from math import pi
from typing import Protocol

import matplotlib.pyplot as plt
import numpy as np






class     UpperCAmelCase__       (					A_		):



    """simple docstring"""






    def _a					(			self					,   A_    )  ->       float:
         return 0.0

def 						_UpperCAmelCase				(			SCREAMING_SNAKE_CASE__			:					np.ndarray			,     SCREAMING_SNAKE_CASE__			:					int				):
     __UpperCamelCase    							=min([-20, np.min(fft_results[1 : samplerate // 2 - 1]				)]				)
     __UpperCamelCase    							=max([20, np.max(fft_results[1 : samplerate // 2 - 1]				)]				)
     return lowest, highest

def 						_UpperCAmelCase				(			SCREAMING_SNAKE_CASE__			:					FilterType			,     SCREAMING_SNAKE_CASE__			:					int				):
     __UpperCamelCase    							=5_12
     __UpperCamelCase    							=[1] + [0] * (size - 1)
     __UpperCamelCase    							=[filter_type.process(SCREAMING_SNAKE_CASE__				) for item in inputs]

     __UpperCamelCase    							=[0] * (samplerate - size)  # zero-padding
     outputs += filler
     __UpperCamelCase    							=np.abs(np.fft.fft(SCREAMING_SNAKE_CASE__				)				)
     __UpperCamelCase    							=20 * np.logaa(SCREAMING_SNAKE_CASE__				)

     # Frequencies on log scale from 24 to nyquist frequency
     plt.xlim(24			,     samplerate / 2 - 1				)
     plt.xlabel('Frequency (Hz)'				)
     plt.xscale('log'				)

     # Display within reasonable bounds
     __UpperCamelCase    							=get_bounds(SCREAMING_SNAKE_CASE__			,     SCREAMING_SNAKE_CASE__				)
     plt.ylim(max([-80, bounds[0]]				)			,     min([80, bounds[1]]				)				)
     plt.ylabel('Gain (dB)'				)

     plt.plot(SCREAMING_SNAKE_CASE__				)
     plt.show()





def 						_UpperCAmelCase				(			SCREAMING_SNAKE_CASE__			:					FilterType			,     SCREAMING_SNAKE_CASE__			:					int				):
     __UpperCamelCase    							=5_12
     __UpperCamelCase    							=[1] + [0] * (size - 1)
     __UpperCamelCase    							=[filter_type.process(SCREAMING_SNAKE_CASE__				) for item in inputs]

     __UpperCamelCase    							=[0] * (samplerate - size)  # zero-padding
     outputs += filler
     __UpperCamelCase    							=np.angle(np.fft.fft(SCREAMING_SNAKE_CASE__				)				)

     # Frequencies on log scale from 24 to nyquist frequency
     plt.xlim(24			,     samplerate / 2 - 1				)
     plt.xlabel('Frequency (Hz)'				)
     plt.xscale('log'				)

     plt.ylim(-2 * pi			,     2 * pi				)
     plt.ylabel('Phase shift (Radians)'				)
     plt.plot(np.unwrap(SCREAMING_SNAKE_CASE__			,     -2 * pi				)				)
     plt.show()





