You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment, the primitives run() method typehints use collections.abc.Sequence for batches of circuits, parameter values or observables. However, we want to support inputs of type np.ndarray, which don't implement the Sequence protocol (they don't implement count() or index()).
After an internal discussion, it looks like a good solution is to change the typehints from Sequence to Iterable (numpy arrays do satisfy Iterable), and normalize the input to tuple or list for internal use. This would require some changes in type checking/error handling (in particular, in BasePrimitive._validate_circuits).
The text was updated successfully, but these errors were encountered:
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.
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
).The text was updated successfully, but these errors were encountered: