-
Notifications
You must be signed in to change notification settings - Fork 876
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
Improvements to the documentation of the Lobsterenv module #3079
Improvements to the documentation of the Lobsterenv module #3079
Conversation
@janosh, I tried to add more type hinting but mypy was raising very weird errors. |
pymatgen/io/lobster/lobsterenv.py
Outdated
number of identified bonds to the selected sites (int), | ||
labels (from ICOHPLIST) for all identified bonds returned as a list of site names, e.g., | ||
['Ag3', 'O5'] [the latter is useful for plotting summed COHP plots] (list), | ||
list of the central isite for each identified interaction (list) |
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.
The return value of the function also has an "atoms" entry but I don't see that here?
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.
Yes, you are correct. I somehow merged labels and atoms in the description.
Where functions are returning a large tuple containing various types and lengths of data, it might be helpful to wrap them up as a NamedTuple. This would be backward-compatible as you still can access the elements by index, but also allows:
Be aware that while a lot of the old docs and tutorials recommend to use the So we could do something like class ICOHPNeighboursInfo(NamedTuple):
total: float
interaction_sums: List[float]
n_bonds: int
labels: List[str]
atoms: List[SomeAtomTypeOrOther]
central_isites: List[int]
class LobsterNeighbors(NearNeighbors):
...
def get_info_icohps_to_neighbors(
self,
isites: Optional[List[int]] = None,
onlycation_isites: bool = True
) -> ICOHPNeighboursInfo:
...
return ICOHPNeigboursInfo(summed_icohps, list_icohps, number_bonds, labels, atoms, final_isites) |
Thanks, @ajjackson , this is a great suggestion. I will implement it as it is much cleaner. |
@ajjackson , I implemented the named tuple |
pymatgen/io/lobster/lobsterenv.py
Outdated
filename_ICOHP: str = None, | ||
valences: list[int | float] = None, | ||
limits: tuple[float, float] | None = None, | ||
structure: Structure = None, |
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.
@janosh, I tried to add more type hinting but mypy was raising very weird errors.
Is the structure
arg really optional here? What happens if you don't supply a structure?
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.
You are correct. Same is true for "filename_ICOHP".
Co-authored-by: Janosh Riebesell <janosh.riebesell@gmail.com>
…nto lobsterenv_improvements
Co-authored-by: Janosh Riebesell <janosh.riebesell@gmail.com>
…nto lobsterenv_improvements
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 @JaGeo! 👍
I improved the documentation of the LobsterEnv module which was triggered by our updates to LobsterPy (JaGeo/LobsterPy#81) and suggestions by @ajjackson
@janosh : happy to hear additional thoughts from you.