# pypy / pypy / module / micronumpy / test / test_ufuncs.py

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101``` ``` from pypy.module.micronumpy.test.test_base import BaseNumpyAppTest class AppTestUfuncs(BaseNumpyAppTest): def test_single_item(self): from numpy import negative, sign, minimum assert negative(5.0) == -5.0 assert sign(-0.0) == 0.0 assert minimum(2.0, 3.0) == 2.0 def test_negative(self): from numpy import array, negative a = array([-5.0, 0.0, 1.0]) b = negative(a) for i in range(3): assert b[i] == -a[i] a = array([-5.0, 1.0]) b = negative(a) a[0] = 5.0 assert b[0] == 5.0 def test_abs(self): from numpy import array, absolute a = array([-5.0, -0.0, 1.0]) b = absolute(a) for i in range(3): assert b[i] == abs(a[i]) def test_minimum(self): from numpy import array, minimum a = array([-5.0, -0.0, 1.0]) b = array([ 3.0, -2.0,-3.0]) c = minimum(a, b) for i in range(3): assert c[i] == min(a[i], b[i]) def test_maximum(self): from numpy import array, maximum a = array([-5.0, -0.0, 1.0]) b = array([ 3.0, -2.0,-3.0]) c = maximum(a, b) for i in range(3): assert c[i] == max(a[i], b[i]) def test_sign(self): from numpy import array, sign reference = [-1.0, 0.0, 0.0, 1.0] a = array([-5.0, -0.0, 0.0, 6.0]) b = sign(a) for i in range(4): assert b[i] == reference[i] def test_reciporocal(self): from numpy import array, reciprocal reference = [-0.2, float("inf"), float("-inf"), 2.0] a = array([-5.0, 0.0, -0.0, 0.5]) b = reciprocal(a) for i in range(4): assert b[i] == reference[i] def test_floor(self): from numpy import array, floor reference = [-2.0, -1.0, 0.0, 1.0, 1.0] a = array([-1.4, -1.0, 0.0, 1.0, 1.4]) b = floor(a) for i in range(5): assert b[i] == reference[i] def test_copysign(self): from numpy import array, copysign reference = [5.0, -0.0, 0.0, -6.0] a = array([-5.0, 0.0, 0.0, 6.0]) b = array([5.0, -0.0, 3.0, -6.0]) c = copysign(a, b) for i in range(4): assert c[i] == reference[i] def test_exp(self): import math from numpy import array, exp a = array([-5.0, -0.0, 0.0, 12345678.0, float("inf"), -float('inf'), -12343424.0]) b = exp(a) for i in range(4): try: res = math.exp(a[i]) except OverflowError: res = float('inf') assert b[i] == res ```