Skip to content

Python API dump_machine should represent amplitudes as complex numbers instead of tuples #1177

@tcNickolas

Description

@tcNickolas

Describe the bug

Python API dump_machine() represents amplitudes of the state as tuples. This is very inconvenient, since the first thing I need to do with its return is get rid of the global phase, which requires converting the amplitudes to complex type. (The complex global phase shows up even in simple scenarios that use only Ry gates, so I couldn't find a case where having only tuples would suffice.)

To Reproduce

Run dump_machine(), for example, using https://github.com/microsoft/qsharp/blob/36a091c23144014a3f9e64169210a30262f9095f/pip/tests/test_qsharp.py#L63.

Expected behavior

Return a dictionary of complex numbers, similar to Qiskit statevector behavior.

Additional context

I can unpack the tuple representing the amplitude and convert its fields into complex type manually, but I'll need to do it every time I use dump_machine(), so it really makes sense to have the API do it instead.

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