Skip to content

Commit

Permalink
Added pytest to run before push
Browse files Browse the repository at this point in the history
  • Loading branch information
brennanfreeze committed Aug 11, 2024
1 parent c022dc2 commit 6593777
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pep8check.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: PEP 8 Code Style Check
name: PEP 8 Check

on: [push, pull_request]

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/runtests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run Tests with Pytest
name: Pytest

on: [push, pull_request]

Expand Down
13 changes: 8 additions & 5 deletions src/quantumcircuit/circuitdrawing/circuitdrawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ def adddrawing(self, drawing: str, qubit: int) -> None:
self.maxlength = max(self.maxlength, self.circuitqueue[qubit].length)

def insertsingle(self, gate: str, qubit: int) -> None:
to_insert = self.maxlength - 1
while self.circuitqueue[qubit].at(to_insert) == linedrawing():
to_insert -= 1
self.circuitqueue[qubit].insert(to_insert + 1, gatedrawing(gate))
self.maxlength = max(self.maxlength, self.circuitqueue[qubit].length)
if self.circuitqueue[qubit].length >= 10:
to_insert = self.maxlength - 1
while self.circuitqueue[qubit].at(to_insert) == linedrawing():
to_insert -= 1
self.circuitqueue[qubit].insert(to_insert + 1, gatedrawing(gate))
self.maxlength = max(self.maxlength, self.circuitqueue[qubit].length)
else:
self.adddrawing(gatedrawing(gate), qubit)
self.equallength()

def twoqubit(self, qubit_1: int, qubit_2: int, gate = None) -> None:
Expand Down
2 changes: 1 addition & 1 deletion src/quantumcircuit/circuitdrawing/wire.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def add(self, to_add: str) -> None:
self.content.append(to_add)

def insert(self, to_insert: int, to_add: str) -> None:
if to_insert >= self.length:
if to_insert > self.length:
self.add(to_add)
self.content[to_insert] = to_add

Expand Down
5 changes: 1 addition & 4 deletions test/quantumcircuit/base/test_qc_02.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@

import numpy as np

from qcpy import quantumcircuit


def inc(x):
qc = quantumcircuit(qubits=x, prep="z")
qc = quantumcircuit(qubits=x)
for i in range(x):
qc.h(i)
return np.around(qc.state.flatten(), 3)
Expand Down
16 changes: 1 addition & 15 deletions test/quantumgate/test_qg_06.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,4 @@ def test_qg_06a():
],
"F",
)
).all(), "test_qg_06b Failed on CNot"

def test_qg_06b():
assert (
qg.cnot(little_endian=True)
== np.array(
[
[1 + 0j, 0 + 0j, 0 + 0j, 0 + 0j],
[0 + 0j, 0 + 0j, 0 + 0j, 1 + 0j],
[0 + 0j, 0 + 0j, 1 + 0j, 0 + 0j],
[0 + 0j, 1 + 0j, 0 + 0j, 0 + 0j],
],
"F",
)
).all(), "test_qg_06a Failed on CNot"
).all(), "test_qg_06b Failed on CNot"

0 comments on commit 6593777

Please sign in to comment.