Closed DrissiReda closed 5 years ago
The control qubits are only added to the command after it is received by the ControlEngine
further down the chain after the MainEngine
. For implementation details see “3.2.1 Implementation of meta instructions” in https://doi.org/10.3929/ethz-b-000322770.
To implement a testing engine such as yours, that can be used to check that indeed control qubits are added right after the MainEngine
, you could do the following:
test_eng = Testing(BasicEngine) # Or CommandPrinter
eng = projectq.MainEngine(engine_list=[test_eng])
Thank you, that is important information, but I cannot use MainEngine
since I want to create a class that inherits from it and adds a few functions, using your method prevents me from getting these functions.
Edit: it actually works even with another class but I would get this output whenever I try to add some more functions, the funny thing is, when I add a change that causes this, even after that change is removed I still get the same output, if I copy that same code (with the removed problematic change) that worked earlier but doesn't work now into another file, the problem would cease to occur :
Traceback (most recent call last):
File "test.py", line 51, in <module>
C(X, n=2) | (q[0], q[1], q[2])
File "/usr/lib64/python3.4/site-packages/projectq/ops/_metagates.py", line 217,in __or__
self._gate | tuple(gate_quregs)
TypeError: unsupported operand type(s) for |: 'PredefGate' and 'tuple'
Edit2: Also how normal is this?
>>> from projectq import ops
>>> ops.SqrtGate
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'SqrtGate'
>>> ops.SqrtSwap
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'SqrtSwap'
>>> ops.SqrtX
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'SqrtX'
>>> ops.SqrtXGate
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'SqrtXGate'
>>> ops.SqrtSwapGate
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'SqrtSwapGate'
>>> ops.Swap
<projectq.ops._gates.SwapGate object at 0x7f8d79001fd0>
>>>
The problem only occurs with SqrtSwap
and SqrtX
the rest of the gates work normally. I'm using
Python 3.4.5 and projectq version 0.3.5
That's perfectly normal, your version of ProjectQ does not have these gates yet.
For the other things, I would suggest opening a new issue and describe in more details what you are trying to achieve. Otherwise it is hard to help.
I cannot find the control qubits inside the cmd object here is a minimal code to reproduce the issue:
The output is :
Aren't the control qubits supposed to be in the
_control_qubits
list? The only qubits I can find are the target qubits inside the_qubits
list