@@ -1717,7 +1717,8 @@ def __init__(
1717
1717
"""
1718
1718
self ._moments : List ['cirq.Moment' ] = []
1719
1719
self ._device = device
1720
- self .append (contents , strategy = strategy )
1720
+ with _compat .block_overlapping_deprecation ('.*' ):
1721
+ self .append (contents , strategy = strategy )
1721
1722
1722
1723
@property # type: ignore
1723
1724
@_compat .deprecated (
@@ -2045,15 +2046,32 @@ def insert(
2045
2046
Raises:
2046
2047
ValueError: Bad insertion strategy.
2047
2048
"""
2048
- moments_and_operations = list (
2049
- ops .flatten_to_ops_or_moments (
2050
- ops .transform_op_tree (
2051
- moment_or_operation_tree ,
2052
- self ._device .decompose_operation ,
2053
- preserve_moments = True ,
2054
- ),
2049
+ if self ._device == devices .UNCONSTRAINED_DEVICE :
2050
+ moments_and_operations = list (
2051
+ ops .flatten_to_ops_or_moments (
2052
+ ops .transform_op_tree (
2053
+ moment_or_operation_tree ,
2054
+ preserve_moments = True ,
2055
+ ),
2056
+ )
2055
2057
)
2056
- )
2058
+ else :
2059
+ _compat ._warn_or_error (
2060
+ 'circuit.insert behavior relies on circuit.device.\n '
2061
+ 'The ability to construct a circuit with a device\n '
2062
+ 'will be removed in cirq v0.15. please update this use of\n '
2063
+ 'insert.'
2064
+ )
2065
+ with _compat .block_overlapping_deprecation ('decompose' ):
2066
+ moments_and_operations = list (
2067
+ ops .flatten_to_ops_or_moments (
2068
+ ops .transform_op_tree (
2069
+ moment_or_operation_tree ,
2070
+ self ._device .decompose_operation ,
2071
+ preserve_moments = True ,
2072
+ ),
2073
+ )
2074
+ )
2057
2075
2058
2076
for moment_or_op in moments_and_operations :
2059
2077
if isinstance (moment_or_op , ops .Moment ):
@@ -2114,7 +2132,7 @@ def insert_into_range(self, operations: 'cirq.OP_TREE', start: int, end: int) ->
2114
2132
)
2115
2133
cannot_add_lambda = lambda a , b : not self ._device .can_add_operation_into_moment (a , b )
2116
2134
2117
- with _compat .block_overlapping_deprecation ('can_add_operation_into_moment' ):
2135
+ with _compat .block_overlapping_deprecation ('( can_add_operation_into_moment|insert) ' ):
2118
2136
while op_index < len (flat_ops ):
2119
2137
op = flat_ops [op_index ]
2120
2138
while i < end and cannot_add_lambda (op , self ._moments [i ]):
0 commit comments