def test_slicing_on_instance_with_parameterless_model():
 p2 = Polynomial2D(1, c0_0=1, c1_0=2, c0_1=3)
 p1 = Polynomial2D(1, c0_0=1, c1_0=2, c0_1=3)
 mapping = Mapping((0, 1, 0, 1))
 offx = Shift((-2), name=u'x_translation')
 offy = Shift((-1), name=u'y_translation')
 aff = AffineTransformation2D(matrix=[[1, 2], [3, 4]], name=u'rotation')
 model = (((mapping | (p1 & p2)) | (offx & offy)) | aff)
 assert (model.param_names == (u'c0_0_1', u'c1_0_1', u'c0_1_1', u'c0_0_2', u'c1_0_2', u'c0_1_2', u'offset_3', u'offset_4', u'matrix_5', u'translation_5'))
 assert (model(1, 2) == (23.0, 53.0))
 m = model[3:]
 assert (m.param_names == (u'offset_3', u'offset_4', u'matrix_5', u'translation_5'))
 assert (m(1, 2) == (1.0, 1.0))

def test_slicing_on_instance_with_parameterless_model ( ) : p2 = Polynomial2D ( 1 , c0_0 = 1 , c1_0 = 2 , c0_1 = 3 ) p1 = Polynomial2D ( 1 , c0_0 = 1 , c1_0 = 2 , c0_1 = 3 ) mapping = Mapping ( ( 0 , 1 , 0 , 1 ) ) offx = Shift ( ( - 2 ) , name = u'x_translation' ) offy = Shift ( ( - 1 ) , name = u'y_translation' ) aff = AffineTransformation2D ( matrix = [ [ 1 , 2 ] , [ 3 , 4 ] ] , name = u'rotation' ) model = ( ( ( mapping | ( p1 & p2 ) ) | ( offx & offy ) ) | aff ) assert ( model . param_names == ( u'c0_0_1' , u'c1_0_1' , u'c0_1_1' , u'c0_0_2' , u'c1_0_2' , u'c0_1_2' , u'offset_3' , u'offset_4' , u'matrix_5' , u'translation_5' ) ) assert ( model ( 1 , 2 ) == ( 23.0 , 53.0 ) ) m = model [ 3 : ] assert ( m . param_names == ( u'offset_3' , u'offset_4' , u'matrix_5' , u'translation_5' ) ) assert ( m ( 1 , 2 ) == ( 1.0 , 1.0 ) )
regression test to fix an issue where the indices attached to parameter names on a compound model were not handled properly when one or more submodels have no parameters .