Skip to content

Maximal number of iterations allowed for finding a smoothing spline has been reached #646

@HealthyPear

Description

@HealthyPear

Sometimes during gta.optimize() I get this warning,

The maximal number of iterations maxit (set to 20 by the program)
allowed for finding a smoothing spline with fp=s has been reached: s
too small.
There is an approximation returned but the corresponding weighted sum
of squared residuals does not satisfy the condition abs(fp-s)/s < tol.
  spline = UnivariateSpline(x, y, k=2,

which seems to be triggered within utils.get_parameter_limits().

I noticed that even in the tutorials this warning seems to pop up, but nothing is explained regarding it.

Is this something the user should worry about? If yes, is there a recommended way to approach the issue e.g. using the available keyword arguments of gta.optimize()?

Slightly unrelated, but still, unexpected behavior: while debugging this I noticed that the optimizer section of my config is not respected by this method when I override one key, as I have

gta.config["optimizer"] = {'optimizer': 'MINUIT',
 'tol': 0.001,
 'max_iter': 100,
 'init_lambda': 0.0001,
 'retries': 3,
 'min_fit_quality': 2,
 'verbosity': 0}

but the output of gta.optimize(optimizer={"verbosity":3}) shows

Minuit fit quality: 3

I would expect that only verbosity should have been overridden.

I get the same behavior even passing the full dict,

optimizer_dict = {**gta.config["optimizer"], "verbosity": 1}
print(optimizer_dict)
gta.optimize(optimizer=optimizer_dict)

gives

2025-11-25 10:37:39 INFO    GTAnalysis.optimize(): Starting
{'optimizer': 'MINUIT', 'tol': 0.001, 'max_iter': 100, 'init_lambda': 0.0001, 'retries': 3, 'min_fit_quality': 2, 'verbosity': 1}

[...]

Minuit fit quality: 3   estimated distance: 2.25552e-07
Minuit parameter uncertainties:
  1  0.0239165
  2  0.0166402
  3  0.0985877
  4  0.00766259
  5  0.00911272
[...]/lib/python3.11/site-packages/fermipy/utils.py:785: UserWarning: 
The maximal number of iterations maxit (set to 20 by the program)
allowed for finding a smoothing spline with fp=s has been reached: s
too small.
There is an approximation returned but the corresponding weighted sum
of squared residuals does not satisfy the condition abs(fp-s)/s < tol.
  spline = UnivariateSpline(x, y, k=2,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions