From a50f5ccbfcb50d4f87c6c7fb5d6879316ec7a003 Mon Sep 17 00:00:00 2001 From: marco Date: Fri, 16 Aug 2024 16:38:10 +0100 Subject: [PATCH] Fixing OverflowError: Python integer -1000 out of bounds for uint32 int32_to_negative(int32) in supplemental.py --- plip/basic/supplemental.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/plip/basic/supplemental.py b/plip/basic/supplemental.py index 4350eb5..37d25f9 100644 --- a/plip/basic/supplemental.py +++ b/plip/basic/supplemental.py @@ -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