Home > Blockchain >  np.arange object is not callable
np.arange object is not callable

Time:05-07

Hi I'm trying to create a Lorentz function that takes an array input called "freq", the center of the profile as "freq0" and the deviation of the function as "gamma", (scale parameter half width at half maximum).

I've created the function as following

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)

And testing the function I did:

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()

Which gives me the error TypeError: 'numpy.ndarray' object is not callable' I don't understand why np.arange is not callable?

CodePudding user response:

return Lorentz

Lorentz is not a function. That's why numpy complained. (Lorentz is a numpy array)

  • Related