@@ -85,12 +85,12 @@ def __init__(
85
85
86
86
Args:
87
87
qubits: The qubits to simulate.
88
- initial_state: The initial state for the simulation. Accepts int or a sequence of int.
88
+ initial_state: The initial state for the simulation. Accepts int or Sequence[ int] .
89
89
classical_data: The classical data container for the simulation.
90
90
91
91
Raises:
92
92
ValueError: If qubits not provided and initial_state is int.
93
- If initial_state is not an int, list[int], tuple [int], or np.ndarray .
93
+ If initial_state is not an int or Sequence [int].
94
94
If initial_state is a np.ndarray and its shape is not 1-dimensional.
95
95
If gate is not one of X, SWAP, QubitPermutationGate, a controlled version
96
96
of X or SWAP, or a measurement.
@@ -99,7 +99,7 @@ def __init__(
99
99
"""
100
100
if isinstance (initial_state , int ):
101
101
if qubits is None :
102
- raise ValueError ('qubits must be provided if initial_state is not list [int]' )
102
+ raise ValueError ('qubits must be provided if initial_state is not Sequence [int]' )
103
103
state = ClassicalBasisState (
104
104
big_endian_int_to_bits (initial_state , bit_count = len (qubits ))
105
105
)
@@ -109,10 +109,10 @@ def __init__(
109
109
f'initial_state must be 1-dimensional, got shape { initial_state .shape } '
110
110
)
111
111
state = ClassicalBasisState (list (initial_state ))
112
- elif isinstance (initial_state , ( list , tuple )):
112
+ elif isinstance (initial_state , Sequence ) and not isinstance ( initial_state , ( str , bytes )):
113
113
state = ClassicalBasisState (list (initial_state ))
114
114
else :
115
- raise ValueError ('initial_state must be an int, list[int], tuple [int], or np.ndarray ' )
115
+ raise ValueError ('initial_state must be an int or Sequence [int]' )
116
116
super ().__init__ (state = state , qubits = qubits , classical_data = classical_data )
117
117
118
118
def _act_on_fallback_ (self , action , qubits : Sequence [cirq .Qid ], allow_decompose : bool = True ):
0 commit comments