docstr: Tests that evaluate_legendre_polynomial generates expected results.
docstr_tok: ["Tests","that","evaluate_legendre_polynomial","generates","expected","results","."]
code: def test_evaluate_legendre_polynomial_preset(self):
      """Tests that evaluate_legendre_polynomial generates expected results."""
      tensor_size = np.random.randint(1, 3)
      tensor_shape = np.random.randint(
          1, 10, size=(tensor_size)
      ).tolist()
      x = np.random.uniform(size=tensor_shape)
  
      with self.subTest(name="l_0_m_0"):
          l = tf.constant(0, shape=tensor_shape)
          m = tf.constant(0, shape=tensor_shape)
          pred = spherical_harmonics.evaluate_legendre_polynomial(
              l, m, x
          )
          gt = np.ones_like(x)
  
          self.assertAllClose(pred, gt)
  
      with self.subTest(name="l_1_m_0"):
          l = tf.constant(1, shape=tensor_shape)
          m = tf.constant(0, shape=tensor_shape)
          pred = spherical_harmonics.evaluate_legendre_polynomial(
              l, m, x
          )
          gt = x
  
          self.assertAllClose(pred, gt)
  
      with self.subTest(name="l_1_m_1"):
          l = tf.constant(1, shape=tensor_shape)
          m = tf.constant(1, shape=tensor_shape)
          pred = spherical_harmonics.evaluate_legendre_polynomial(
              l, m, x
          )
          gt = -tf.sqrt(1.0 - x * x)
  
          self.assertAllClose(pred, gt)
  
      with self.subTest(name="l_2_m_0"):
          l = tf.constant(2, shape=tensor_shape)
          m = tf.constant(0, shape=tensor_shape)
          pred = spherical_harmonics.evaluate_legendre_polynomial(
              l, m, x
          )
          gt = 0.5 * (3.0 * x * x - 1.0)
  
          self.assertAllClose(pred, gt)
  
      with self.subTest(name="l_2_m_1"):
          l = tf.constant(2, shape=tensor_shape)
          m = tf.constant(1, shape=tensor_shape)
          pred = spherical_harmonics.evaluate_legendre_polynomial(
              l, m, x
          )
          gt = -3.0 * x * tf.sqrt(1.0 - x * x)
  
          self.assertAllClose(pred, gt)
  
      with self.subTest(name="l_2_m_2"):
          l = tf.constant(2, shape=tensor_shape)
          m = tf.constant(2, shape=tensor_shape)
          pred = spherical_harmonics.evaluate_legendre_polynomial(
              l, m, x
          )
          gt = 3.0 * (1.0 - x * x)
  
          self.assertAllClose(pred, gt)
  
      with self.subTest(name="l_3_m_0"):
          l = tf.constant(3, shape=tensor_shape)
          m = tf.constant(0, shape=tensor_shape)
          pred = spherical_harmonics.evaluate_legendre_polynomial(
              l, m, x
          )
          gt = 0.5 * x * (5.0 * x * x - 3.0)
  
          self.assertAllClose(pred, gt)
  
      with self.subTest(name="l_3_m_1"):
          l = tf.constant(3, shape=tensor_shape)
          m = tf.constant(1, shape=tensor_shape)
          pred = spherical_harmonics.evaluate_legendre_polynomial(
              l, m, x
          )
          gt = 1.5 * (1.0 - 5.0 * x * x) * tf.sqrt(1.0 - x * x)
  
          self.assertAllClose(pred, gt)
  
      with self.subTest(name="l_3_m_2"):
          l = tf.constant(3, shape=tensor_shape)
          m = tf.constant(2, shape=tensor_shape)
          pred = spherical_harmonics.evaluate_legendre_polynomial(
              l, m, x
          )
          gt = 15.0 * x * (1.0 - x * x)
  
          self.assertAllClose(pred, gt)
  
      with self.subTest(name="l_3_m_3"):
          l = tf.constant(3, shape=tensor_shape)
          m = tf.constant(3, shape=tensor_shape)
          pred = spherical_harmonics.evaluate_legendre_polynomial(
              l, m, x
          )
          gt = -15.0 * tf.pow(1.0 - x * x, 1.5)
  
          self.assertAllClose(pred, gt)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import sys
  from absl.testing import parameterized
  import numpy
  import tensorflow
  from tensorflow_graphics.math import math_helpers
  from tensorflow_graphics.math import spherical_harmonics
  from tensorflow_graphics.util import asserts
  from tensorflow_graphics.util import test_case
label_desc: Use image node_id 1 for calling the SphericalHarmonicsTest obj's underlying member method code with example usage: obj.test_evaluate_legendre_polynomial_preset() without return types