Closed ElePT closed 2 months ago
Is any of these https://github.com/Qiskit/qiskit-terra/pulls?q=is%3Apr+label%3Amypy a fix for this issue?
TL;DR: No
I noticed this issue while reviewing #8263, but considered out of scope for this PR, as it affects the primitive base class, and therefore other implementations of the primitives.
I close this because the Primitives V1 is deprecated #12575
What should we add?
At the moment, the primitives
run()
method typehints usecollections.abc.Sequence
for batches of circuits, parameter values or observables. However, we want to support inputs of typenp.ndarray
, which don't implement theSequence
protocol (they don't implementcount()
orindex()
).After an internal discussion, it looks like a good solution is to change the typehints from
Sequence
toIterable
(numpy arrays do satisfyIterable
), and normalize the input totuple
orlist
for internal use. This would require some changes in type checking/error handling (in particular, inBasePrimitive._validate_circuits
).