我刚刚在jupyter上使用cython编写了一个函数:
%load_ext Cython
%%cython
def modelar(lista, int leadtime, int recompra, int qtd, int seg, int dsv, int numero=1):
import math
import pandas as pd
import numpy as np
cdef int data = 0
cdef int n = 0
....
当我尝试以.py脚本下载以便仅使用python运行时,它的转换如下:
get_ipython().run_line_magic('load_ext', 'Cython')
get_ipython().run_cell_magic('cython', '', "def modelar(lista, int leadtime, int recompra, int qtd, int seg, int dsv, int numero=1):\n import math\n import pandas as pd\n import numpy as np\n \n cdef int data = 0\n cdef int n = 0\n cdef float c = 0\n cdef float V = 0\n")
但是,它没有运行。看起来像这样的错误:
AttributeError: 'NoneType' object has no attribute 'magic'