def test_logaddexp(self): import math import sys float_max, float_min = sys.float_info.max, sys.float_info.min from _numpypy import logaddexp # From the numpy documentation prob1 = math.log(1e-50) prob2 = math.log(2.5e-50) prob12 = logaddexp(prob1, prob2) assert math.fabs(-113.87649168120691 - prob12) < 0.000000000001 assert logaddexp(0, 0) == math.log(2) assert logaddexp(float('-inf'), 0) == 0 assert logaddexp(float_max, float_max) == float_max assert logaddexp(float_min, float_min) == math.log(2) assert math.isnan(logaddexp(float('nan'), 1)) assert math.isnan(logaddexp(1, float('nan'))) assert math.isnan(logaddexp(float('nan'), float('inf'))) assert math.isnan(logaddexp(float('inf'), float('nan'))) assert logaddexp(float('-inf'), float('-inf')) == float('-inf') assert logaddexp(float('-inf'), float('inf')) == float('inf') assert logaddexp(float('inf'), float('-inf')) == float('inf') assert logaddexp(float('inf'), float('inf')) == float('inf')
def test_logaddexp(self): import math from _numpypy import logaddexp # From the numpy documentation prob1 = math.log(1e-50) prob2 = math.log(2.5e-50) prob12 = logaddexp(prob1, prob2) assert math.fabs(-113.87649168120691 - prob12) < 0.000000000001 assert logaddexp(0, 0) == math.log(2) assert logaddexp(float('-inf'), 0) == 0 assert logaddexp(12345678, 12345678) == float('inf') assert math.isnan(logaddexp(float('nan'), 1)) assert math.isnan(logaddexp(1, float('nan'))) assert math.isnan(logaddexp(float('nan'), float('inf'))) assert math.isnan(logaddexp(float('inf'), float('nan'))) assert logaddexp(float('-inf'), float('-inf')) == float('-inf') assert logaddexp(float('-inf'), float('inf')) == float('inf') assert logaddexp(float('inf'), float('-inf')) == float('inf') assert logaddexp(float('inf'), float('inf')) == float('inf')