class_docstr: Tests for methods in linear_interpolation module.
docstr: Tests linear interpolation with nonconst extrapolation.
docstr_tok: ["Tests","linear","interpolation","with","nonconst","extrapolation","."]
code: def test_linear_interpolation_nonconst_extrapolation(
      self, optimize_for_tpu
  ):
      """Tests linear interpolation with nonconst extrapolation."""
      x = [-10, -2, -1, 1, 3, 6, 7, 8, 15, 18, 25, 30, 31, 35]
      x_data = np.array([-1, 2, 6, 8, 18, 30])
      y_data_as_list = [10, -1, -5, 7, 9, 20]
      y_data = tf.convert_to_tensor(y_data_as_list, dtype=tf.float64)
      left_slope = 2.0
      right_slope = -3.0
      result = self.evaluate(
          tff.math.interpolation.linear.interpolate(
              x,
              x_data,
              y_data,
              left_slope=left_slope,
              right_slope=right_slope,
              optimize_for_tpu=optimize_for_tpu,
              dtype=tf.float64,
          )
      )
      expected_left = 10.0 + left_slope * (
          np.array([-10.0, -2.0]) - (-1.0)
      )
      expected_right = 20.0 + right_slope * (
          np.array([31.0, 35.0]) - 30.0
      )
      expected_middle = [
          np.interp(x_coord, x_data, y_data_as_list)
          for x_coord in x[2:-2]
      ]
      self.assertAllClose(
          result,
          np.concatenate(
              [expected_left, expected_middle, expected_right]
          ),
          1e-8,
      )
  
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 3 for calling the LinearInterpolation obj's underlying member method code with example usage: obj.test_linear_interpolation_nonconst_extrapolation(optimize_for_tpu) without return types