예제 #1
0
 def test_spence_boundary(self):
   self.assertAllClose(np.pi**2 / 6., special_math_ops.spence(0.))
   self.assertAllClose(0., special_math_ops.spence(1.))
   self.assertTrue(np.isnan(self.evaluate(special_math_ops.spence(np.nan))))
   # Check that the domain of definition is [0, inf)
   self.assertTrue(
       np.all(
           np.isnan(
               self.evaluate(
                   special_math_ops.spence(
                       np.random.uniform(-20., -1., size=int(1e3)))))))
예제 #2
0
 def test_spence_larger(self, dtype):
   x = np.random.uniform(1., 100., size=int(1e4)).astype(dtype)
   try:
     from scipy import special  # pylint: disable=g-import-not-at-top
     self.assertAllClose(
         special.spence(x), self.evaluate(special_math_ops.spence(x)))
   except ImportError as e:
     tf_logging.warn('Cannot test special functions: %s' % str(e))