-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New methods in ObservablesArray
: sparse_observables_array
and sparse_observables_array_slice
#14344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: Ian Hincks <ian.hincks@gmail.com>
Co-authored-by: Ian Hincks <ian.hincks@gmail.com>
Co-authored-by: Ian Hincks <ian.hincks@gmail.com>
Co-authored-by: Ian Hincks <ian.hincks@gmail.com>
Co-authored-by: Ian Hincks <ian.hincks@gmail.com>
Co-authored-by: Ian Hincks <ian.hincks@gmail.com>
Co-authored-by: Ian Hincks <ian.hincks@gmail.com>
Co-authored-by: Ian Hincks <ian.hincks@gmail.com>
One or more of the following people are relevant to this code:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @yaelbh !!
Co-authored-by: Ian Hincks <ian.hincks@gmail.com>
Co-authored-by: Ian Hincks <ian.hincks@gmail.com>
Co-authored-by: Ian Hincks <ian.hincks@gmail.com>
Co-authored-by: Ian Hincks <ian.hincks@gmail.com>
Co-authored-by: Ian Hincks <ian.hincks@gmail.com>
ObservablesArray
: get_sparse_observable
and sparse_observables_array
ObservablesArray
: sparse_observables_array
and sparse_observables_array_slice
obs = self.copy() if copy else self | ||
return obs._array | ||
|
||
IndexType = Union[int, slice, None] # pylint: disable=used-before-assignment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is currently in the namespace of the ObservablesArray
(as ObservablesArray.IndexType
). I would move it to the module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by moving it to the class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry that was a typo, fixed. I mean moving it out of the class, into the module.
…arse_observables_array_slice` (Qiskit#14344) * added SparseObservable to ObservableLike * wrote apply_layout * wrote test_equivalent * more layout tests * black * lint * Update qiskit/primitives/containers/observables_array.py Co-authored-by: Ian Hincks <ian.hincks@gmail.com> * Update qiskit/primitives/containers/observables_array.py Co-authored-by: Ian Hincks <ian.hincks@gmail.com> * Update qiskit/primitives/containers/observables_array.py Co-authored-by: Ian Hincks <ian.hincks@gmail.com> * create the zero observable outside of a loop * Update qiskit/primitives/containers/observables_array.py Co-authored-by: Ian Hincks <ian.hincks@gmail.com> * Update qiskit/primitives/containers/observables_array.py Co-authored-by: Ian Hincks <ian.hincks@gmail.com> * don't import unused List * Update qiskit/primitives/containers/observables_array.py Co-authored-by: Ian Hincks <ian.hincks@gmail.com> * Update qiskit/primitives/containers/observables_array.py Co-authored-by: Ian Hincks <ian.hincks@gmail.com> * setting validate=False in a reliable creation of an ObervablesArray object * black * Update qiskit/primitives/containers/observables_array.py Co-authored-by: Ian Hincks <ian.hincks@gmail.com> * fixing doc string * defer apply_layout checks to SparseObservable * lint * wrote get_sparse_observable * wrote sparse_observables_array * typo * removed Ellipsis type because of CI failure * release notes * Update qiskit/primitives/containers/observables_array.py Co-authored-by: Ian Hincks <ian.hincks@gmail.com> * Update qiskit/primitives/containers/observables_array.py Co-authored-by: Ian Hincks <ian.hincks@gmail.com> * Update qiskit/primitives/containers/observables_array.py Co-authored-by: Ian Hincks <ian.hincks@gmail.com> * Update releasenotes/notes/observables-array-7d7544b3bb3fbaa3.yaml Co-authored-by: Ian Hincks <ian.hincks@gmail.com> * Update releasenotes/notes/observables-array-7d7544b3bb3fbaa3.yaml Co-authored-by: Ian Hincks <ian.hincks@gmail.com> * renamed function * black * fixes * shorten method name to 'slice' * disable an erroneous lint error * moving IndexType outside of obs-array class --------- Co-authored-by: Ian Hincks <ian.hincks@gmail.com> Co-authored-by: Ian Hincks <ian.hincks@ibm.com>
…arse_observables_array_slice` (Qiskit#14344) * added SparseObservable to ObservableLike * wrote apply_layout * wrote test_equivalent * more layout tests * black * lint * Update qiskit/primitives/containers/observables_array.py Co-authored-by: Ian Hincks <ian.hincks@gmail.com> * Update qiskit/primitives/containers/observables_array.py Co-authored-by: Ian Hincks <ian.hincks@gmail.com> * Update qiskit/primitives/containers/observables_array.py Co-authored-by: Ian Hincks <ian.hincks@gmail.com> * create the zero observable outside of a loop * Update qiskit/primitives/containers/observables_array.py Co-authored-by: Ian Hincks <ian.hincks@gmail.com> * Update qiskit/primitives/containers/observables_array.py Co-authored-by: Ian Hincks <ian.hincks@gmail.com> * don't import unused List * Update qiskit/primitives/containers/observables_array.py Co-authored-by: Ian Hincks <ian.hincks@gmail.com> * Update qiskit/primitives/containers/observables_array.py Co-authored-by: Ian Hincks <ian.hincks@gmail.com> * setting validate=False in a reliable creation of an ObervablesArray object * black * Update qiskit/primitives/containers/observables_array.py Co-authored-by: Ian Hincks <ian.hincks@gmail.com> * fixing doc string * defer apply_layout checks to SparseObservable * lint * wrote get_sparse_observable * wrote sparse_observables_array * typo * removed Ellipsis type because of CI failure * release notes * Update qiskit/primitives/containers/observables_array.py Co-authored-by: Ian Hincks <ian.hincks@gmail.com> * Update qiskit/primitives/containers/observables_array.py Co-authored-by: Ian Hincks <ian.hincks@gmail.com> * Update qiskit/primitives/containers/observables_array.py Co-authored-by: Ian Hincks <ian.hincks@gmail.com> * Update releasenotes/notes/observables-array-7d7544b3bb3fbaa3.yaml Co-authored-by: Ian Hincks <ian.hincks@gmail.com> * Update releasenotes/notes/observables-array-7d7544b3bb3fbaa3.yaml Co-authored-by: Ian Hincks <ian.hincks@gmail.com> * renamed function * black * fixes * shorten method name to 'slice' * disable an erroneous lint error * moving IndexType outside of obs-array class --------- Co-authored-by: Ian Hincks <ian.hincks@gmail.com> Co-authored-by: Ian Hincks <ian.hincks@ibm.com>
Summary
This is the last PR for completion of #14129.
Details and comments
In addition to the new methods, I changed the type hints of
__getitem__
and enhanced its tests. The type hints are still not fully accurate, since they don't covertuple[()]
(as inarr[()]
), but I don't want to make them more cumbersome.