语法错误:Python、Cyrthon 中 math.sqrt 中的语法无效

问题描述 投票:0回答:0

我试过这个 成功加载 cython 但我无法使用 cimport

%%cython

from libc.math cimport sqrt
import numpy as np

def filt_conv3(double complex[:,:] filterInput, Py_ssize_t sample_per_symbol, double[:] h, int flag, Py_ssize_t num_of_taps):
    cdef Py_ssize_t input_batch_size = filterInput.shape[0]
    cdef Py_ssize_t input_length = filterInput.shape[1]

    cdef Py_ssize_t num_of_output = num_of_taps + (input_length-1) * sample_per_symbol  
    cdef double complex[:,:] output = np.zeros((input_batch_size, num_of_output), dtype=np.complex)  
    cdef double complex[:,:] FiltSig = np.zeros((input_batch_size, num_of_output), dtype=np.complex)  

    

但它返回给我以下错误:

Cell In[12], line 4
    from libc.math cimport sqrt
                   ^
SyntaxError: invalid syntax

这个语法错误的原因是什么? 我该怎么办?

python math import sqrt cimport
© www.soinside.com 2019 - 2024. All rights reserved.