Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
4.83k stars 2.29k forks source link

validate `order` kwarg in `BitArray.from_bool_array()` #12673

Open aeddins-ibm opened 3 days ago

aeddins-ibm commented 3 days ago

Environment

What is happening?

BitArray.from_bool_array() has a kwarg order which nominally should be 'little' or 'big' (for bit-ordering of the input array).

The function only checks whether or not order == 'little': https://github.com/Qiskit/qiskit/blob/76af5b475b9b2a57f9eeabd3c0b793b037464630/qiskit/primitives/containers/bit_array.py#L207-L210

Would be helpful to raise an error if order is neither 'little' nor 'big'. Otherwise e.g. a user will unknowingly get the wrong result if they typo order = 'litle'.

How can we reproduce the issue?

see above

What should happen?

see above

Any suggestions?

No response