docs: def _apply_to_array(self, yd, y, weights, off_slices, ref_slice, dim):
          """Applies the finite differences only to slices along a given axis"""
  
          ndims = len(y.shape)
  
          all = slice(None, None, 1)
  
          ref_multi_slice = [all] * ndims
          ref_multi_slice[dim] = ref_slice
  
          for w, s in zip(weights, off_slices):
              off_multi_slice = [all] * ndims
              off_multi_slice[dim] = s
              if abs(1 - w) < 1.E-14:
                  yd[ref_multi_slice] += y[off_multi_slice]
              else:
                  yd[ref_multi_slice] += w * y[off_multi_slice]