docstr: Tests model with piecewise constant volatility in 1 dimension.
docstr_tok: ["Tests","model","with","piecewise","constant","volatility","in","1","dimension","."]
code: def test_correctness_time_dep_1d(self):
      """Tests model with piecewise constant volatility in 1 dimension."""
      error_tol = 1e-3
      dtype = tf.float64
  
      discount_rate_fn = lambda x: 0.01 * tf.ones_like(x, dtype=dtype)
      volatility_fn = tff.math.piecewise.PiecewiseConstantFunc(
          jump_locations=[0.5],
          values=self.volatility_time_dep_1d,
          dtype=dtype,
      )
  
      def piecewise_1d_volatility_fn(t, r_t):
          vol = volatility_fn([t])
          return tf.fill(dims=[r_t.shape[0], 1], value=vol)
  
      price = tff.models.hjm.cap_floor_price(
          strikes=self.strikes,
          expiries=self.expiries,
          maturities=self.maturities,
          daycount_fractions=self.daycount_fractions,
          notional=100.0,
          dim=1,
          mean_reversion=self.mean_reversion_1d,
          volatility=piecewise_1d_volatility_fn,
          reference_rate_fn=discount_rate_fn,
          num_samples=100000,
          time_step=0.1,
          random_type=tff.math.random.RandomType.STATELESS_ANTITHETIC,
          seed=[42, 42],
          dtype=dtype,
      )
      self.assertEqual(price.dtype, dtype)
      self.assertAllEqual(price.shape, [])
      price = self.evaluate(price)
      self.assertAllClose(
          price, 0.2394242699989869, rtol=error_tol, atol=error_tol
      )
  
file_path: tf-quant-finance/tf_quant_finance/models/hjm/cap_floor_test.py
imports: 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 HJMCapFloorTest obj's underlying member method code with example usage: obj.test_correctness_time_dep_1d() and returns: tf