Skip to content

Commit

Permalink
Handle case of empty structure
Browse files Browse the repository at this point in the history
  • Loading branch information
padix-key committed Jan 25, 2025
1 parent 4d05f3c commit 8ee7779
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/biotite/structure/chains.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ def get_chain_starts(array, add_exclusive_stop=False):
--------
get_residue_starts
"""
if array.array_length() == 0:
return np.array([], dtype=int)

diff = np.diff(array.res_id)
res_id_decrement = diff < 0
# This mask is 'true' at indices where the value changes
Expand Down
3 changes: 3 additions & 0 deletions src/biotite/structure/residues.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ def get_residue_starts(array, add_exclusive_stop=False):
[ 0 16 35 56 75 92 116 135 157 169 176 183 197 208 219 226 250 264
278 292 304]
"""
if array.array_length() == 0:
return np.array([], dtype=int)

# These mask are 'true' at indices where the value changes
chain_id_changes = array.chain_id[1:] != array.chain_id[:-1]
res_id_changes = array.res_id[1:] != array.res_id[:-1]
Expand Down

0 comments on commit 8ee7779

Please sign in to comment.