docstr: Checks outputs against a linear kernel, where interpolation is exact.
docstr_tok: ["Checks","outputs","against","a","linear","kernel",",","where","interpolation","is","exact","."]
code: def testLinearKernel(self, is_square):
      """Checks outputs against a linear kernel, where interpolation is exact."""
      # Arrange inputs.
      ndims = 3
      x1 = np.stack([np.linspace(-5.0, 5.0, 5)] * ndims, axis=-1)
      x1_length = x1.shape[-2]
      if is_square:
          x2 = None
          x2_length = x1.shape[-2]
      else:
          x2 = np.stack([np.linspace(-5.0, 5.0, 3)] * ndims, axis=-1)
          x2_length = x2.shape[-2]
      bounds_min = [-5.0] * ndims
      bounds_max = [5.0] * ndims
      num_interpolation_points = 3
      diag_shift = 1.0 if is_square else None
      shift = 1.0
  
      kernel = polynomial.Linear(shift=self.make_input(shift, []))
      # Construct linop, do some operations on it.
      linop = loipk.LinearOperatorInterpolatedPSDKernel(
          kernel=kernel,
          bounds_min=tf.constant(bounds_min, self.dtype),
          bounds_max=tf.constant(bounds_max, self.dtype),
          num_interpolation_points=num_interpolation_points,
          x1=self.make_input(x1, [-2, -1]),
          x2=x2 if x2 is None else self.make_input(x2, [-2, -1]),
          diag_shift=diag_shift
          if diag_shift is None
          else self.make_input(diag_shift, []),
      )
  
      dense = linop.to_dense()
      kernel_dense = kernel.matrix(x1, x1 if x2 is None else x2)
      if diag_shift is not None:
          kernel_dense += diag_shift * tf.eye(
              x1_length, x2_length, dtype=self.dtype
          )
      self.assertAllClose(kernel_dense, dense)
  
imports: import functools
  from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.experimental.linalg import linear_operator_interpolated_psd_kernel
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math.psd_kernels import matern
  from tensorflow_probability.python.math.psd_kernels import polynomial
label_desc: Use image node_id 2 for calling the _LinearOperatorInterpolatedPSDKernelTestStaticTest obj's underlying member method code with example usage: obj.testLinearKernel(is_square) without return types