Skip to content

Commit

Permalink
[ci] only publish manually, fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mc-Zen committed Feb 18, 2024
1 parent 45524f6 commit a851d0a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish-python.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI

on: push
on: workflow_dispatch

jobs:
build:
Expand Down Expand Up @@ -30,7 +30,7 @@ jobs:
publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
# if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.10", "3.11"]

steps:
- uses: actions/checkout@v3
Expand All @@ -28,7 +28,7 @@ jobs:
run: |
python -m pip install --upgrade pip
# pip install .
pip install numpy==1.22
pip install numpy>=1.22
pip install qiskit==0.45.0
pip install qiskit-aer==0.12.1
- name: Test with unittest
Expand Down
6 changes: 3 additions & 3 deletions tests/test_lc_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def test_determine_lc_class3(self):
self.assertEqual(lc_class.type, LCClass3.EntanglementStructure.Separable)
self.assertEqual(lc_class.id(), 0)
self.assertEqual(lc_class, LCClass3(lc_class.id()))
lc_class.get_graph().draw()

lc_class = determine_lc_class3(Stabilizer(["YII", "IYX", "IXY"]))
self.assertEqual(lc_class.type, LCClass3.EntanglementStructure.Pair)
Expand All @@ -48,7 +47,6 @@ def test_determine_lc_class3(self):
self.assertEqual(lc_class.type, LCClass3.EntanglementStructure.Triple)
self.assertEqual(lc_class.id(), 4)
self.assertEqual(lc_class, LCClass3(lc_class.id()))
lc_class.get_graph().draw()

def test_determine_lc_class4(self):
lc_class = determine_lc_class4(Stabilizer(["XYIY", "XIZY", "IYZI", "IYII"]))
Expand Down Expand Up @@ -407,7 +405,7 @@ def test_6_qubit_classes_to_from_graph(self):
for i in range(LCClass6.count()):
self.assertEqual(i, LCClass6(i).id())
if i != determine_lc_class(Stabilizer(LCClass6(i).get_graph())).id():
LCClass6(i).get_graph().draw(show=True)
# LCClass6(i).get_graph().draw(show=True)
print(LCClass6.get_LC_type(i))
self.assertEqual(i, determine_lc_class(Stabilizer(LCClass6(i).get_graph())).id())

Expand All @@ -417,4 +415,6 @@ def test_get_type(self):

def test_str(self):
print(str(LCClass4(5)))

def test_eq(self):
self.assertEqual(LCClass4(5), LCClass4(5))
10 changes: 7 additions & 3 deletions tests/test_rotate_stabilizer_into_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def test_basic_2(self):
qc3 = rotate_stabilizer_into_state(qc1, Stabilizer(qc2))
assert_same_state(qc2, qc3)

@unittest.skip("is_equivalent() is not implemented yet")
def test_special_case(self):
stabilizer = Stabilizer(['+YX', '+ZY'])
qc = _get_preparation_circuit_modulo_phase(stabilizer, "all")
Expand All @@ -85,7 +86,8 @@ def test_basic_inplace_2(self):
def test_random_2(self):
for num_qubits in range(5, 6):
for i in range(100):
qc: QuantumCircuit = random_clifford(num_qubits).to_circuit() # type: ignore
qc: QuantumCircuit = random_clifford(
num_qubits).to_circuit() # type: ignore
stabilizer = Stabilizer(qc)

x_gates = QuantumCircuit(num_qubits)
Expand All @@ -108,14 +110,16 @@ def get_graph_state_circuit(self, graph: Graph):
return graph_state_circuit

def test_fail_case(self):
qc = circuit_lookup.parse_circuit(5, "h0 h3 cz0,3 h1 cz0,1 s3 h3 h4 s4 cz3,4 h0 s0 h2 s2 h2 cz0,2 s0 h0 h3 s3 h3 cz0,3 s2 h3 ")
qc = circuit_lookup.parse_circuit(
5, "h0 h3 cz0,3 h1 cz0,1 s3 h3 h4 s4 cz3,4 h0 s0 h2 s2 h2 cz0,2 s0 h0 h3 s3 h3 cz0,3 s2 h3 ")
print(qc)
graph = Graph.decompress(5, 919)
graph_state_circuit = self.get_graph_state_circuit(graph)
qc_p = rotate_stabilizer_into_state(qc, Stabilizer(graph))
print(qc_p)
# qc_p = rotate_stabilizer_into_state(qc, graph_state_circuit)
# print(qc_p)
self.assertTrue(Stabilizer(graph_state_circuit).is_equivalent_mod_phase(Stabilizer(qc_p)))
self.assertTrue(Stabilizer(
graph_state_circuit).is_equivalent_mod_phase(Stabilizer(qc_p)))
# self.assertTrue(Stabilizer(graph_state_circuit).is_equivalent(Stabilizer(qc_p)))
assert_same_state(qc_p, graph_state_circuit)

0 comments on commit a851d0a

Please sign in to comment.