Skip to content

Commit be721a2

Browse files
fix some bug when qiskit or cirq is not installed
1 parent cff2344 commit be721a2

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

tensorcircuit/results/qem/qem_methods.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
logger = logging.getLogger(__name__)
1515

1616
import numpy as np
17-
import cirq
1817

1918
try:
2019
from mitiq import zne, ddd
@@ -205,6 +204,8 @@ def dd_rule(slack_length: int, spacing: int = -1) -> Any:
205204
return dd_sequence
206205

207206
if isinstance(rule, list):
207+
import cirq
208+
208209
gates = []
209210
for i in rule:
210211
gates.append(getattr(cirq, i))

tensorcircuit/translation.py

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"Please first ``pip install -U qiskit`` to enable related functionality in translation module"
2828
)
2929
CircuitInstruction = Any
30+
QuantumCircuit = Any
3031

3132
try:
3233
import cirq

tests/test_torchnn.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
try:
1515
import torch
1616
except ImportError:
17-
pytest.skip("torch is not installed")
17+
pytest.skip("torch is not installed", allow_module_level=True)
1818

1919

2020
@pytest.mark.parametrize("backend", [lf("tfb"), lf("jaxb"), lf("torchb")])

0 commit comments

Comments
 (0)