Skip to content

Commit

Permalink
Update documentation comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jakelishman committed Oct 18, 2023
1 parent 7247f33 commit 586767f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions qiskit/circuit/singleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,10 @@ def _prepare_singleton_instance(instruction: Instruction):
class they are providing overrides for has more lazy attributes or user-exposed state
with interior mutability."""
instruction._define()
# Some places assume that `params` is a list not a tuple, unfortunately. The always-raises
# `__setattr__` of the classes that inherit this means the `params` setter can't be used to
# replace the object.
# We use this `list` subclass that rejects all mutation rather than a simple `tuple` because
# the `params` typing is specified as `list`. Various places in the library and beyond do
# `x.params.copy()` when they want to produce a version they own, which is good behaviour,
# and would fail if we switched to a `tuple`, which has no `copy` method.
instruction._params = _frozenlist(instruction._params)
return instruction

Expand Down Expand Up @@ -587,8 +588,9 @@ def stdlib_singleton_key(*, num_ctrl_qubits: int = 0):
if num_ctrl_qubits:

def key(label=None, ctrl_state=None, *, duration=None, unit="dt", _base_label=None):
ctrl_state = _ctrl_state_to_int(ctrl_state, num_ctrl_qubits)
if label is None and duration is None and unit == "dt" and _base_label is None:
# Normalisation; we want all types for the control state to key the same.
ctrl_state = _ctrl_state_to_int(ctrl_state, num_ctrl_qubits)
return (ctrl_state,)
return None

Expand Down

0 comments on commit 586767f

Please sign in to comment.