docstr: Checks that method works even if the actual rates are negative.
docstr_tok: ["Checks","that","method","works","even","if","the","actual","rates","are","negative","."]
code: def test_negative_rates(self, dtype):
      """Checks that method works even if the actual rates are negative."""
      cashflows = [
          # 1 year bond with 5% three monthly coupon.
          np.array([12.5, 12.5, 12.5, 1012.5], dtype=dtype),
          # 2 year bond with 6% semi-annual coupon.
          np.array([30, 30, 30, 1030], dtype=dtype),
          # 3 year bond with 8% semi-annual coupon.
          np.array([40, 40, 40, 40, 40, 1040], dtype=dtype),
          # 4 year bond with 3% semi-annual coupon.
          np.array([15, 15, 15, 15, 15, 15, 15, 1015], dtype=dtype),
      ]
      cashflow_times = [
          np.array([0.25, 0.5, 0.75, 1.0], dtype=dtype),
          np.array([0.5, 1.0, 1.5, 2.0], dtype=dtype),
          np.array([0.5, 1.0, 1.5, 2.0, 2.5, 3.0], dtype=dtype),
          np.array(
              [0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0], dtype=dtype
          ),
      ]
      pvs = np.array(
          [1029.54933442, 1097.95320227, 1268.65376174, 1249.84175959],
          dtype=dtype,
      )
      true_discount_rates = np.array(
          [0.02, 0.01, -0.01, -0.03], dtype=dtype
      )
      results = self.evaluate(
          bond_curve.bond_curve(
              cashflows,
              cashflow_times,
              pvs,
              validate_args=True,
              dtype=dtype,
          )
      )
      with self.subTest("Converged"):
          self.assertTrue(results.converged)
      with self.subTest("NotFailed"):
          self.assertFalse(results.failed)
      with self.subTest("DiscountRates"):
          np.testing.assert_allclose(
              results.discount_rates, true_discount_rates, atol=1e-4
          )
  
imports: import math
  from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  from tensorflow.python.framework import test_util
  from tf_quant_finance.rates.hagan_west import bond_curve
  from tf_quant_finance.rates.hagan_west import monotone_convex
label_desc: Use image node_id 8 for calling the BondCurveTest obj's underlying member method code with example usage: obj.test_negative_rates(dtype) without return types