File: test_unary_ufuncs.py

package info (click to toggle)
pytorch-cuda 2.6.0%2Bdfsg-7
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid, trixie
  • size: 161,620 kB
  • sloc: python: 1,278,832; cpp: 900,322; ansic: 82,710; asm: 7,754; java: 3,363; sh: 2,811; javascript: 2,443; makefile: 597; ruby: 195; xml: 84; objc: 68
file content (148 lines) | stat: -rw-r--r-- 5,092 bytes parent folder | download | duplicates (3)
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# Owner(s): ["module: dynamo"]

# this file is autogenerated via gen_ufuncs.py
# do not edit manually!

import numpy as np

from torch._numpy._ufuncs import *  # noqa: F403
from torch._numpy.testing import assert_allclose
from torch.testing._internal.common_utils import run_tests, TestCase


class TestUnaryUfuncs(TestCase):
    def test_absolute(self):
        assert_allclose(np.absolute(0.5), absolute(0.5), atol=1e-14, check_dtype=False)

    def test_arccos(self):
        assert_allclose(np.arccos(0.5), arccos(0.5), atol=1e-14, check_dtype=False)

    def test_arccosh(self):
        assert_allclose(np.arccosh(1.5), arccosh(1.5), atol=1e-14, check_dtype=False)

    def test_arcsin(self):
        assert_allclose(np.arcsin(0.5), arcsin(0.5), atol=1e-14, check_dtype=False)

    def test_arcsinh(self):
        assert_allclose(np.arcsinh(0.5), arcsinh(0.5), atol=1e-14, check_dtype=False)

    def test_arctan(self):
        assert_allclose(np.arctan(0.5), arctan(0.5), atol=1e-14, check_dtype=False)

    def test_arctanh(self):
        assert_allclose(np.arctanh(0.5), arctanh(0.5), atol=1e-14, check_dtype=False)

    def test_cbrt(self):
        assert_allclose(np.cbrt(0.5), cbrt(0.5), atol=1e-14, check_dtype=False)

    def test_ceil(self):
        assert_allclose(np.ceil(0.5), ceil(0.5), atol=1e-14, check_dtype=False)

    def test_conjugate(self):
        assert_allclose(
            np.conjugate(0.5), conjugate(0.5), atol=1e-14, check_dtype=False
        )

    def test_cos(self):
        assert_allclose(np.cos(0.5), cos(0.5), atol=1e-14, check_dtype=False)

    def test_cosh(self):
        assert_allclose(np.cosh(0.5), cosh(0.5), atol=1e-14, check_dtype=False)

    def test_deg2rad(self):
        assert_allclose(np.deg2rad(0.5), deg2rad(0.5), atol=1e-14, check_dtype=False)

    def test_degrees(self):
        assert_allclose(np.degrees(0.5), degrees(0.5), atol=1e-14, check_dtype=False)

    def test_exp(self):
        assert_allclose(np.exp(0.5), exp(0.5), atol=1e-14, check_dtype=False)

    def test_exp2(self):
        assert_allclose(np.exp2(0.5), exp2(0.5), atol=1e-14, check_dtype=False)

    def test_expm1(self):
        assert_allclose(np.expm1(0.5), expm1(0.5), atol=1e-14, check_dtype=False)

    def test_fabs(self):
        assert_allclose(np.fabs(0.5), fabs(0.5), atol=1e-14, check_dtype=False)

    def test_floor(self):
        assert_allclose(np.floor(0.5), floor(0.5), atol=1e-14, check_dtype=False)

    def test_isfinite(self):
        assert_allclose(np.isfinite(0.5), isfinite(0.5), atol=1e-14, check_dtype=False)

    def test_isinf(self):
        assert_allclose(np.isinf(0.5), isinf(0.5), atol=1e-14, check_dtype=False)

    def test_isnan(self):
        assert_allclose(np.isnan(0.5), isnan(0.5), atol=1e-14, check_dtype=False)

    def test_log(self):
        assert_allclose(np.log(0.5), log(0.5), atol=1e-14, check_dtype=False)

    def test_log10(self):
        assert_allclose(np.log10(0.5), log10(0.5), atol=1e-14, check_dtype=False)

    def test_log1p(self):
        assert_allclose(np.log1p(0.5), log1p(0.5), atol=1e-14, check_dtype=False)

    def test_log2(self):
        assert_allclose(np.log2(0.5), log2(0.5), atol=1e-14, check_dtype=False)

    def test_logical_not(self):
        assert_allclose(
            np.logical_not(0.5), logical_not(0.5), atol=1e-14, check_dtype=False
        )

    def test_negative(self):
        assert_allclose(np.negative(0.5), negative(0.5), atol=1e-14, check_dtype=False)

    def test_positive(self):
        assert_allclose(np.positive(0.5), positive(0.5), atol=1e-14, check_dtype=False)

    def test_rad2deg(self):
        assert_allclose(np.rad2deg(0.5), rad2deg(0.5), atol=1e-14, check_dtype=False)

    def test_radians(self):
        assert_allclose(np.radians(0.5), radians(0.5), atol=1e-14, check_dtype=False)

    def test_reciprocal(self):
        assert_allclose(
            np.reciprocal(0.5), reciprocal(0.5), atol=1e-14, check_dtype=False
        )

    def test_rint(self):
        assert_allclose(np.rint(0.5), rint(0.5), atol=1e-14, check_dtype=False)

    def test_sign(self):
        assert_allclose(np.sign(0.5), sign(0.5), atol=1e-14, check_dtype=False)

    def test_signbit(self):
        assert_allclose(np.signbit(0.5), signbit(0.5), atol=1e-14, check_dtype=False)

    def test_sin(self):
        assert_allclose(np.sin(0.5), sin(0.5), atol=1e-14, check_dtype=False)

    def test_sinh(self):
        assert_allclose(np.sinh(0.5), sinh(0.5), atol=1e-14, check_dtype=False)

    def test_sqrt(self):
        assert_allclose(np.sqrt(0.5), sqrt(0.5), atol=1e-14, check_dtype=False)

    def test_square(self):
        assert_allclose(np.square(0.5), square(0.5), atol=1e-14, check_dtype=False)

    def test_tan(self):
        assert_allclose(np.tan(0.5), tan(0.5), atol=1e-14, check_dtype=False)

    def test_tanh(self):
        assert_allclose(np.tanh(0.5), tanh(0.5), atol=1e-14, check_dtype=False)

    def test_trunc(self):
        assert_allclose(np.trunc(0.5), trunc(0.5), atol=1e-14, check_dtype=False)


if __name__ == "__main__":
    run_tests()