def test_fmax(self): from _numpypy import fmax import math nnan, nan, inf, ninf = float('-nan'), float('nan'), float('inf'), float('-inf') a = [ninf, -5, 0, 5, inf] assert (fmax(a, [ninf]*5) == a).all() assert (fmax(a, [inf]*5) == [inf]*5).all() assert (fmax(a, [1]*5) == [1, 1, 1, 5, inf]).all() assert math.isnan(fmax(nan, 0)) assert math.isnan(fmax(0, nan)) assert math.isnan(fmax(nan, nan)) # The numpy docs specify that the FIRST NaN should be used if both are NaN assert math.copysign(1.0, fmax(nnan, nan)) == -1.0
def test_fmax(self): from _numpypy import fmax import math nnan, nan, inf, ninf = float('-nan'), float('nan'), float('inf'), float('-inf') a = [ninf, -5, 0, 5, inf] assert (fmax(a, [ninf]*5) == a).all() assert (fmax(a, [inf]*5) == [inf]*5).all() assert (fmax(a, [1]*5) == [1, 1, 1, 5, inf]).all() assert math.isnan(fmax(nan, 0)) assert math.isnan(fmax(0, nan)) assert math.isnan(fmax(nan, nan)) # The numpy docs specify that the FIRST NaN should be used if both are NaN # Since comparisons with nnan and nan all return false, # use copysign on both sides to sidestep bug in nan representaion # on Microsoft win32 assert math.copysign(1., fmax(nnan, nan)) == math.copysign(1., nnan)
def test_fmax(self): from _numpypy import fmax import math nnan, nan, inf, ninf = float('-nan'), float('nan'), float( 'inf'), float('-inf') a = [ninf, -5, 0, 5, inf] assert (fmax(a, [ninf] * 5) == a).all() assert (fmax(a, [inf] * 5) == [inf] * 5).all() assert (fmax(a, [1] * 5) == [1, 1, 1, 5, inf]).all() assert math.isnan(fmax(nan, 0)) assert math.isnan(fmax(0, nan)) assert math.isnan(fmax(nan, nan)) # The numpy docs specify that the FIRST NaN should be used if both are NaN # Since comparisons with nnan and nan all return false, # use copysign on both sides to sidestep bug in nan representaion # on Microsoft win32 assert math.copysign(1., fmax(nnan, nan)) == math.copysign(1., nnan)