def test_compound_custom_inverse():
 poly = Polynomial1D(1, c0=1, c1=2)
 scale = Scale(1)
 shift = Shift(1)
 model1 = (poly | scale)
 model1.inverse = poly
 model2 = (shift | model1)
 assert_allclose(model2.inverse(1), (poly | shift.inverse)(1))
 with pytest.raises(NotImplementedError):
  (shift + model1).inverse
 with pytest.raises(NotImplementedError):
  (model1 & poly).inverse

def test_compound_custom_inverse ( ) : poly = Polynomial1D ( 1 , c0 = 1 , c1 = 2 ) scale = Scale ( 1 ) shift = Shift ( 1 ) model1 = ( poly | scale ) model1 . inverse = poly model2 = ( shift | model1 ) assert_allclose ( model2 . inverse ( 1 ) , ( poly | shift . inverse ) ( 1 ) ) with pytest . raises ( NotImplementedError ) : ( shift + model1 ) . inverse with pytest . raises ( NotImplementedError ) : ( model1 & poly ) . inverse
test that a compound model with a custom inverse has that inverse applied when the inverse of another model .