-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyarr_test.py
More file actions
48 lines (38 loc) · 1.1 KB
/
pyarr_test.py
File metadata and controls
48 lines (38 loc) · 1.1 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
import numpy, warnings, pdb, os
with warnings.catch_warnings():
warnings.simplefilter('ignore')
import libboost_common as lbc
def test_environ():
x = os.environ['LIBPYARR_ROOT']
assert(os.path.isdir(x))
def test_to_vvd():
a = numpy.random.random((3,5))
av = lbc.pyarr_to_vvd_test(a)
for x in range(a.shape[0]):
for y in range(a.shape[1]):
n = a[x][y]
assert(n == av[x][y])
def test_pyarr_cast():
a = numpy.random.random((3,5))
ac = lbc.pyarr_cast(a)
assert(ac.get_nd() == 2)
def test_uint_pair():
x = lbc.uint_real_pair()
x.first = 0
x.second = 1.0
assert(x.first == 0)
assert(x.second == 1.0)
def overflow(x):
x.first = -1
expect_error(overflow,
OverflowError,
x)
def expect_error(func, err, *args, **kwargs):
try:
func(*args, **kwargs)
except err:
pass
except Exception as e:
raise AssertionError("got unexpected exception: {}: {}".format(type(e), e))
else:
raise AssertionError("didn't get expected exception")