class_docstr: Tests for methods for the vanilla pricing module.
class_docstr_tok: ["Tests","for","methods","for","the","vanilla","pricing","module","."]
docstr: Function tests swaption pricing.
docstr_tok: ["Function","tests","swaption","pricing","."]
code: def test_swaption_price(
      self, is_normal_model, volatilities, expected_price
  ):
      """Function tests swaption pricing."""
      dtype = tf.float64
  
      expiries = [1.0, 1.0]
      float_leg_start_times = [
          [1.0, 1.25, 1.5, 1.75, 2.0, 2.0, 2.0, 2.0],
          [1.0, 1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 2.75],
      ]
      float_leg_end_times = [
          [1.25, 1.5, 1.75, 2.0, 2.0, 2.0, 2.0, 2.0],
          [1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 2.75, 3.0],
      ]
      fixed_leg_payment_times = [
          [1.25, 1.5, 1.75, 2.0, 2.0, 2.0, 2.0, 2.0],
          [1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 2.75, 3.0],
      ]
      float_leg_daycount_fractions = [
          [0.25, 0.25, 0.25, 0.25, 0.0, 0.0, 0.0, 0.0],
          [0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25],
      ]
      fixed_leg_daycount_fractions = [
          [0.25, 0.25, 0.25, 0.25, 0.0, 0.0, 0.0, 0.0],
          [0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25],
      ]
      fixed_leg_coupon = [0.011, 0.011]
      discount_fn = lambda x: np.exp(-0.01 * np.array(x))
      price = self.evaluate(
          tff.black_scholes.swaption_price(
              volatilities=volatilities,
              expiries=expiries,
              floating_leg_start_times=float_leg_start_times,
              floating_leg_end_times=float_leg_end_times,
              fixed_leg_payment_times=fixed_leg_payment_times,
              floating_leg_daycount_fractions=float_leg_daycount_fractions,
              fixed_leg_daycount_fractions=fixed_leg_daycount_fractions,
              fixed_leg_coupon=fixed_leg_coupon,
              floating_leg_start_times_discount_factors=discount_fn(
                  float_leg_start_times
              ),
              floating_leg_end_times_discount_factors=discount_fn(
                  float_leg_end_times
              ),
              fixed_leg_payment_times_discount_factors=discount_fn(
                  fixed_leg_payment_times
              ),
              is_normal_volatility=is_normal_model,
              notional=100.0,
              dtype=dtype,
          )
      )
  
      self.assertAllClose(price, expected_price, 1e-6)
  
imports: import functools
  from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  import tensorflow_probability
  import tf_quant_finance
  from tensorflow.python.framework import test_util
label_desc: Use image node_id 19 for calling the VanillaPrice obj's underlying member method code with example usage: obj.test_swaption_price(is_normal_model, volatilities, expected_price) without return types