docstr: Tests calibration with constant parameters.
docstr_tok: ["Tests","calibration","with","constant","parameters","."]
code: def test_correctness(
      self,
      hw_vol,
      optimizer_fn,
      noise_size,
      use_analytic_pricing,
      expected_mr,
      expected_vol,
      vol_based_calib,
  ):
      """Tests calibration with constant parameters."""
      dtype = tf.float64
  
      zero_rate_fn = lambda x: 0.01 * tf.ones_like(x)
      prices = tff.models.hull_white.swaption_price(
          expiries=self.expiries,
          floating_leg_start_times=self.float_leg_start_times,
          floating_leg_end_times=self.float_leg_end_times,
          fixed_leg_payment_times=self.fixed_leg_payment_times,
          floating_leg_daycount_fractions=self.float_leg_daycount_fractions,
          fixed_leg_daycount_fractions=self.fixed_leg_daycount_fractions,
          fixed_leg_coupon=self.fixed_leg_coupon,
          reference_rate_fn=zero_rate_fn,
          notional=100.0,
          mean_reversion=self.mean_reversion,
          volatility=hw_vol,
          use_analytic_pricing=True,
          dtype=dtype,
      )
  
      # Add noise
      prices = prices + tf.random.normal(
          prices.shape, stddev=noise_size * prices, seed=0, dtype=dtype
      )
  
      (
          calibrated_result,
          _,
          _,
      ) = tff.models.hull_white.calibration_from_swaptions(
          prices=prices,
          expiries=self.expiries,
          floating_leg_start_times=self.float_leg_start_times,
          floating_leg_end_times=self.float_leg_end_times,
          fixed_leg_payment_times=self.fixed_leg_payment_times,
          floating_leg_daycount_fractions=self.float_leg_daycount_fractions,
          fixed_leg_daycount_fractions=self.fixed_leg_daycount_fractions,
          fixed_leg_coupon=self.fixed_leg_coupon,
          reference_rate_fn=zero_rate_fn,
          notional=100.0,
          mean_reversion=[0.01],
          volatility=[0.005],
          optimizer_fn=optimizer_fn,
          use_analytic_pricing=use_analytic_pricing,
          volatility_based_calibration=vol_based_calib,
          num_samples=2000,
          random_type=tff.math.random.RandomType.STATELESS_ANTITHETIC,
          seed=[0, 0],
          time_step=0.1,
          maximum_iterations=50,
          dtype=dtype,
      )
      self.assertEqual(prices.dtype, dtype)
      calib_parameters = tf.concat(
          [
              calibrated_result.mean_reversion.values(),
              calibrated_result.volatility.values(),
          ],
          axis=0,
      )
      calib_parameters = self.evaluate(calib_parameters)
      mr = calib_parameters[:1]
      vol = calib_parameters[1:]
      self.assertAllClose(mr, expected_mr, rtol=1e-4, atol=1e-4)
      self.assertAllClose(vol, expected_vol, rtol=1e-4, atol=1e-4)
  
file_path: tf-quant-finance/tf_quant_finance/models/hull_white/calibration_test.py
imports: 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 2 for calling the HullWhiteCalibrationSwaptionTest obj's underlying member method code with example usage: obj.test_correctness(hw_vol, optimizer_fn, noise_size, use_analytic_pricing, expected_mr, expected_vol, vol_based_calib) without return types