#NEWLINE# def _fit_first( self , first ) : #NEWLINE# #INDENT# schema = Schema ( ( int , float , str , NumberSequenceValidator ( ) , BagValidator ( ) ) ) #NEWLINE# schema . validate ( first ) #NEWLINE# if ( not first ) : #NEWLINE# #INDENT# raise ValueError ( 'Cannot fit with no empty features' ) #NEWLINE# #UNINDENT# self . indexes = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# self . reverse = [ ] #NEWLINE# self . schema = ( [ None ] * len ( first ) ) #NEWLINE# self . str_tuple_indexes = [ ] #NEWLINE# self . bag_indexes = [ ] #NEWLINE# for ( i , data ) in enumerate ( first ) : #NEWLINE# #INDENT# if isinstance ( data , ( int , float ) ) : #NEWLINE# #INDENT# type_ = Use ( float ) #NEWLINE# self . _add_column ( i , None ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( data , str ) : #NEWLINE# #INDENT# type_ = str #NEWLINE# self . str_tuple_indexes . append ( i ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( i ) != 0 ) : #NEWLINE# #INDENT# elem = list ( data ) [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# elem = None #NEWLINE# #UNINDENT# if ( type ( elem ) in ( int , float ) ) : #NEWLINE# #INDENT# type_ = NumberSequenceValidator ( data ) #NEWLINE# for j in range ( type_ . size ) : #NEWLINE# #INDENT# self . _add_column ( i , j ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# type_ = BagValidator ( data ) #NEWLINE# self . bag_indexes . append ( i ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . schema [ i ] = type_ #NEWLINE# #UNINDENT# assert ( None not in self . schema ) #NEWLINE# self . schema = tuple ( self . schema ) #NEWLINE# self . validator = TupleValidator ( self . schema )