Skip to content

Commit

Permalink
Merge pull request biotite-dev#618 from 0ut0fcontrol/fix_add_two_bond…
Browse files Browse the repository at this point in the history
…_list

fix a bug in add two bond lists.
  • Loading branch information
padix-key authored Jul 2, 2024
2 parents 2331695 + 87b1372 commit 79568bb
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 79568bb

Please sign in to comment.