예제 #1
0
 def test_besselk_boundary(self):
   self.assertTrue(np.isinf(self.evaluate(special_math_ops.bessel_k0(0.))))
   self.assertTrue(np.isinf(self.evaluate(special_math_ops.bessel_k0e(0.))))
   self.assertTrue(np.isinf(self.evaluate(special_math_ops.bessel_k1(0.))))
   self.assertTrue(np.isinf(self.evaluate(special_math_ops.bessel_k1e(0.))))
   self.assertTrue(np.isnan(self.evaluate(special_math_ops.bessel_k0(np.nan))))
   self.assertTrue(
       np.isnan(self.evaluate(special_math_ops.bessel_k0e(np.nan))))
   self.assertTrue(np.isnan(self.evaluate(special_math_ops.bessel_k1(np.nan))))
   self.assertTrue(
       np.isnan(self.evaluate(special_math_ops.bessel_k1e(np.nan))))
예제 #2
0
 def test_besselk_larger(self, dtype):
   x = np.random.uniform(1., 30., size=int(1e4)).astype(dtype)
   try:
     from scipy import special  # pylint: disable=g-import-not-at-top
     self.assertAllClose(
         special.k0(x), self.evaluate(special_math_ops.bessel_k0(x)))
     self.assertAllClose(
         special.k0e(x), self.evaluate(special_math_ops.bessel_k0e(x)))
     self.assertAllClose(
         special.k1(x), self.evaluate(special_math_ops.bessel_k1(x)))
     self.assertAllClose(
         special.k1e(x), self.evaluate(special_math_ops.bessel_k1e(x)))
   except ImportError as e:
     tf_logging.warn('Cannot test special functions: %s' % str(e))