You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
File "...\learn-qc-with-python-and-qsharp\ch05\simulator.py", line 88, in _apply
matrix = qt.circuit.gate_expand_1toN(
AttributeError: module 'qutip.qip.circuit' has no attribute 'gate_expand_1toN'
File "...\learn-qc-with-python-and-qsharp\ch06\simulator.py", line 124, in _apply
matrix = qt.circuit.gate_expand_2toN(unitary,
AttributeError: module 'qutip.qip.circuit' has no attribute 'gate_expand_2toN'
The text was updated successfully, but these errors were encountered:
MrSago
changed the title
Module 'qutip.qip.circuit' has no attribute 'gate_expand_1toN'
Module 'qutip.qip.circuit' has no attribute 'gate_expand_1toN' and 'gate_expand_2toN'
Aug 31, 2021
I'd also recommend locking your qutip install to 4.7.6, i.e. pip install qutip==4.7.6, as qutip version 5 doesn't have that method anymore. Unfortunately, I'm not sure what the version 5 equivalent is.
In version 5.1.0 you can use the qutip.expand_operator() function. This is a generalised version of the gate_expand_ntoN() functions so the input is a bit different. In this case I got it to work by doing this: matrix = qt.expand_operator(unitary, [2] * self.capacity, ids[0]) in the _apply() method of the Simulator. Similar for the measure() method of the SimulatedQubit: qt.expand_operator(qt.basis(2, outcome) * qt.basis(2, outcome).dag(), [2] *self.parent.capacity, self.qubit_id).
This works since the function expects the dimensionality of the composite systems, in this case simple qubits, which have 2 states. So multiplying this by the amount of qubits gives the total dimensionality specification. In the old version this was handled on a case-by-case basis so this was not necessary.
The text was updated successfully, but these errors were encountered: