qiskit-community / qiskit-nature

Qiskit Nature is an open-source, quantum computing, framework for solving quantum mechanical natural science problems.
https://qiskit-community.github.io/qiskit-nature/
Apache License 2.0
301 stars 204 forks source link

docs: improve the documentation of SparseLabelOp.simplify #1261

Closed mrossinek closed 1 year ago

mrossinek commented 1 year ago

Summary

Closes #1260

Details and comments

coveralls commented 1 year ago

Pull Request Test Coverage Report for Build 6336900218


Totals Coverage Status
Change from base Build 6323000347: 0.01%
Covered Lines: 8707
Relevant Lines: 10038

💛 - Coveralls
woodsp-ibm commented 1 year ago

In FermionicOp there is a note in index_order method that pertains to simplify. Would it be better in conjunction with this to more have a note in simplify so if you look at the subclass simplify docs you have an idea of the other methods that can be called first to potentially allow simplify to further reduce things. At present, both it and VibrationalOp inherit the SparseLabelOp simplify docstring that was updated here - so it would mean adding something for them - which BosonicOp already seems to do as it has further details there pertinent to that sub-class.

mrossinek commented 1 year ago

I tried to find a solution which does not require duplicating the simplify docstring into the subclasses in order to append to it. If you feel this solution is not sufficient, we can do that though.

woodsp-ibm commented 1 year ago

I certainly would not suggest duplicating the entire thing - of course the args bit one has too and a sentence describing it. This is pretty much what BosonicOp.simplify() has plus some extra specific notes for that operator - it does not inherit the parent class docstring unlike FermionicOp or VibrationalOp. It is a bit extra work to do this for simplify but it could save the user going around other methods in the class to see if they would help - like index_order for example may do. I'll leave it to you - I'll approve this since in improves what it states - anything further like I was suggesting can always be done later since its "just docs".

mrossinek commented 1 year ago

I actually had overlooked that BosonicOp.simplify already has a custom docstring. I will take another look on how to improve things :+1:

mrossinek commented 1 year ago

Okay, I did end up duplicating them but this allows a proper linking to the index_order method. I did consider adding index_order as an abstractmethod to SparseLabelOp (because it is implemented by all of its subclasses anyways) but I was not confident that we really want to enforce this.

Since this is "just docs" lets leave it as a PR that really affects "just docs".

I also took the note regarding the difference between simplify and chop which we had in the BosonicOp docstring and made sure we have this everywhere.