Skip to content

Commit

Permalink
Reducing some code by cleaning up some logic (#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 committed Feb 12, 2023
1 parent 3dc9629 commit dd2667a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions cirq-core/cirq/circuits/circuit.py
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 dd2667a

Please sign in to comment.