Skip to content

Fixing a model parameter can violate bounds restrictions on another #2235

Description

@ChrisBeaumont

Notice that the boundary constraints on mean are violated here

from astropy import __version__
from astropy.modeling import models, fitting
import numpy as np

print __version__

m = models.Gaussian1D(amplitude=3, mean=4, stddev=1, 
                      bounds={'mean': [4, 5]}, 
                      fixed={'amplitude': True})
x = np.linspace(0, 10, 10)
y = np.exp(-x ** 2 / 2)

f = fitting.NonLinearLSQFitter()
print f(m, x, y)
0.4.dev6909
Model: Gaussian1D
n_inputs:   1
Degree: N/A
Parameter sets: 1
Parameters: 
           amplitude: Parameter('amplitude', value=3.0)
           mean: Parameter('mean', value=3.8251208412576392)
           stddev: Parameter('stddev', value=0.1348079843293544)

This goes away if the fixed constraint on amplitude is removed

m.amplitude.fixed = False
print f(m, x, y)
Model: Gaussian1D
n_inputs:   1
Degree: N/A
Parameter sets: 1
Parameters: 
           amplitude: Parameter('amplitude', value=3.0)
           mean: Parameter('mean', value=4.0)
           stddev: Parameter('stddev', value=1.0)

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions