Search code examples
pythonprintinglmfit

how do I suppress the print of "Adding parameter" in lmfit


How do I suppress the printing of "Adding parameter" in the following code

In [7]: from numpy import sqrt, pi, exp, linspace 
In [8]: import numpy as np    
In [9]: def gaussian(x, amp, cen, wid):
   ...:        return amp * exp(-(x-cen)**2 /wid)
   ...: x = linspace(-10,10)
   ...: y = gaussian(x, 2.33, 0.21, 1.51) + np.random.normal(0, 0.2, len(x))
   ...: 

In [10]: from lmfit import Model
In [11]: gmod = Model(gaussian)
In [12]: result = gmod.fit(y, x=x, amp=5, cen=5, wid=1)#<-- here!!
 - Adding parameter "amp"
 - Adding parameter "cen"
 - Adding parameter "wid"

Thanks.


Solution

  • In order to suppress this output one needs to add verbose=False

    fit(..., verbose=False)