-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_basic.py
More file actions
64 lines (49 loc) · 1.77 KB
/
test_basic.py
File metadata and controls
64 lines (49 loc) · 1.77 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
60
61
62
63
64
import pytest
# Now you can import your custom module
import pyms3d_core as pyms3d
def basic_hydrogen_dataset_test():
try:
df = "testing/Hydrogen_128x128x128.raw"
dim = (128,128,128)
pyms3d.select_device()
msc = pyms3d.MsComplex()
msc.compute_bin(df,dim)
except Exception as e:
pytest.fail("Error on processing the hydrogen dataset..")
try:
msc.simplify_pers(thresh=0.05)
except Exception as e:
pytest.fail("Error on simplifying the processed hydrogen data")
#numerical test based on the known outcomes from the hydrogen dataset
correctNumberOfMinima=1
correctNumberOfSaddle1=1
correctNumberOfSaddle2=5
correctNumberOfMaxima=4
#if any of these are triggered, it means the package is not calculating the number of critical points correctly
assert(correctNumberOfMinima==len(msc.cps(0)))
assert(correctNumberOfSaddle1==len(msc.cps(1)))
assert(correctNumberOfSaddle2==len(msc.cps(2)))
assert(correctNumberOfMaxima==len(msc.cps(3)))
def test_data():
basic_hydrogen_dataset_test()
def test_has_required_hardware():
try:
pyms3d.select_device()
except Exception as e:
pytest.fail("Error on finding the required GPU and hardware for OpenCL initialisation..")
def test_msc_datastructure():
try:
msc = pyms3d.MsComplex()
except Exception as e:
pytest.fail("Error on creating the msc object")
if __name__ == "__main__":
df = "testing/Hydrogen_128x128x128.raw"
dim = (128,128,128)
pyms3d.select_device()
msc = pyms3d.MsComplex()
msc.compute_bin(df,dim)
msc.simplify_pers(thresh=0.05)
print(len(msc.cps(0)))
print(len(msc.cps(1)))
print(len(msc.cps(2)))
print(len(msc.cps(3)))