@pytest.mark.skipif(u'not HAS_SCIPY')
def test_fit_with_bound_constraints_estimate_jacobian():
 class MyModel(Fittable1DModel, ):
  a = Parameter(default=1)
  b = Parameter(default=2)
  @staticmethod
  def evaluate(x, a, b):
   return ((a * x) + b)
 m_real = MyModel(a=1.5, b=(-3))
 x = np.arange(100)
 y = m_real(x)
 m = MyModel()
 f = fitting.LevMarLSQFitter()
 fitted_1 = f(m, x, y)
 assert np.allclose(fitted_1.a, 1.5)
 assert np.allclose(fitted_1.b, (-3))
 m2 = MyModel()
 m2.a.bounds = ((-2), 2)
 f2 = fitting.LevMarLSQFitter()
 fitted_2 = f2(m2, x, y)
 assert np.allclose(fitted_1.a, 1.5)
 assert np.allclose(fitted_1.b, (-3))
 assert np.any((f2.fit_info[u'fjac'] != 0))

@ pytest . mark . skipif ( u'not HAS_SCIPY' ) def test_fit_with_bound_constraints_estimate_jacobian ( ) : class MyModel ( Fittable1DModel , ) : a = Parameter ( default = 1 ) b = Parameter ( default = 2 ) @ staticmethod def evaluate ( x , a , b ) : return ( ( a * x ) + b ) m_real = MyModel ( a = 1.5 , b = ( - 3 ) ) x = np . arange ( 100 ) y = m_real ( x ) m = MyModel ( ) f = fitting . LevMarLSQFitter ( ) fitted_1 = f ( m , x , y ) assert np . allclose ( fitted_1 . a , 1.5 ) assert np . allclose ( fitted_1 . b , ( - 3 ) ) m2 = MyModel ( ) m2 . a . bounds = ( ( - 2 ) , 2 ) f2 = fitting . LevMarLSQFitter ( ) fitted_2 = f2 ( m2 , x , y ) assert np . allclose ( fitted_1 . a , 1.5 ) assert np . allclose ( fitted_1 . b , ( - 3 ) ) assert np . any ( ( f2 . fit_info [ u'fjac' ] != 0 ) )
regression test for URL checks that bounds constraints are obeyed on a custom model that does not define fit_deriv .