我收到标题中所述的错误。完全错误:
MaxD = Cone*np.sqrt(SymsX/np.pi)*np.exp((-SymsX/(k*T))) #Define Maxwellian distribution function
AttributeError: 'Mul' object has no attribute 'sqrt'
代码如下:
^{2}$我还有另外一个问题。我有时看到例子用“from。。。导入。为什么会这样?仅仅导入整个库就够了吗?是不是因为使用import命令实际上并没有导入整个库,而只导入最基本的函数?在
在
isympy
会话中:
^{pr2}$np.sqrt
必须首先将其输入转换为numpy数组:这是一个对象数据类型数组,不是普通的数值数组。给定这样的数组,qnumpy
ufunc
尝试将操作委托给element方法。e、 g.(0.31*SymsX).sqrt()
乘法和加法可用于此对象数组:
因为
sympy
对象具有正确的加法和乘法方法:===
sympy.lambdify
是同时使用sympy
和{在这种情况下,
SymsX/pi
表达式可以转换为numpy表达式,其中:===
sympy
中的相同评估:在新的
isympy
会话中:结果是:
^{pr2}$SymsX
仍然是一个符号,因此这些是sympy
表达式,而不是数字。在相关问题 更多 >
编程相关推荐