def test_indexing_on_class():
 g = Gaussian1D(1, 2, 3, name=u'g')
 p = Polynomial1D(2, name=u'p')
 M = (Gaussian1D + Const1D)
 assert (M[0] is Gaussian1D)
 assert (M[1] is Const1D)
 assert (M[u'Gaussian1D'] is M[0])
 assert (M[u'Const1D'] is M[1])
 M = (Gaussian1D + p)
 assert (M[0] is Gaussian1D)
 assert (M[1] is p)
 assert (M[u'Gaussian1D'] is M[0])
 assert (M[u'p'] is M[1])
 m = (g + p)
 assert isinstance(m[0], Gaussian1D)
 assert isinstance(m[1], Polynomial1D)
 assert isinstance(m[u'g'], Gaussian1D)
 assert isinstance(m[u'p'], Polynomial1D)
 assert isinstance(m[(-1)], Polynomial1D)
 assert isinstance(m[(-2)], Gaussian1D)
 with pytest.raises(IndexError):
  m[42]
 with pytest.raises(IndexError):
  m[u'foobar']

def test_indexing_on_class ( ) : g = Gaussian1D ( 1 , 2 , 3 , name = u'g' ) p = Polynomial1D ( 2 , name = u'p' ) M = ( Gaussian1D + Const1D ) assert ( M [ 0 ] is Gaussian1D ) assert ( M [ 1 ] is Const1D ) assert ( M [ u'Gaussian1D' ] is M [ 0 ] ) assert ( M [ u'Const1D' ] is M [ 1 ] ) M = ( Gaussian1D + p ) assert ( M [ 0 ] is Gaussian1D ) assert ( M [ 1 ] is p ) assert ( M [ u'Gaussian1D' ] is M [ 0 ] ) assert ( M [ u'p' ] is M [ 1 ] ) m = ( g + p ) assert isinstance ( m [ 0 ] , Gaussian1D ) assert isinstance ( m [ 1 ] , Polynomial1D ) assert isinstance ( m [ u'g' ] , Gaussian1D ) assert isinstance ( m [ u'p' ] , Polynomial1D ) assert isinstance ( m [ ( - 1 ) ] , Polynomial1D ) assert isinstance ( m [ ( - 2 ) ] , Gaussian1D ) with pytest . raises ( IndexError ) : m [ 42 ] with pytest . raises ( IndexError ) : m [ u'foobar' ]
test indexing on compound model class objects .