def test_fmin(self): from numpypy import fmin, array nnan, nan, inf, ninf = float('-nan'), float('nan'), float('inf'), float('-inf') a = array((complex(ninf, 10), complex(10, ninf), complex( inf, 10), complex(10, inf), 5+5j, 5-5j, -5+5j, -5-5j, 0+5j, 0-5j, 5, -5, complex(nan, 0), complex(0, nan)), dtype = complex) b = [inf]*a.size res = [a[0 ], a[1 ], b[2 ], a[3 ], a[4 ], a[5 ], a[6 ], a[7 ], a[8 ], a[9 ], a[10], a[11], b[12], b[13]] assert (fmin(a, b) == res).all() b = [ninf]*a.size res = [b[0 ], b[1 ], b[2 ], b[3 ], b[4 ], b[5 ], b[6 ], b[7 ], b[8 ], b[9 ], b[10], b[11], b[12], b[13]] assert (fmin(a, b) == res).all() b = [0]*a.size res = [a[0 ], b[1 ], b[2 ], b[3 ], b[4 ], b[5 ], a[6 ], a[7 ], b[8 ], a[9 ], b[10], a[11], b[12], b[13]] assert (fmin(a, b) == res).all()
def test_fmin(self): from numpypy import fmin, array import math nnan, nan, inf, ninf = float('-nan'), float('nan'), float('inf'), float('-inf') a = [ninf, -5, 0, 5, inf] assert (fmin(a, [ninf]*5) == [ninf]*5).all() assert (fmin(a, [inf]*5) == a).all() assert (fmin(a, [1]*5) == [ninf, -5, 0, 1, 1]).all() assert fmin(nan, 0) == 0 assert fmin(0, nan) == 0 assert math.isnan(fmin(nan, nan)) # The numpy docs specify that the FIRST NaN should be used if both are NaN # use copysign on both sides to sidestep bug in nan representaion # on Microsoft win32 assert math.copysign(1., fmin(nnan, nan)) == math.copysign(1., nnan)