Skip to content

Commit

Permalink
fix bug in add two bond lists.
Browse files Browse the repository at this point in the history
Co-authored-by: WenZhi Ma <masgils@foxmail.com>
  • Loading branch information
0ut0fcontrol and cloverzizi committed Jun 30, 2024
1 parent 2331695 commit 87b1372
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/biotite/structure/bonds.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ class BondList(Copyable):
# maximum and redundant bond calculation
merged_bond_list._bonds = merged_bonds
merged_bond_list._max_bonds_per_atom = max(
self._max_bonds_per_atom, merged_bond_list._max_bonds_per_atom
self._max_bonds_per_atom, bond_list._max_bonds_per_atom
)
return merged_bond_list

Expand Down
13 changes: 13 additions & 0 deletions tests/structure/test_bonds.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,19 @@ def test_modification(bond_list):
[1, 4, 0]]


def test_add_two_bond_list():
"""
Test adding two `BondList` objects.
"""
bond_list1 = struc.BondList(2, np.array([(0,1)])) # max_bond_per_atom=1
bond_list2 = struc.BondList(3, np.array([(0,1),(0,2)])) # max_bond_per_atom=2
added_list = bond_list1 + bond_list2
assert added_list._max_bonds_per_atom == 2
assert added_list.get_bonds(2)[0].tolist() == [3, 4]
assert added_list.as_array().tolist() == [[0, 1, 0],
[2, 3, 0],
[2, 4, 0]]

def test_contains(bond_list):
"""
Test whether `BondList` correctly identifies whether it contains a
Expand Down

0 comments on commit 87b1372

Please sign in to comment.