1# Owner(s): ["module: dynamo"] 2 3# this file is autogenerated via gen_ufuncs.py 4# do not edit manually! 5import numpy as np 6 7from torch._numpy._ufuncs import * # noqa: F403 8from torch._numpy.testing import assert_allclose 9from torch.testing._internal.common_utils import run_tests, TestCase 10 11 12class TestBinaryUfuncBasic(TestCase): 13 def test_add(self): 14 assert_allclose(np.add(0.5, 0.6), add(0.5, 0.6), atol=1e-7, check_dtype=False) 15 16 def test_arctan2(self): 17 assert_allclose( 18 np.arctan2(0.5, 0.6), arctan2(0.5, 0.6), atol=1e-7, check_dtype=False 19 ) 20 21 def test_bitwise_and(self): 22 assert_allclose( 23 np.bitwise_and(5, 6), bitwise_and(5, 6), atol=1e-7, check_dtype=False 24 ) 25 26 def test_bitwise_or(self): 27 assert_allclose( 28 np.bitwise_or(5, 6), bitwise_or(5, 6), atol=1e-7, check_dtype=False 29 ) 30 31 def test_bitwise_xor(self): 32 assert_allclose( 33 np.bitwise_xor(5, 6), bitwise_xor(5, 6), atol=1e-7, check_dtype=False 34 ) 35 36 def test_copysign(self): 37 assert_allclose( 38 np.copysign(0.5, 0.6), copysign(0.5, 0.6), atol=1e-7, check_dtype=False 39 ) 40 41 def test_divide(self): 42 assert_allclose( 43 np.divide(0.5, 0.6), divide(0.5, 0.6), atol=1e-7, check_dtype=False 44 ) 45 46 def test_equal(self): 47 assert_allclose( 48 np.equal(0.5, 0.6), equal(0.5, 0.6), atol=1e-7, check_dtype=False 49 ) 50 51 def test_float_power(self): 52 assert_allclose( 53 np.float_power(0.5, 0.6), 54 float_power(0.5, 0.6), 55 atol=1e-7, 56 check_dtype=False, 57 ) 58 59 def test_floor_divide(self): 60 assert_allclose( 61 np.floor_divide(0.5, 0.6), 62 floor_divide(0.5, 0.6), 63 atol=1e-7, 64 check_dtype=False, 65 ) 66 67 def test_fmax(self): 68 assert_allclose(np.fmax(0.5, 0.6), fmax(0.5, 0.6), atol=1e-7, check_dtype=False) 69 70 def test_fmin(self): 71 assert_allclose(np.fmin(0.5, 0.6), fmin(0.5, 0.6), atol=1e-7, check_dtype=False) 72 73 def test_fmod(self): 74 assert_allclose(np.fmod(0.5, 0.6), fmod(0.5, 0.6), atol=1e-7, check_dtype=False) 75 76 def test_gcd(self): 77 assert_allclose(np.gcd(5, 6), gcd(5, 6), atol=1e-7, check_dtype=False) 78 79 def test_greater(self): 80 assert_allclose( 81 np.greater(0.5, 0.6), greater(0.5, 0.6), atol=1e-7, check_dtype=False 82 ) 83 84 def test_greater_equal(self): 85 assert_allclose( 86 np.greater_equal(0.5, 0.6), 87 greater_equal(0.5, 0.6), 88 atol=1e-7, 89 check_dtype=False, 90 ) 91 92 def test_heaviside(self): 93 assert_allclose( 94 np.heaviside(0.5, 0.6), heaviside(0.5, 0.6), atol=1e-7, check_dtype=False 95 ) 96 97 def test_hypot(self): 98 assert_allclose( 99 np.hypot(0.5, 0.6), hypot(0.5, 0.6), atol=1e-7, check_dtype=False 100 ) 101 102 def test_lcm(self): 103 assert_allclose(np.lcm(5, 6), lcm(5, 6), atol=1e-7, check_dtype=False) 104 105 def test_ldexp(self): 106 assert_allclose(np.ldexp(0.5, 6), ldexp(0.5, 6), atol=1e-7, check_dtype=False) 107 108 def test_left_shift(self): 109 assert_allclose( 110 np.left_shift(5, 6), left_shift(5, 6), atol=1e-7, check_dtype=False 111 ) 112 113 def test_less(self): 114 assert_allclose(np.less(0.5, 0.6), less(0.5, 0.6), atol=1e-7, check_dtype=False) 115 116 def test_less_equal(self): 117 assert_allclose( 118 np.less_equal(0.5, 0.6), less_equal(0.5, 0.6), atol=1e-7, check_dtype=False 119 ) 120 121 def test_logaddexp(self): 122 assert_allclose( 123 np.logaddexp(0.5, 0.6), logaddexp(0.5, 0.6), atol=1e-7, check_dtype=False 124 ) 125 126 def test_logaddexp2(self): 127 assert_allclose( 128 np.logaddexp2(0.5, 0.6), logaddexp2(0.5, 0.6), atol=1e-7, check_dtype=False 129 ) 130 131 def test_logical_and(self): 132 assert_allclose( 133 np.logical_and(0.5, 0.6), 134 logical_and(0.5, 0.6), 135 atol=1e-7, 136 check_dtype=False, 137 ) 138 139 def test_logical_or(self): 140 assert_allclose( 141 np.logical_or(0.5, 0.6), logical_or(0.5, 0.6), atol=1e-7, check_dtype=False 142 ) 143 144 def test_logical_xor(self): 145 assert_allclose( 146 np.logical_xor(0.5, 0.6), 147 logical_xor(0.5, 0.6), 148 atol=1e-7, 149 check_dtype=False, 150 ) 151 152 def test_matmul(self): 153 assert_allclose( 154 np.matmul([0.5], [0.6]), matmul([0.5], [0.6]), atol=1e-7, check_dtype=False 155 ) 156 157 def test_maximum(self): 158 assert_allclose( 159 np.maximum(0.5, 0.6), maximum(0.5, 0.6), atol=1e-7, check_dtype=False 160 ) 161 162 def test_minimum(self): 163 assert_allclose( 164 np.minimum(0.5, 0.6), minimum(0.5, 0.6), atol=1e-7, check_dtype=False 165 ) 166 167 def test_remainder(self): 168 assert_allclose( 169 np.remainder(0.5, 0.6), remainder(0.5, 0.6), atol=1e-7, check_dtype=False 170 ) 171 172 def test_multiply(self): 173 assert_allclose( 174 np.multiply(0.5, 0.6), multiply(0.5, 0.6), atol=1e-7, check_dtype=False 175 ) 176 177 def test_nextafter(self): 178 assert_allclose( 179 np.nextafter(0.5, 0.6), nextafter(0.5, 0.6), atol=1e-7, check_dtype=False 180 ) 181 182 def test_not_equal(self): 183 assert_allclose( 184 np.not_equal(0.5, 0.6), not_equal(0.5, 0.6), atol=1e-7, check_dtype=False 185 ) 186 187 def test_power(self): 188 assert_allclose( 189 np.power(0.5, 0.6), power(0.5, 0.6), atol=1e-7, check_dtype=False 190 ) 191 192 def test_right_shift(self): 193 assert_allclose( 194 np.right_shift(5, 6), right_shift(5, 6), atol=1e-7, check_dtype=False 195 ) 196 197 def test_subtract(self): 198 assert_allclose( 199 np.subtract(0.5, 0.6), subtract(0.5, 0.6), atol=1e-7, check_dtype=False 200 ) 201 202 203if __name__ == "__main__": 204 run_tests() 205