Exemple #1
0
 def test_full_output(self):
     p0 = array([[0, 0, 0]])
     full_output = leastsq(self.residuals,
                           p0,
                           args=(self.y_meas, self.x),
                           full_output=True)
     params_fit, cov_x, infodict, mesg, ier = full_output
     assert_(ier in (1, 2, 3, 4), 'solution not found: %s' % mesg)
Exemple #2
0
 def test_basic(self):
     p0 = array([0, 0, 0])
     params_fit, ier = leastsq(self.residuals,
                               p0,
                               args=(self.y_meas, self.x))
     assert_(ier in (1, 2, 3, 4), 'solution not found (ier=%d)' % ier)
     # low precision due to random
     assert_array_almost_equal(params_fit, self.abc, decimal=2)
Exemple #3
0
    def test_reentrant_func(self):
        def func(*args):
            self.test_basic()
            return self.residuals(*args)

        p0 = array([0, 0, 0])
        params_fit, ier = leastsq(func, p0, args=(self.y_meas, self.x))
        assert_(ier in (1, 2, 3, 4), 'solution not found (ier=%d)' % ier)
        # low precision due to random
        assert_array_almost_equal(params_fit, self.abc, decimal=2)
Exemple #4
0
 def test_input_untouched(self):
     p0 = array([0, 0, 0], dtype=float64)
     p0_copy = array(p0, copy=True)
     full_output = leastsq(self.residuals,
                           p0,
                           args=(self.y_meas, self.x),
                           full_output=True)
     params_fit, cov_x, infodict, mesg, ier = full_output
     assert_(ier in (1, 2, 3, 4), 'solution not found: %s' % mesg)
     assert_array_equal(p0, p0_copy)