def test_custom_model_parametrized_decorator():
 def cosine(x, amplitude=1):
  return [(amplitude * np.cos(x))]
 @custom_model(fit_deriv=cosine)
 def sine(x, amplitude=1):
  return (amplitude * np.sin(x))
 assert issubclass(sine, Model)
 s = sine(2)
 assert_allclose(s((np.pi / 2)), 2)
 assert_allclose(s.fit_deriv(0, 2), 2)

def test_custom_model_parametrized_decorator ( ) : def cosine ( x , amplitude = 1 ) : return [ ( amplitude * np . cos ( x ) ) ] @ custom_model ( fit_deriv = cosine ) def sine ( x , amplitude = 1 ) : return ( amplitude * np . sin ( x ) ) assert issubclass ( sine , Model ) s = sine ( 2 ) assert_allclose ( s ( ( np . pi / 2 ) ) , 2 ) assert_allclose ( s . fit_deriv ( 0 , 2 ) , 2 )
tests using custom_model as a decorator with parameters .