Numpy数组获取对象而不是值

2024-05-13 21:36:30 发布

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

我使用Python3.6和numpy库的最新版本,当我调用一个函数时:

    def matriz_jacobiana_reducida(self, a, b, c):
    return np.array([
        [-c * np.sin(a) * np.cos(b) - c * np.cos(a) * np.sin(b) - self.a1 * np.sin(a),
         -c * np.cos(a) * np.sin(b) - c * np.sin(a) * np.cos(b),
         np.cos(a) * np.cos(b) - np.sin(a) * np.sin(b)],
        [-c * np.cos(a) * np.cos(b) - c * np.sin(a) * np.sin(b) + self.a1 * np.cos(a),
         -c * np.sin(a) * np.sin(b) + c * np.cos(a) * np.cos(b),
         np.sin(a) * np.cos(b) + np.cos(a) * np.sin(b)],
        [1, 1, 0]
    ])

在循环的第三次迭代中,我开始得到一些奇怪的东西,而不是numpy矩阵中的值:

[[array([1.85417763]) array([-0.14528501]) array([0.99970679])][array([6.04488775]) array([5.99824076]) array([0.02421417])][1 1 0]]

我试图将值复制到另一个数组中,但没有起作用,当我调用此数组时,开始出现错误:

TypeError: No loop matching the specified signature and casting was found for ufunc det

这个[array(value)]格式numpy设置的原因是什么

谢谢


Tags: 函数self版本numpyreturndefa1np