簡體   English   中英

np.arange object 不可調用

[英]np.arange object is not callable

您好,我正在嘗試創建一個 Lorentz function,它采用名為“freq”的數組輸入,配置文件的中心為“freq0”,function 的偏差為“gamma”,(比例參數半寬度半最大值)。

我創建了 function 如下

def LorentzProfileFreq(freq, freq0, gamma):
    '''
Return a Lorentz profile on a given frequency grid

Parameters
----------
    freq:  array_like
           Frequency grid
    freq0: float
           Center of the profile
    gamma: float
           Scale parameter gamma (hald-width at half-maximum)

Returns
-------
    LorentzProfileFreq: ndarray
                        Lorentz profile
    '''

    Lorentz=1/np.pi*((gamma/2)/((freq-freq0)**2+(gamma/2)**2))
    return Lorentz(freq,freq0,gamma)

並測試我所做的 function:

def test_LorentzProfileFreq():
    x=np.arange(-5,5,0.1)
    y=LorentzProfileFreq(np.arange(-5,5,0.1),0,1)
    plt.plot(x,y)
    plt.show()

這給我錯誤TypeError: 'numpy.ndarray' object is not callable'我不明白為什么 np.arange 不可調用?

return Lorentz

Lorentz不是 function。這就是numpy抱怨的原因。 Lorentz是一個 numpy 數組)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM