Skip to content

Instantly share code, notes, and snippets.

@majkelx
Created December 25, 2017 13:53
Show Gist options
  • Select an option

  • Save majkelx/0f105055554ce5061264f18be44b5171 to your computer and use it in GitHub Desktop.

Select an option

Save majkelx/0f105055554ce5061264f18be44b5171 to your computer and use it in GitHub Desktop.
import numpy as np
from numpy.testing.utils import assert_allclose
from astropy.modeling.fitting import LevMarLSQFitter, LinearLSQFitter
from astropy.modeling import models
def test_fitters_with_weights():
""" Fails due issue #7035"""
Xin, Yin = np.mgrid[0:21, 0:21]
# fitter = LevMarLSQFitter()
fitter = LinearLSQFitter()
zsig = np.random.normal(0, 0.01, size=Xin.shape)
p2 = models.Polynomial2D(3)
p2.parameters = np.arange(10)/1.2
z = p2(Xin, Yin)
pmod = fitter(models.Polynomial2D(3), Xin, Yin, z + zsig, weights=zsig**(-2))
assert_allclose(pmod.parameters, p2.parameters, atol=10 ** (-2))
test_fitters_with_weights()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment