forked from xtensor-stack/xtensor-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_a.py
More file actions
59 lines (38 loc) · 1.21 KB
/
Copy pathtest_a.py
File metadata and controls
59 lines (38 loc) · 1.21 KB
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
import unittest
import xt
import numpy as np
class test_a(unittest.TestCase):
"""
??
"""
def test_mean(self):
a = np.random.random([103, 102, 101])
n = np.mean(a)
x = xt.mean(a)
self.assertTrue(np.allclose(n, x))
def test_average(self):
a = np.random.random([103, 102, 101])
w = np.random.random([103, 102, 101])
n = np.average(a, weights=w)
x = xt.average(a, w)
self.assertTrue(np.allclose(n, x))
def test_average_axes(self):
a = np.random.random([103, 102, 101])
w = np.random.random([103, 102, 101])
axis = int(np.random.randint(0, high=3))
n = np.average(a, weights=w, axis=(axis,))
x = xt.average(a, w, [axis])
self.assertTrue(np.allclose(n, x))
def test_flip(self):
axis = int(np.random.randint(0, high=3))
a = np.random.random([103, 102, 101])
n = np.flip(a, axis)
x = xt.flip(a, axis)
self.assertTrue(np.allclose(n, x))
def test_cos(self):
a = np.random.random([103, 102, 101])
n = np.cos(a)
x = xt.cos(a)
self.assertTrue(np.allclose(n, x))
if __name__ == "__main__":
unittest.main()