Hi.

Based on the last email from Andreas, it seems that upgrading to 2.6.0 will
not be as simple as I thought.

This is what I tried without success:

I tried dropping the current debian/patches/numpy2.patch and using
the attached patch instead, which is based on upstream's commit
regarding NumPy.

Those two patches overlap to some extent, but I'm not 100% sure that
the second one should work as a drop-in replacement of the first.

Thanks.
From: Nathaniel Echols <[email protected]>
Subject: [SL-11761] fix numpy 2.x compatibility
Bug-Debian: https://bugs.debian.org/1114717

--- python-pbcore-2.1.2+dfsg.orig/pbcore/io/align/BamAlignment.py
+++ python-pbcore-2.1.2+dfsg/pbcore/io/align/BamAlignment.py
@@ -532,7 +532,10 @@ class BamAlignment(AlignmentRecordMixin)
         if data.dtype == np.int8:
             gapCode = ord("-")
         else:
-            gapCode = data.dtype.type(-1)
+            try:
+                gapCode = data.dtype.type(-1)
+            except OverflowError:
+                gapCode = data.dtype.type(np.iinfo(data.dtype).max)
         uc = self.unrolledCigar(orientation=orientation)
         alnData = np.repeat(np.array(gapCode, dtype=data.dtype), len(uc))
         gapMask = (uc == gapOp)
--- python-pbcore-2.1.2+dfsg.orig/pbcore/io/align/_BamSupport.py
+++ python-pbcore-2.1.2+dfsg/pbcore/io/align/_BamSupport.py
@@ -1,5 +1,7 @@
 # Author: David Alexander
 
+import re
+
 import numpy as np
 
 
@@ -63,7 +65,13 @@ BAM_CDIFF = 8
 # qId calculation from RG ID string
 #
 def rgAsInt(rgIdString):
-    return np.int32(int(rgIdString.split("/")[0], 16))
+    numericId = int(rgIdString.split("/")[0].split("-")[0], 16)
+    # Identifiers may exceed the 32-bit range, so compensate manually
+    # the overflow, otherwise numpy 2 and later raises OverflowError.
+    overflownId = (numericId + np.iinfo(np.int32).min) \
+                  % (2 * (np.iinfo(np.int32).max + 1)) \
+                  + np.iinfo(np.int32).min
+    return np.int32(overflownId)
 
 #
 # Kinetics: decode the scheme we are using to encode approximate frame
--- python-pbcore-2.1.2+dfsg.orig/pbcore/io/dataset/DataSetMembers.py
+++ python-pbcore-2.1.2+dfsg/pbcore/io/dataset/DataSetMembers.py
@@ -827,7 +827,7 @@ class Filters(RecordWrapper):
                 'mapqv': (lambda x: x.mapQV),
                 'accuracy': (
                     lambda x: (np.ones(len(x.nMM), dtype='f4') -
-                               (x.nMM + x.nIns + x.nDel).astype(float) /
+                               (x.nMM + x.nIns + x.nDel).astype(float32) /
                                (x.nM + x.nMM + x.nIns)))
                 }
         base = self._pbiVecAccMap()

Reply via email to