File tree 1 file changed +6
-2
lines changed
1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -1741,11 +1741,15 @@ def __init__(
1741
1741
circuit.
1742
1742
"""
1743
1743
self ._moments : List ['cirq.Moment' ] = []
1744
+ flattened_contents = tuple (ops .flatten_to_ops_or_moments (contents ))
1745
+ if all (isinstance (c , Moment ) for c in flattened_contents ):
1746
+ self ._moments [:] = cast (Iterable [Moment ], flattened_contents )
1747
+ return
1744
1748
with _compat .block_overlapping_deprecation ('.*' ):
1745
1749
if strategy == InsertStrategy .EARLIEST :
1746
- self ._load_contents_with_earliest_strategy (contents )
1750
+ self ._load_contents_with_earliest_strategy (flattened_contents )
1747
1751
else :
1748
- self .append (contents , strategy = strategy )
1752
+ self .append (flattened_contents , strategy = strategy )
1749
1753
1750
1754
@classmethod
1751
1755
def _from_moments (cls , moments : Iterable ['cirq.Moment' ]) -> 'Circuit' :
You can’t perform that action at this time.
0 commit comments