简体   繁体   English

使用 numba 重载时 Python 内核死掉

[英]Python kernel dies when using numba overload

I am attempting to use an externally defined function inside of a numba jitted function, through use of numba's overload (docs here) but the Python kernel dies when I run it.我试图通过使用 numba 的重载(此处的文档)在 numba jitted 函数中使用外部定义的函数,但是当我运行它时 Python 内核死了。 Here is my minimal example to reproduce:这是我重现的最小示例:

from numpy.polynomial.legendre import leggauss as lg  # My externally defined function
import numba as nb
from numba.extending import overload

@overload(lg)
def implimentlg(n):
   if not isinstance(n, (int, nb.types.Integer, nb.int32)):
      raise nb.errors.TypingError("must be int")

   def impli(n):
      return lg(n)
   return impli

@nb.jit(nopython=True)
def tmp():
   return lg(15)

tmp()

I would guess my problem has something to do with the typing in my implimentlg function, but without a stack trace I am at a loss.我猜我的问题与我的implimentlg函数中的输入有关,但是没有堆栈跟踪我就不知所措了。

The problem was that I was running my python code in a iPython terminal using the neovim package "nvim-ipy".问题是我使用neovim包“nvim-ipy”在iPython终端中运行我的python代码。 Running my code directly instead with python3 myFile.py gave a stack trace.直接使用python3 myFile.py运行我的代码给出了堆栈跟踪。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM