Skip to content

Reducing some code by cleaning up some logic #6003

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

Merged
merged 3 commits into from
Feb 12, 2023
Merged
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: 3 additions & 5 deletions cirq-core/cirq/circuits/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1861,9 +1861,8 @@ def __setitem__(self, key: slice, value: Iterable['cirq.Moment']):
pass

def __setitem__(self, key, value):
if isinstance(key, int):
if not isinstance(value, Moment):
raise TypeError('Can only assign Moments into Circuits.')
if isinstance(key, int) and not isinstance(value, Moment):
raise TypeError('Can only assign Moments into Circuits.')

if isinstance(key, slice):
value = list(value)
Expand Down Expand Up @@ -2595,8 +2594,7 @@ def _get_global_phase_and_tags_for_op(op: 'cirq.Operation') -> Tuple[Optional[co
elif isinstance(op.untagged, CircuitOperation):
op_phase, op_tags = _get_global_phase_and_tags_for_ops(op.untagged.circuit.all_operations())
return op_phase, list(op.tags) + op_tags
else:
return None, []
return None, []


def _get_global_phase_and_tags_for_ops(op_list: Any) -> Tuple[Optional[complex], List[Any]]:
Expand Down