code: def cheby_rect(G, bounds, signal, **kwargs):
      r
      if not (isinstance(bounds, (list, np.ndarray)) and len(bounds) == 2):
          raise ValueError('Bounds of wrong shape.')
  
      bounds = np.array(bounds)
  
      m = int(kwargs.pop('order', 30) + 1)
  
      try:
          Nv = np.shape(signal)[1]
          r = np.zeros((G.N, Nv))
      except IndexError:
          r = np.zeros((G.N))
  
      b1, b2 = np.arccos(2. * bounds / G.lmax - 1.)
      factor = 4./G.lmax * G.L - 2.*sparse.eye(G.N)
  
      T_old = signal
      T_cur = factor.dot(signal) / 2.
      r = (b1 - b2)/np.pi * signal + 2./np.pi * (np.sin(b1) - np.sin(b2)) * T_cur
  
      for k in range(2, m):
          T_new = factor.dot(T_cur) - T_old
          r += 2./(k*np.pi) * (np.sin(k*b1) - np.sin(k*b2)) * T_new
          T_old = T_cur
          T_cur = T_new
  
      return r
docs: r"""
      Fast filtering using Chebyshev polynomial for a perfect rectangle filter.
  
      Parameters
      ----------
      G : Graph
      bounds : array_like
          The bounds of the pass-band filter
      signal : array_like
          Signal to filter
      order : int (optional)
          Order of the Chebyshev polynomial (default: 30)
  
      Returns
      -------
      r : array_like
          Result of the filtering