Skip to content

Commit

Permalink
Reducing some code by cleaning up some logic (quantumlib#6003)
Browse files Browse the repository at this point in the history
* reducing some indenting and amount of reading by changing some logic around in circuit.py

* reverting change per code review

---------

Co-authored-by: Adam Zalcman <40255865+viathor@users.noreply.github.com>
  • Loading branch information
joesho112358 and viathor authored Feb 12, 2023
1 parent c118c51 commit 5062c78
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions 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

0 comments on commit 5062c78

Please sign in to comment.