class_docstr: Tests for methods in linear_interpolation module.
docstr: Tests linear interpolation with const extrapolation.
docstr_tok: ["Tests","linear","interpolation","with","const","extrapolation","."]
code: def test_linear_interpolation_const_extrapolation_default_dtype(
      self, optimize_for_tpu
  ):
      """Tests linear interpolation with const extrapolation."""
      x = [
          -10.0,
          -1.0,
          1.0,
          3.0,
          6.0,
          7.0,
          8.0,
          15.0,
          18.0,
          25.0,
          30.0,
          35.0,
      ]
      x_data = [-1.0, 2.0, 6.0, 8.0, 18.0, 30.0]
      y_data = [10.0, -1.0, -5.0, 7.0, 9.0, 20.0]
      result = self.evaluate(
          tff.math.interpolation.linear.interpolate(
              x, x_data, y_data, optimize_for_tpu=optimize_for_tpu
          )
      )
      with self.subTest("Shape"):
          self.assertAllEqual(result.shape, [12])
      with self.subTest("Values"):
          self.assertAllClose(
              result,
              [np.interp(x_coord, x_data, y_data) for x_coord in x],
              1e-8,
          )
      with self.subTest("Shape"):
          # All above real would be converted to float32.
          self.assertDTypeEqual(result, np.float32)
  
imports: from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  import tf_quant_finance
  from tensorflow.python.framework import test_util
label_desc: Use image node_id 1 for calling the LinearInterpolation obj's underlying member method code with example usage: obj.test_linear_interpolation_const_extrapolation_default_dtype(optimize_for_tpu) without return types