docstr: Tests for edge cases and continuity for sin(px)/sin(x).
docstr_tok: ["Tests","for","edge","cases","and","continuity","for","sin","(","px",")","\/sin","(","x",")","."]
code: def test_safe_sinpx_div_sinx(self):
      """Tests for edge cases and continuity for sin(px)/sin(x)."""
      angle_step = np.pi / 16.0
  
      with self.subTest(name="all_angles"):
          theta = tf.range(
              -2.0 * np.pi, 2.0 * np.pi + angle_step / 2.0, angle_step
          )
          factor = np.random.uniform(size=(1,))
  
          division = safe_ops.safe_sinpx_div_sinx(theta, factor)
          division_l = safe_ops.safe_sinpx_div_sinx(
              theta + 1e-10, factor
          )
          division_r = safe_ops.safe_sinpx_div_sinx(
              theta - 1e-10, factor
          )
  
          self.assertAllClose(division, division_l, rtol=1e-9)
          self.assertAllClose(division, division_r, rtol=1e-9)
  
      with self.subTest(name="theta_is_zero"):
          theta = 0.0
          factor = tf.range(0.0, 1.0, 0.001)
  
          division = safe_ops.safe_sinpx_div_sinx(theta, factor)
          division_l = safe_ops.safe_sinpx_div_sinx(
              theta + 1e-10, factor
          )
          division_r = safe_ops.safe_sinpx_div_sinx(
              theta - 1e-10, factor
          )
  
          self.assertAllClose(division, division_l, atol=1e-9)
          self.assertAllClose(division, division_r, atol=1e-9)
          # According to l'Hopital rule, limit should be factor
          self.assertAllClose(division, factor, atol=1e-9)
  
      with self.subTest(name="theta_is_pi"):
          theta = np.pi
          factor = tf.range(0.0, 1.001, 0.001)
  
          division = safe_ops.safe_sinpx_div_sinx(theta, factor)
          division_l = safe_ops.safe_sinpx_div_sinx(
              theta + 1e-10, factor
          )
          division_r = safe_ops.safe_sinpx_div_sinx(
              theta - 1e-10, factor
          )
  
          self.assertAllClose(division, division_l, atol=1e-9)
          self.assertAllClose(division, division_r, atol=1e-9)
  
file_path: graphics/tensorflow_graphics/util/tests/safe_ops_test.py
imports: from absl.testing import parameterized
  import numpy
  import tensorflow
  from tensorflow_graphics.util import asserts
  from tensorflow_graphics.util import safe_ops
  from tensorflow_graphics.util import test_case
label_desc: Use image node_id 7 for calling the SafeOpsTest obj's underlying member method code with example usage: obj.test_safe_sinpx_div_sinx() without return types