Skip to content

Commit

Permalink
pylint - fix dangerous-default-value
Browse files Browse the repository at this point in the history
  • Loading branch information
pavoljuhas committed Nov 4, 2024
1 parent 27ae797 commit e4a635d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dev_tools/.pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ enable=
consider-merging-isinstance,
consider-using-f-string,
continue-in-finally,
# dangerous-default-value, # TODO: #210 - enable and fix
dangerous-default-value,
docstyle,
duplicate-argument-name,
# expression-not-assigned, # TODO: #210 - enable and fix
Expand Down
8 changes: 5 additions & 3 deletions unitary/quantum_chess/mcpe_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"""

from collections import defaultdict, deque
from typing import Callable, Dict, Iterable, Set, Tuple
from typing import Callable, Dict, Iterable, Optional, Set, Tuple

import cirq

Expand Down Expand Up @@ -67,8 +67,10 @@ class QubitMapping:
initial_mapping: initial logical-to-physical qubit map.
"""

def __init__(self, initial_mapping: Dict[cirq.Qid, cirq.GridQubit] = {}):
self.logical_to_physical = initial_mapping
def __init__(
self, initial_mapping: Optional[Dict[cirq.Qid, cirq.GridQubit]] = None
):
self.logical_to_physical = initial_mapping or {}
self.physical_to_logical = {v: k for k, v in initial_mapping.items()}

def swap_physical(self, q1: cirq.GridQubit, q2: cirq.GridQubit) -> None:
Expand Down
4 changes: 2 additions & 2 deletions unitary/quantum_chess/swap_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,14 @@ def __init__(
self,
circuit: cirq.Circuit,
device_qubits: Optional[Iterable[cirq.GridQubit]],
initial_mapping: Dict[cirq.Qid, cirq.GridQubit] = {},
initial_mapping: Optional[Dict[cirq.Qid, cirq.GridQubit]] = None,
swap_factory: Callable[
[cirq.Qid, cirq.Qid], Iterable[cirq.Operation]
] = generate_decomposed_swap,
):
self.device_qubits = device_qubits or []
self.dlists = mcpe.DependencyLists(circuit)
self.mapping = mcpe.QubitMapping(initial_mapping)
self.mapping = mcpe.QubitMapping(initial_mapping or {})
self.swap_factory = swap_factory
self.adjacent = {q: q.neighbors(device_qubits) for q in self.device_qubits}
self.pairwise_distances = _pairwise_shortest_distances(self.adjacent)
Expand Down

0 comments on commit e4a635d

Please sign in to comment.