Skip to content

Commit

Permalink
No longer overwrites manual bonds (#232)
Browse files Browse the repository at this point in the history
* No longer overwrites manual bonds

No longer overwrites bonds that were added manually before the atoms object was sent to ZnDraw

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* different approach using hasattr

* typing error

* whitespace error

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
phohenberger and pre-commit-ci[bot] authored Oct 2, 2023
1 parent c970fda commit aa72914
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion zndraw/zndraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ def on_size(size):
def _set_item(self, index, value):
assert isinstance(value, ase.Atoms), "Must be an ASE Atoms object"
assert isinstance(index, int), "Index must be an integer"
if self.bonds_calculator is not None:
if hasattr(value, "connectivity"):
pass
elif self.bonds_calculator is not None:
value.connectivity = self.bonds_calculator.build_graph(value)
else:
value.connectivity = nx.Graph()
Expand Down

0 comments on commit aa72914

Please sign in to comment.