Пример #1
0
 def test_logaddexp_range(self):
     x = [1000000, -1000000, 1000200, -1000200]
     y = [1000200, -1000200, 1000000, -1000000]
     z = [1000200, -1000000, 1000200, -1000000]
     for ds in ['float32', 'float64']:
         logxf = blaze.array(x, dshape=ds)
         logyf = blaze.array(y, dshape=ds)
         logzf = blaze.array(z, dshape=ds)
         result = blaze.logaddexp(logxf, logyf)
         assert_almost_equal(result, logzf)
Пример #2
0
 def test_logaddexp_values(self):
     x = [1, 2, 3, 4, 5]
     y = [5, 4, 3, 2, 1]
     z = [6, 6, 6, 6, 6]
     for ds, dec in zip(['float32', 'float64'], [6, 15]):
         xf = blaze.log(blaze.array(x, dshape=ds))
         yf = blaze.log(blaze.array(y, dshape=ds))
         zf = blaze.log(blaze.array(z, dshape=ds))
         result = blaze.logaddexp(xf, yf)
         assert_almost_equal(result, zf, decimal=dec)
Пример #3
0
 def test_inf(self):
     inf = blaze.inf
     x = [inf, -inf,  inf, -inf, inf, 1,  -inf,  1]
     y = [inf,  inf, -inf, -inf, 1,   inf, 1,   -inf]
     z = [inf,  inf,  inf, -inf, inf, inf, 1,    1]
     for ds in ['float32', 'float64']:
         logxf = blaze.array(x, dshape=ds)
         logyf = blaze.array(y, dshape=ds)
         logzf = blaze.array(z, dshape=ds)
         result = blaze.logaddexp(logxf, logyf)
         assert_equal(result, logzf)
Пример #4
0
 def test_nan(self):
     self.assertTrue(blaze.isnan(blaze.logaddexp(blaze.nan, blaze.inf)))
     self.assertTrue(blaze.isnan(blaze.logaddexp(blaze.inf, blaze.nan)))
     self.assertTrue(blaze.isnan(blaze.logaddexp(blaze.nan, 0)))
     self.assertTrue(blaze.isnan(blaze.logaddexp(0, blaze.nan)))
     self.assertTrue(blaze.isnan(blaze.logaddexp(blaze.nan, blaze.nan)))