-
Notifications
You must be signed in to change notification settings - Fork 210
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
Add SparseLabelOp base class #731
Conversation
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.
I finally had time for some more feedback on the open discussion points.
Besides that, please also relocate (now that #746 has been merged) this class to qiskit_nature/second_q/operators/sparse_label_op.py
(and the matching test location).
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.
Some feedback for now. I think in general this looks good.
It would be good, if you could also add a release note 👍
I think, we can leave the following aspects for an extension later during the refactoring process:
- more detailed documentation
- addition of
Parameter
support
Pull Request Test Coverage Report for Build 3016572442
💛 - Coveralls |
Co-authored-by: Max Rossmannek <[email protected]>
Co-authored-by: Max Rossmannek <[email protected]>
Co-authored-by: Max Rossmannek <[email protected]>
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.
Some minor comments but other than this, this LGTM 👍
Co-authored-by: Max Rossmannek <[email protected]>
Co-authored-by: Max Rossmannek <[email protected]>
Following my suggestion over in #756, I will make a similar comment here: I had another discussion with @woodsp-ibm and we said that it might be beneficial to directly implement from collections.abc import Mapping
from typing import Iterator
class SparseLabelOp(..., Mapping):
...
def __getitem__(self, __k: str) -> Number:
return self._data.__getitem__(__k)
def __len__(self) -> int:
return self._data.__len__()
def __iter__(self) -> Iterator[str]:
return self._data.__iter__() This also shows an even simpler implementation of This will directly enable users to use |
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.
Other than these suggestions, this LGTM 👍
Note: if you go to the Files
tab of the PR, you can batch all of these suggestions into a single commit, which will trigger fewer CI runs 👍
a1ea5ff
to
23e3def
Compare
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.
LGTM 👍
Thanks a lot, Abby!
I'll await another official review from @woodsp-ibm before merging 👍
|
||
|
||
class SparseLabelOp(LinearMixin, AdjointMixin, TolerancesMixin, ABC, Mapping): | ||
"""The Sparse Label Operator base 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.
Could this be fleshed out a little to explain what this is a bit more. Maybe an example usage to or something to give someone a better idea of whats this all about.
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, Abby! 🙂
* Started foundation for SparseLabelOp abstract class * Made changes based on PR comments * Update some docstrings * Refactpr sparselabelop and add test * Implemented changes requested from review * Fix mypy error * Remove Number bc it doesn't play nice with mypy * Added reno * Try adding Number check * Update qiskit_nature/operators/second_quantization/sparse_label_op.py Co-authored-by: Max Rossmannek <[email protected]> * Made changes based on review comments * Make review changes and fix mypy issues * Fixed mypy errors based on Steve's suggestions * Moved files to new subdir * Make class abstract * ✨ lint ✨ * ✨ lint again ✨ * Removed qargs check * Update qiskit_nature/second_q/operators/sparse_label_op.py Co-authored-by: Max Rossmannek <[email protected]> * Update qiskit_nature/second_q/operators/sparse_label_op.py Co-authored-by: Max Rossmannek <[email protected]> * Update qiskit_nature/second_q/operators/sparse_label_op.py Co-authored-by: Max Rossmannek <[email protected]> * Update qiskit_nature/second_q/operators/sparse_label_op.py Co-authored-by: Max Rossmannek <[email protected]> * Update qiskit_nature/second_q/operators/sparse_label_op.py Co-authored-by: Max Rossmannek <[email protected]> * Update qiskit_nature/second_q/operators/sparse_label_op.py Co-authored-by: Max Rossmannek <[email protected]> * Update releasenotes/notes/sparselabelop-class-57ffd57121dadfe5.yaml Co-authored-by: Max Rossmannek <[email protected]> * Updated based on review comments * ✨ lint ✨ * Adjusted copy and iter * Update qiskit_nature/second_q/operators/sparse_label_op.py Co-authored-by: Max Rossmannek <[email protected]> * Update qiskit_nature/second_q/operators/sparse_label_op.py Co-authored-by: Max Rossmannek <[email protected]> * ✨ lint! ✨ * ✨ lint again ✨ * Updated mapping type and added tests * Added sparselabelop to pylintdict * Apply suggestions from code review * Adjusted register length * Removed reno Co-authored-by: Max Rossmannek <[email protected]> Co-authored-by: Manoel Marques <[email protected]>
Summary
closes #669
Details and comments