Skip to content

Commit 9172e64

Browse files
committedJul 23, 2022
backward compatibility
1 parent 009c506 commit 9172e64

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed
 

‎CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
## Unreleased
44

5+
### Changed
6+
7+
- Change pytest xdist option in check_all.sh to `-n auto`
8+
9+
### Fixed
10+
11+
- Add `sgates`, `vgates`, `mpogates` and `gate_aliases` back to `BaseCircuit` for backward compatibility
12+
13+
## 0.3.0
14+
515
### Added
616

717
- Add `device` and `device_move` methods on backend with universal device string representation

‎check_all.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ mypy tensorcircuit
77
echo "pylint check"
88
pylint tensorcircuit tests examples/*.py
99
echo "pytest check"
10-
pytest -n 4 --cov=tensorcircuit -vv -W ignore::DeprecationWarning
10+
pytest -n auto --cov=tensorcircuit -vv -W ignore::DeprecationWarning
1111
echo "sphinx check"
1212
cd docs && sphinx-build source build/html && sphinx-build source -D language="zh" build/html_cn
1313
echo "all checks passed, congratulation! 💐"

‎tensorcircuit/basecircuit.py

+5
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ class BaseCircuit:
6464
inputs: Tensor
6565
circuit_param: Dict[str, Any]
6666

67+
sgates = sgates
68+
vgates = vgates
69+
mpogates = mpogates
70+
gate_aliases = gate_aliases
71+
6772
@staticmethod
6873
def all_zero_nodes(n: int, d: int = 2, prefix: str = "qb-") -> List[tn.Node]:
6974
l = [0.0 for _ in range(d)]

‎tests/test_gates.py

+4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ def test_iswap_gate():
4242
np.testing.assert_allclose(t, np.eye(4).reshape([2, 2, 2, 2]), atol=1e-5)
4343

4444

45+
def test_gate_list():
46+
assert tc.Circuit.sgates == tc.basecircuit.sgates
47+
48+
4549
def test_controlled():
4650
xgate = tc.gates.x
4751
cxgate = xgate.controlled()

0 commit comments

Comments
 (0)
Please sign in to comment.