code: def _fd_matrix(step_ratio, parity, nterms):
          
          _assert(0 <= parity <= 6,
                  'Parity must be 0, 1, 2, 3, 4, 5 or 6! ({0:d})'.format(parity))
          step = [1, 2, 2, 4, 4, 4, 4][parity]
          inv_sr = 1.0 / step_ratio
          offset = [1, 1, 2, 2, 4, 1, 3][parity]
          c0 = [1.0, 1.0, 1.0, 2.0, 24.0, 1.0, 6.0][parity]
          c = c0 / \
              special.factorial(np.arange(offset, step * nterms + offset, step))
          [i, j] = np.ogrid[0:nterms, 0:nterms]
          return np.atleast_2d(c[j] * inv_sr ** (i * (step * j + offset)))
docs: Return matrix for finite difference and complex step derivation.
  
          Parameters
          ----------
          step_ratio : real scalar
              ratio between steps in unequally spaced difference rule.
          parity : scalar, integer
              0 (one sided, all terms included but zeroth order)
              1 (only odd terms included)
              2 (only even terms included)
              3 (only every 4'th order terms included starting from order 2)
              4 (only every 4'th order terms included starting from order 4)
              5 (only every 4'th order terms included starting from order 1)
              6 (only every 4'th order terms included starting from order 3)
          nterms : scalar, integer
              number of terms