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

Enable pylint's dangerous-default-value check #544

Merged
merged 3 commits into from
Apr 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
8 changes: 4 additions & 4 deletions circuit_knitting/cutting/cut_finding/circuit_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ class SimpleGateList(CircuitInterface):
`cut_type` (list): a list that assigns cut-type annotations to gates
in ``new_circuit``.

`new_gate_ID`_map (list): a list that maps the positions of gates
`new_gate_ID`_map (array): an array that maps the positions of gates
in circuit to their new positions in ``new_circuit``.

`output_wires` (list): a list that maps qubit IDs in circuit to the corresponding
`output_wires` (array): an array that maps qubit IDs in circuit to the corresponding
output wires of new_circuit so that observables defined for circuit
can be remapped to ``new_circuit``.

Expand All @@ -158,7 +158,7 @@ class SimpleGateList(CircuitInterface):
def __init__(
self,
input_circuit: list[CircuitElement | str],
init_qubit_names: list[Hashable] = [],
init_qubit_names: Sequence[Hashable] = (),
):
"""Assign member variables."""
self.qubit_names = NameToIDMap(init_qubit_names)
Expand Down Expand Up @@ -410,7 +410,7 @@ def replace_wire_ids(
class NameToIDMap:
"""Class used to construct maps between hashable items (e.g., qubit names) and natural numbers (e.g., qubit IDs)."""

def __init__(self, init_names: list[Hashable]):
def __init__(self, init_names: Sequence[Hashable]):
"""Allow the name dictionary to be initialized with the names in ``init_names`` in the order the names appear.

This is done in order to force a preferred ordering in the assigment of item IDs to those names.
Expand Down
16 changes: 10 additions & 6 deletions circuit_knitting/cutting/cut_finding/cut_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,18 @@ def __init__(
circuit_interface,
optimization_settings,
device_constraints,
search_engine_config={
"CutOptimization": SearchSpaceGenerator(
functions=cut_optimization_search_funcs,
actions=disjoint_subcircuit_actions,
)
},
search_engine_config=None,
):
"""Assign member variables."""
if search_engine_config is None:
# Set default config
search_engine_config = {
"CutOptimization": SearchSpaceGenerator(
functions=cut_optimization_search_funcs,
actions=disjoint_subcircuit_actions,
)
}

generator = search_engine_config["CutOptimization"]
search_space_funcs = generator.functions
search_space_actions = generator.actions
Expand Down
16 changes: 10 additions & 6 deletions circuit_knitting/cutting/cut_finding/lo_cuts_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,18 @@ def __init__(
circuit_interface=None,
optimization_settings=None,
device_constraints=None,
search_engine_config={
"CutOptimization": SearchSpaceGenerator(
functions=cut_optimization_search_funcs,
actions=disjoint_subcircuit_actions,
)
},
search_engine_config=None,
):
"""Initialize :class:`LOCutsOptimizer with the specified configuration variables."""
if search_engine_config is None:
# Set default config
search_engine_config = {
"CutOptimization": SearchSpaceGenerator(
functions=cut_optimization_search_funcs,
actions=disjoint_subcircuit_actions,
)
}

self.circuit_interface = circuit_interface
self.optimization_settings = optimization_settings
self.device_constraints = device_constraints
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ enable = [
"unused-argument",
"use-list-literal",
"use-dict-literal",
"dangerous-default-value",
]

#[tool.coverage.run]
Expand Down