-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
67 lines (52 loc) · 1.42 KB
/
conftest.py
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
import sys
import os
import pytest
thisfile = os.path.abspath(__file__)
modulepath = os.path.dirname(os.path.dirname(thisfile))
sys.path.insert(0, modulepath)
import tensorcircuit as tc
@pytest.fixture(scope="function")
def npb():
tc.set_backend("numpy")
yield
tc.set_backend("numpy") # default backend
@pytest.fixture(scope="function")
def tfb():
tc.set_backend("tensorflow")
yield
tc.set_backend("numpy") # default backend
@pytest.fixture(scope="function")
def jaxb():
try:
tc.set_backend("jax")
yield
tc.set_backend("numpy")
except ImportError as e:
print(e)
tc.set_backend("numpy")
pytest.skip("****** No jax backend found, skipping test suit *******")
@pytest.fixture(scope="function")
def torchb():
try:
tc.set_backend("pytorch")
yield
tc.set_backend("numpy")
except ImportError as e:
print(e)
tc.set_backend("numpy")
pytest.skip("****** No torch backend found, skipping test suit *******")
@pytest.fixture(scope="function")
def cpb():
try:
tc.set_backend("cupy")
yield
tc.set_backend("numpy")
except ImportError as e:
print(e)
tc.set_backend("numpy")
pytest.skip("****** No cupy backend found, skipping test suit *******")
@pytest.fixture(scope="function")
def highp():
tc.set_dtype("complex128")
yield
tc.set_dtype("complex64")