nlsq.callbacks.ProgressBar

class nlsq.callbacks.ProgressBar(max_nfev=None, desc='Optimizing', **tqdm_kwargs)[source]

Bases: CallbackBase

Progress bar callback using tqdm.

Displays a progress bar showing optimization progress with current cost, gradient norm, and iteration statistics.

Parameters:
  • max_nfev (int, optional) – Maximum number of function evaluations. If provided, progress bar will be based on nfev. Otherwise, shows indefinite progress.

  • desc (str, optional) – Description to display in progress bar. Default: “Optimizing”

  • **tqdm_kwargs – Additional keyword arguments passed to tqdm

Examples

>>> from nlsq import curve_fit
>>> from nlsq.callbacks import ProgressBar
>>> callback = ProgressBar(max_nfev=100)
>>> popt, pcov = curve_fit(f, x, y, callback=callback)
__init__(max_nfev=None, desc='Optimizing', **tqdm_kwargs)[source]
__call__(iteration, cost, params, info)[source]

Update progress bar.

close()[source]

Close progress bar.

__del__()[source]

Ensure progress bar is closed on deletion.