Skip to content

bug in dealing with data type at one_qubit_decompose.py #9827

@youngseok-kim1

Description

@youngseok-kim1

Environment

  • Qiskit Terra version:
    {'qiskit-terra': '0.23.0', 'qiskit-aer': '0.11.2', 'qiskit-ignis': '0.7.0', 'qiskit-ibmq-provider': '0.19.2', 'qiskit': '0.40.0', 'qiskit-nature': None, 'qiskit-finance': None, 'qiskit-optimization': None, 'qiskit-machine-learning': None}
  • Python version:
    python3.8
  • Operating system: linux

What is happening?

I see error message as below:

"/home/labuser/.virtualenvs/controller/lib/python3.8/site-packages/qiskit/quantum_info/synthesis/one_qubit_decompose.py", line 242, in angles_and_phase
    return self._params(unitary)
  File "/home/labuser/.virtualenvs/controller/lib/python3.8/site-packages/qiskit/quantum_info/synthesis/one_qubit_decompose.py", line 265, in _params_u1x
    theta, phi, lam, phase = OneQubitEulerDecomposer._params_zyz(mat)
TypeError: argument 'unitary': type mismatch:
 from=float64, to=complex128

this was with input

[[ 0.70710678  0.70710678]                          
 [ 0.70710678 -0.70710678]] 

How can we reproduce the issue?

from   qiskit.quantum_info import OneQubitEulerDecomposer

rzsxDecomposer = OneQubitEulerDecomposer('PSX')
M=[[ 0.70710678,  0.70710678] , [ 0.70710678, -0.70710678]] 
(theta, phi, lam, gamma) = rzsxDecomposer.angles_and_phase(M)

The error can be resolved by manually casting M to complex;

from   qiskit.quantum_info import OneQubitEulerDecomposer

rzsxDecomposer = OneQubitEulerDecomposer('PSX')
M=[[ 0.70710678,  0.70710678] , [ 0.70710678, -0.70710678]] 
(theta, phi, lam, gamma) = rzsxDecomposer.angles_and_phase(np.array(M).astype(complex))

What should happen?

flag the data type error

Any suggestions?

add wrapper before pass it to rust so that every variable we are passing is casted to complex

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions