小编WZh*_*hao的帖子

将 numba 的 dict 类型替换为 python 函数的参数

在我的代码中,有很多参数在运行过程中是不变的。我定义了一个dict类型变量来存储它们。但我发现numba不能支持dict.

有什么更好的方法来解决这个问题?

python numba

7
推荐指数
1
解决办法
1956
查看次数

为什么numba在numpy linspace中引发类型错误

我正在使用numba0.34.0和numpy1.13.1。一个小例子如下所示:

import numpy as np    
from numba import jit
@jit(nopython=True)
def initial(veh_size):
    t = np.linspace(0, (100 - 1) * 30, 100, dtype=np.int32)
    t0 = np.linspace(0, (veh_size - 1) * 30, veh_size, dtype=np.int32)
    return t0

initial(100)
Run Code Online (Sandbox Code Playgroud)

t和的行都具有t0相同的错误消息。

错误信息:

numba.errors.InternalError: 
[1] During: resolving callee type: Function(<function linspace at 0x000001F977678C80>)
[2] During: typing of call at ***/test1.py (6)
Run Code Online (Sandbox Code Playgroud)

python numpy numba

1
推荐指数
1
解决办法
531
查看次数

Cython 在 Windows 中使用 mingw64 编译错误“无法将类型 'double' 分配给 'int'”,但在 linux 中正常

我在安装traj-dist 使用Cython. 在Linux下使用gcc编译后可以安装,但在winodws下使用mingw64 gcc编译后无法安装。

我使用Python 3.8,Cython 0.29.21。

python setup.py build_ext --inplace --force

完整的输出错误消息在这里

Error compiling Cython file:
------------------------------------------------------------
...
    q=len(Q)

    cc=_compute_critical_values(P,Q,p,q)
    eps=cc[0]
    while(len(cc)!=1):
        m_i=len(cc)/2-1
                    ^
------------------------------------------------------------

traj_dist\cydist\frechet.pyx:535:21: Cannot assign type 'double' to 'int'
Run Code Online (Sandbox Code Playgroud)

有编译错误的文件是https://github.com/bguillouet/traj-dist/blob/master/traj_dist/cydist/frechet.pyx

我怎样才能在windows下编译它?

python cython

1
推荐指数
1
解决办法
4539
查看次数

标签 统计

python ×3

numba ×2

cython ×1

numpy ×1