#NEWLINE# def bohman( M , sym = True ) : #NEWLINE# #INDENT# 'Return a Bohman window.\n\n    Parameters\n    ----------\n    M : int\n        Number of points in the output window. If zero or less, an empty\n        array is returned.\n    sym : bool, optional\n        When True (default), generates a symmetric window, for use in filter\n        design.\n        When False, generates a periodic window, for use in spectral analysis.\n\n    Returns\n    -------\n    w : ndarray\n        The window, with the maximum value normalized to 1 (though the value 1\n        does not appear if `M` is even and `sym` is True).\n\n    Examples\n    --------\n    Plot the window and its frequency response:\n\n    >>> from scipy import signal\n    >>> from scipy.fftpack import fft, fftshift\n    >>> import matplotlib.pyplot as plt\n\n    >>> window = signal.bohman(51)\n    >>> plt.plot(window)\n    >>> plt.title("Bohman window")\n    >>> plt.ylabel("Amplitude")\n    >>> plt.xlabel("Sample")\n\n    >>> plt.figure()\n    >>> A = fft(window, 2048) / (len(window)/2.0)\n    >>> freq = np.linspace(-0.5, 0.5, len(A))\n    >>> response = 20 * np.log10(np.abs(fftshift(A / abs(A).max())))\n    >>> plt.plot(freq, response)\n    >>> plt.axis([-0.5, 0.5, -120, 0])\n    >>> plt.title("Frequency response of the Bohman window")\n    >>> plt.ylabel("Normalized magnitude [dB]")\n    >>> plt.xlabel("Normalized frequency [cycles per sample]")\n\n    ' #NEWLINE# if ( M < 1 ) : #NEWLINE# #INDENT# return np . array ( [ ] ) #NEWLINE# #UNINDENT# if ( M == 1 ) : #NEWLINE# #INDENT# return np . ones ( 1 , 'd' ) #NEWLINE# #UNINDENT# odd = ( M % 2 ) #NEWLINE# if ( ( not sym ) and ( not odd ) ) : #NEWLINE# #INDENT# M = ( M + 1 ) #NEWLINE# #UNINDENT# fac = np . abs ( np . linspace ( ( - 1 ) , 1 , M ) [ 1 : ( - 1 ) ] ) #NEWLINE# w = ( ( ( 1 - fac ) * np . cos ( ( np . pi * fac ) ) ) + ( ( 1.0 / np . pi ) * np . sin ( ( np . pi * fac ) ) ) ) #NEWLINE# w = np . r_ [ ( 0 , w , 0 ) ] #NEWLINE# if ( ( not sym ) and ( not odd ) ) : #NEWLINE# #INDENT# w = w [ : ( - 1 ) ] #NEWLINE# #UNINDENT# return w