Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing OverflowError: Python integer -1000 out of bounds for uint32 #158

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions plip/basic/supplemental.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,16 +351,14 @@ def canonicalize(lig, preserve_bond_order=False):


def int32_to_negative(int32):
"""Checks if a suspicious number (e.g. ligand position) is in fact a negative number represented as a
32 bit integer and returns the actual number.
"""Checks if a suspicious number (e.g., ligand position) is in fact a negative number represented as a
32-bit integer and returns the actual number.
"""
dct = {}
if int32 == 4294967295: # Special case in some structures (note, this is just a workaround)
return -1
for i in range(-1000, -1):
dct[int(np.array(i).astype(np.uint32))] = i
if int32 in dct:
return dct[int32]
uint32_value = np.uint32(int32)
if uint32_value >= 2147483648:
return int(uint32_value - 4294967296)
else:
return int32

Expand Down