Dendropy interop和numpy数组

2024-06-26 10:56:22 发布

您现在位置:Python中文网/ 问答频道 /正文

我目前正在尝试使用python Dendropy库,并在代码中包含一些PAUP命令。你知道吗

我将矩阵作为numpy数组,但是看起来numpy数组和这个模块有问题。你知道吗

***Distance matrix A (Numpy array)***

[[ 0  2  7  8 16 17]
 [ 2  0  5  6 17 16]
 [ 7  5  0  9 15 13]
 [ 8  6  9  0 18 16]
 [16 17 15 18  0  5]
 [17 16 13 16  5  0]]

我尝试使用:A=numpy.matrix(A)将numpy数组转换为numpy矩阵

import dendropy
from dendropy.interop import paup     

#A is a distance matrix like this    

tree = paup.estimate_tree(A, 'nj')

我得到的错误是:AttributeError: 'matrix' object has no attribute 'write_to_stream'

或:

AttributeError: 'numpy.ndarray' object has no attribute 'write_to_stream'

任何帮助都将不胜感激。你知道吗


Tags: tonoimportnumpytreeobjectattribute矩阵