File: fix-type-cast-i386.patch

package info (click to toggle)
python-biopython 1.85%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 126,380 kB
  • sloc: xml: 1,047,995; python: 332,722; ansic: 16,944; sql: 1,208; makefile: 142; sh: 81
file content (48 lines) | stat: -rw-r--r-- 2,282 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Description: fix test failure on 32-bit platforms.
 This fixes the following symptom while running the test suite of
 Biopython on 32-bit processors:
 .
           File "/builds/med-team/python-biopython/debian/output/source_dir/.pybuild/cpython3_3.12/build/Bio/PDB/binary_cif.py", line 85, in _run_length_decoder
             decoded_data = np.repeat(data[::2].astype(dtype), data[1::2])
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
           File "/usr/lib/python3/dist-packages/numpy/core/fromnumeric.py", line 466, in repeat
             return _wrapfunc(a, 'repeat', repeats, axis=axis)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
           File "/usr/lib/python3/dist-packages/numpy/core/fromnumeric.py", line 68, in _wrapfunc
             return _wrapit(obj, method, *args, **kwds)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
           File "/usr/lib/python3/dist-packages/numpy/core/fromnumeric.py", line 45, in _wrapit
             result = getattr(asarray(obj), method)(*args, **kwds)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         TypeError: Cannot cast array data from dtype('uint32') to dtype('int32') according to the rule 'safe'
Author: Étienne Mollier <emollier@debian.org>
Forwarded: no
Last-Update: 2024-09-16
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- python-biopython.orig/Bio/PDB/binary_cif.py
+++ python-biopython/Bio/PDB/binary_cif.py
@@ -3,6 +3,7 @@
 """
 
 import gzip
+import sys
 from collections import deque
 from typing import Optional
 
@@ -82,7 +83,14 @@
 
     data = column["data"]["data"]
     dtype = _dtypes[encoding["srcType"]]
-    decoded_data = np.repeat(data[::2].astype(dtype), data[1::2])
+    if sys.maxsize == 2**63 - 1:
+        # We're running classical 64-bit platform here.
+        decoded_data = np.repeat(data[::2].astype(dtype), data[1::2])
+    else:
+        # We're assuming 32-bit platform here, numpy croaks on unsafe
+        # type casts.
+        decoded_data = np.repeat(data[::2].astype('int32', casting='unsafe'),
+                                 data[1::2].astype('int32', casting='unsafe'))
 
     assert len(decoded_data) == encoding["srcSize"]
     column["data"]["data"] = decoded_data