Repository: scipy/scipy

Issue:
scipy.signal.windows.dpss docstring typo
in the parameters of scipy.signal.windows.dpss:
NW: float
        Standardized half bandwidth corresponding to 2*NW = BW/f0 = BW*N*dt where dt is taken as 1.

I believe the N should be an M, as M is the window length, i.e., BW*N*dt -> BW*M*dt

also in the return:
v: ndarray, shape (Kmax, N) or (N,)

N should also be replaced by M

And in the example would also be good to replace N by M for consistency

Another option is to change all the M to N, since the name NW comes from the fact that usually, the number of points in the window is N.


Discussion:
> Another option is to change all the M to N, since the name NW comes from the fact that usually, the number of points in the window is N.

I agree this would be nice, but it's harder because it will break people passing everything as kwargs. I think it would be better just to update the docstrings. Are you up for making a PR to do it?

Resolving patch:
diff --git a/scipy/signal/windows/windows.py b/scipy/signal/windows/windows.py
--- a/scipy/signal/windows/windows.py
+++ b/scipy/signal/windows/windows.py
@@ -1634,7 +1634,7 @@ def dpss(M, NW, Kmax=None, sym=True, norm=None, return_ratios=False):
     M : int
         Window length.
     NW : float
-        Standardized half bandwidth corresponding to ``2*NW = BW/f0 = BW*N*dt``
+        Standardized half bandwidth corresponding to ``2*NW = BW/f0 = BW*M*dt``
         where ``dt`` is taken as 1.
     Kmax : int | None, optional
         Number of DPSS windows to return (orders ``0`` through ``Kmax-1``).
@@ -1657,7 +1657,7 @@ def dpss(M, NW, Kmax=None, sym=True, norm=None, return_ratios=False):
 
     Returns
     -------
-    v : ndarray, shape (Kmax, N) or (N,)
+    v : ndarray, shape (Kmax, M) or (M,)
         The DPSS windows. Will be 1D if `Kmax` is None.
     r : ndarray, shape (Kmax,) or float, optional
         The concentration ratios for the windows. Only returned if
@@ -1702,16 +1702,16 @@ def dpss(M, NW, Kmax=None, sym=True, norm=None, return_ratios=False):
     >>> import numpy as np
     >>> import matplotlib.pyplot as plt
     >>> from scipy.signal import windows, freqz
-    >>> N = 51
+    >>> M = 51
     >>> fig, axes = plt.subplots(3, 2, figsize=(5, 7))
     >>> for ai, alpha in enumerate((1, 3, 5)):
-    ...     win_dpss = windows.dpss(N, alpha)
+    ...     win_dpss = windows.dpss(M, alpha)
     ...     beta = alpha*np.pi
-    ...     win_kaiser = windows.kaiser(N, beta)
+    ...     win_kaiser = windows.kaiser(M, beta)
     ...     for win, c in ((win_dpss, 'k'), (win_kaiser, 'r')):
     ...         win /= win.sum()
     ...         axes[ai, 0].plot(win, color=c, lw=1.)
-    ...         axes[ai, 0].set(xlim=[0, N-1], title=r'$\\alpha$ = %s' % alpha,
+    ...         axes[ai, 0].set(xlim=[0, M-1], title=r'$\\alpha$ = %s' % alpha,
     ...                         ylabel='Amplitude')
     ...         w, h = freqz(win)
     ...         axes[ai, 1].plot(w, 20 * np.log10(np.abs(h)), color=c, lw=1.)
@@ -1822,8 +1822,8 @@ def dpss(M, NW, Kmax=None, sym=True, norm=None, return_ratios=False):
     # Here we set up an alternative symmetric tri-diagonal eigenvalue
     # problem such that
     # (B - (l2)I)v = 0, and v are our DPSS (but eigenvalues l2 != l1)
-    # the main diagonal = ([N-1-2*t]/2)**2 cos(2PIW), t=[0,1,2,...,N-1]
-    # and the first off-diagonal = t(N-t)/2, t=[1,2,...,N-1]
+    # the main diagonal = ([M-1-2*t]/2)**2 cos(2PIW), t=[0,1,2,...,M-1]
+    # and the first off-diagonal = t(M-t)/2, t=[1,2,...,M-1]
     # [see Percival and Walden, 1993]
     d = ((M - 1 - 2 * nidx) / 2.) ** 2 * np.cos(2 * np.pi * W)
     e = nidx[1:] * (M - nidx[1:]) / 2.


Test patch: