docstr: Checks that method works if the rates are positive by fwds are not.
docstr_tok: ["Checks","that","method","works","if","the","rates","are","positive","by","fwds","are","not","."]
code: def test_negative_forwards(self, dtype):
      """Checks that method works if the rates are positive by fwds are not."""
      true_discount_rates = np.array(
          [0.12, 0.09, 0.02, 0.01, 0.01318182], dtype=dtype
      )
      # Note the implied forward rates for this rate curve are:
      # [0.12, 0.06, -0.05, -0.01, 0.02]
      cashflows = [
          np.array([1.2, 10.0], dtype=dtype),
          np.array([1.1, 2.2, 1.4, 15.5], dtype=dtype),
          np.array([1.22, 0.45, 2.83, 96.0], dtype=dtype),
          np.array(
              [12.33, 9.84, 1.15, 11.87, 0.66, 104.55], dtype=dtype
          ),
          np.array([5.84, 0.23, 5.23, 114.95], dtype=dtype),
      ]
      cashflow_times = [
          np.array([0.15, 0.25], dtype=dtype),
          np.array([0.1, 0.2, 0.4, 0.5], dtype=dtype),
          np.array([0.22, 0.45, 0.93, 1.0], dtype=dtype),
          np.array([0.33, 0.84, 0.92, 1.22, 1.45, 1.5], dtype=dtype),
          np.array([0.43, 0.77, 1.3, 2.2], dtype=dtype),
      ]
      pvs = np.array(
          [
              10.88135262,
              19.39268844,
              98.48426722,
              137.91938533,
              122.63546542,
          ],
          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("NumIterations"):
          self.assertEqual(results.iterations, 6)
      with self.subTest("DiscountRates"):
          np.testing.assert_allclose(
              results.discount_rates, true_discount_rates, atol=1e-6
          )
      with self.subTest("Times"):
          np.testing.assert_allclose(
              results.times, [0.25, 0.5, 1.0, 1.5, 2.2], atol=1e-6
          )
  
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 9 for calling the BondCurveTest obj's underlying member method code with example usage: obj.test_negative_forwards(dtype) without return types