Ejemplo n.º 1
0
 def test_logaddexp2_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.logaddexp2(logxf, logyf)
         assert_almost_equal(result, logzf)
Ejemplo n.º 2
0
 def test_logaddexp2_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, 15]):
         xf = blaze.log2(blaze.array(x, dshape=ds))
         yf = blaze.log2(blaze.array(y, dshape=ds))
         zf = blaze.log2(blaze.array(z, dshape=ds))
         result = blaze.logaddexp2(xf, yf)
         assert_almost_equal(result, zf, decimal=dec)
Ejemplo n.º 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.logaddexp2(logxf, logyf)
         assert_equal(result, logzf)
Ejemplo n.º 4
0
 def test_nan(self):
     self.assertTrue(blaze.isnan(blaze.logaddexp2(blaze.nan, blaze.inf)))
     self.assertTrue(blaze.isnan(blaze.logaddexp2(blaze.inf, blaze.nan)))
     self.assertTrue(blaze.isnan(blaze.logaddexp2(blaze.nan, 0)))
     self.assertTrue(blaze.isnan(blaze.logaddexp2(0, blaze.nan)))
     self.assertTrue(blaze.isnan(blaze.logaddexp2(blaze.nan, blaze.nan)))