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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
Description: fix runtime failures with Numpy ≥ 2.
This patch fixes the following symptom when running gubbins with Numpy
version 2 and more:
.
Running joint ancestral reconstruction with pyjar
Traceback (most recent call last):
File "/usr/bin/run_gubbins", line 33, in <module>
sys.exit(load_entry_point('gubbins==3.4', 'console_scripts', 'run_gubbins.py')())
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/share/gubbins/gubbins/run_gubbins.py", line 166, in main
gubbins.common.parse_and_run(parser.parse_args(), parser.description)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/share/gubbins/gubbins/common.py", line 373, in parse_and_run
jar(sequence_names = ordered_sequence_names, # complete polymorphism alignment
~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
base_patterns = base_pattern_bases_array, # array of unique base patterns in alignment
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<8 lines>...
verbose = input_args.verbose,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
max_pos = max_pos)
^^^^^^^^^^^^^^^^^^
File "/usr/share/gubbins/gubbins/pyjar.py", line 646, in jar
node_pij = numpy.full((num_nodes,16), numpy.NINF, dtype=numpy.float32)
^^^^^^^^^^
File "/usr/lib/python3/dist-packages/numpy/__init__.py", line 400, in __getattr__
raise AttributeError(
...<3 lines>...
)
AttributeError: `np.NINF` was removed in the NumPy 2.0 release. Use `-np.inf` instead.
Author: Étienne Mollier <emollier@debian.org>
Forwarded: https://github.com/nickjcroucher/gubbins/pull/426
Last-Update: 2025-02-28
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- gubbins.orig/python/gubbins/pyjar.py
+++ gubbins/python/gubbins/pyjar.py
@@ -64,7 +64,7 @@
#Calculate Pij from Q matrix and branch length
def calculate_pij(branch_length,rate_matrix):
if branch_length==0:
- pij = numpy.full((4,4), numpy.NINF, dtype = numpy.float32)
+ pij = numpy.full((4,4), -numpy.inf, dtype = numpy.float32)
numpy.fill_diagonal(pij, 0.0)
else:
pij = numpy.array(numpy.log(linalg.expm(numpy.multiply(branch_length,rate_matrix))), dtype = numpy.float32) # modified
@@ -328,7 +328,7 @@
Cmat_null = numpy.array([0,1,2,3], dtype = numpy.uint8)
# Reset matrices
- Lmat.fill(numpy.NINF)
+ Lmat.fill(-numpy.inf)
Cmat[:] = Cmat_null
# Count unknown bases
@@ -537,7 +537,7 @@
# Generate data structures for reconstructions
num_nodes = len(tree.nodes())
- Lmat = numpy.full((num_nodes,4), numpy.NINF, dtype = numpy.float32)
+ Lmat = numpy.full((num_nodes,4), -numpy.inf, dtype = numpy.float32)
Cmat = numpy.full((num_nodes,4), [0,1,2,3], dtype = numpy.uint8)
reconstructed_base_indices = numpy.full(num_nodes, 8, dtype = numpy.uint8)
@@ -643,7 +643,7 @@
child_nodes_array = numpy.empty(num_nodes, dtype=object)
leaf_node_list = []
node_labels = numpy.empty(num_nodes, dtype=object)
- node_pij = numpy.full((num_nodes,16), numpy.NINF, dtype=numpy.float32)
+ node_pij = numpy.full((num_nodes,16), -numpy.inf, dtype=numpy.float32)
postordered_nodes = numpy.arange(num_nodes, dtype=numpy.int32)
seed_node = None
seed_node_edge_truncation = True
|