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
When adding custom annotations to an AtomArray, they are not displayed in the repr() of that array. I think this is because the annotations are hardcoded in the __repr__ method of Atom.
Showing all annotations would make it more straightforward to interactively do structural analysis, especially in a Notebook context where you frequently print atom arrays.
Below is a suggestion for a potential fix. If this would be an interesting feature to be added to Biotite I'm happy to make a PR.
def__repr__(self):
# print out key-value pairs and format strings in quotation marksannot_parts= [
f'{key}="{value}"'ifisinstance(value, str) elsef'{key}={value}'forkey, valueinself._annot.items()
]
annot=', '.join(annot_parts)
returnf'Atom(np.{np.array_repr(self.coord)}, {annot})'
The text was updated successfully, but these errors were encountered:
Since repr() is intended to return actual code that recreates an object (https://docs.python.org/3/library/functions.html#repr), I would even consider the current behavior a bug, as information would be missing. Hence, your PR would be welcome.
* Fix Atom __repr__() (#602)
This changes the hardcoded Atom __repr__() to a more general version that will additionally print custom added attributes.
* Add back docstring
* Add new contributor (PR for #602)
When adding custom annotations to an
AtomArray
, they are not displayed in therepr()
of that array. I think this is because the annotations are hardcoded in the__repr__
method ofAtom
.Showing all annotations would make it more straightforward to interactively do structural analysis, especially in a Notebook context where you frequently print atom arrays.
Below is a suggestion for a potential fix. If this would be an interesting feature to be added to Biotite I'm happy to make a PR.
The text was updated successfully, but these errors were encountered: