code: def _calculate_filter(n, spacing, shift, fI, r_def, reim, name):
      r
  
      # Base :: For this n/spacing/shift
      base = np.exp(spacing*(np.arange(n)-n//2) + shift)
  
      # r :: Start/end is defined by base AND r_def[0]/r_def[1]
      #      Overdetermined system if r_def[2] > 1
      r = np.logspace(np.log10(1/np.max(base)) - r_def[0],
                      np.log10(1/np.min(base)) + r_def[1], r_def[2]*n)
  
      # k :: Get required k-values (matrix of shape (r.size, base.size))
      k = base/r[:, None]
  
      # Create filter instance
      dlf = DigitalFilter(name.split('.')[0])
      dlf.base = base
      dlf.factor = np.around(np.average(base[1:]/base[:-1]), 15)
  
      # Loop over transforms
      for f in fI:
          # Calculate lhs and rhs for inversion
          lhs = reim(f.lhs(k))
          rhs = reim(f.rhs(r)*r)
  
          # Calculate filter values: Solve lhs*J=rhs using linalg.qr.
          # If factoring fails (qr) or if matrix is singular or square (solve) it
          # will raise a LinAlgError. Error is ignored and zeros are returned
          # instead.
          try:
              qq, rr = np.linalg.qr(lhs)
              J = np.linalg.solve(rr, rhs.dot(qq))
          except np.linalg.LinAlgError:
              J = np.zeros((base.size,))
  
          setattr(dlf, f.name, J)
  
      return dlf
docs: r"""Calculate filter for this spacing, shift, n.