Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⬆️🪝 update pre-commit hooks #45

Merged
merged 2 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ repos:

# Python linting using ruff
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.5
rev: v0.5.7
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
Expand All @@ -68,7 +68,7 @@ repos:

# Static type checking using mypy
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.0
rev: v1.11.1
hooks:
- id: mypy
files: ^(src/mqt|test/python)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ def retrieve_local_sequence(self, fweight, children):
a, p = getAngles(coef[i + 1], coef[i])
gate = R(self.circuit, "R", qudit, [i, i + 1, a, p], self.circuit.dimensions[qudit], None).to_matrix()
coef = np.dot(gate, coef)
aplog[(i, i + 1)] = (-a, p)
aplog[i, i + 1] = (-a, p)

phase_2 = np.angle(find_complex_number(fweight, coef[0]))
aplog[(-1, 0)] = (-phase_2 * 2, 0)
aplog[-1, 0] = (-phase_2 * 2, 0)

return aplog

Expand Down
4 changes: 2 additions & 2 deletions src/mqt/qudits/quantum_circuit/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def append(self, qreg: QuantumRegister) -> None:
num_lines_stored = len(self._sitemap)
for i in range(qreg.size):
qreg.local_sitemap[i] = num_lines_stored + i
self._sitemap[(str(qreg.label), i)] = (num_lines_stored + i, qreg.dimensions[i])
self._sitemap[str(qreg.label), i] = (num_lines_stored + i, qreg.dimensions[i])
self.inverse_sitemap[num_lines_stored + i] = (str(qreg.label), i)

def append_classic(self, creg: ClassicRegister) -> None:
Expand All @@ -149,7 +149,7 @@ def append_classic(self, creg: ClassicRegister) -> None:
num_lines_stored = len(self._classic_site_map)
for i in range(creg.size):
creg.local_sitemap[i] = num_lines_stored + i
self._classic_site_map[(str(creg.label), i)] = (num_lines_stored + i,)
self._classic_site_map[str(creg.label), i] = (num_lines_stored + i,)
self.cl_inverse_sitemap[num_lines_stored + i] = (str(creg.label), i)

@add_gate_decorator
Expand Down
8 changes: 4 additions & 4 deletions src/mqt/qudits/quantum_circuit/qasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def parse_qreg(self, line, rgxs, sitemap) -> bool:
qdims = [2] * nq

for i in range(int(nq)):
sitemap[(str(name), i)] = len(sitemap), qdims[i]
sitemap[str(name), i] = len(sitemap), qdims[i]

return True
return False
Expand All @@ -60,7 +60,7 @@ def parse_creg(self, line, rgxs, sitemap_classic) -> bool:
if match:
name, nclassics = match.groups()
for i in range(int(nclassics)):
sitemap_classic[(str(name), i)] = len(sitemap_classic)
sitemap_classic[str(name), i] = len(sitemap_classic)
return True
return False

Expand Down Expand Up @@ -100,7 +100,7 @@ def parse_gate(self, line, rgxs, sitemap, gates) -> bool:
if match:
name, reg_qudit_index = match.groups()
reg_qudit_index = int(*re.search(r"\[(\d+)\]", reg_qudit_index).groups())
qudit = tuple(sitemap[(name, reg_qudit_index)])
qudit = tuple(sitemap[name, reg_qudit_index])
qudits_list.append(qudit)

qudits_control_list = []
Expand All @@ -109,7 +109,7 @@ def parse_gate(self, line, rgxs, sitemap, gates) -> bool:
for match in matches:
name, reg_qudit_index = match
reg_qudit_index = int(*re.search(r"\[(\d+)\]", reg_qudit_index).groups())
qudit = tuple(sitemap[(name, reg_qudit_index)])
qudit = tuple(sitemap[name, reg_qudit_index])
qudits_control_list.append(qudit[0])

qudits_levels_list = []
Expand Down
2 changes: 1 addition & 1 deletion src/mqt/qudits/simulation/backends/backendv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def num_qudits(self) -> int:
return self.target.num_qudits

@property
def energy_level_graphs(self) -> list[(LevelGraph, LevelGraph)]:
def energy_level_graphs(self) -> list[LevelGraph, LevelGraph]:
raise NotImplementedError

def _default_options(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(
self._energy_level_graphs = None

@property
def energy_level_graphs(self) -> list[(LevelGraph, LevelGraph)]:
def energy_level_graphs(self) -> list[LevelGraph, LevelGraph]:
e_graphs = []

# declare the edges on the energy level graph between logic states .
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(
self._energy_level_graphs = None

@property
def energy_level_graphs(self) -> list[(LevelGraph, LevelGraph)]:
def energy_level_graphs(self) -> list[LevelGraph, LevelGraph]:
e_graphs = []

# declare the edges on the energy level graph between logic states .
Expand Down
Loading