#NEWLINE# def test02_AppendRows( self ) : #NEWLINE# #INDENT# 'Checking whether appending record rows works or not.' #NEWLINE# self . h5file = tables . open_file ( self . h5fname , mode = 'a' ) #NEWLINE# self . rootgroup = self . h5file . root #NEWLINE# if common . verbose : #NEWLINE# #INDENT# print ( '\n' , ( '-=' * 30 ) ) #NEWLINE# print ( ( 'Running %s.test02_AppendRows...' % self . __class__ . __name__ ) ) #NEWLINE# #UNINDENT# table = self . h5file . get_node ( '/group0/table1' ) #NEWLINE# row = table . row #NEWLINE# if common . verbose : #NEWLINE# #INDENT# print ( 'Nrows in old' , table . _v_pathname , ':' , table . nrows ) #NEWLINE# print ( 'Record Format ==>' , table . description . _v_nested_formats ) #NEWLINE# print ( 'Record Size ==>' , table . rowsize ) #NEWLINE# #UNINDENT# for i in range ( self . appendrows ) : #NEWLINE# #INDENT# s = ( '%04d' % ( self . appendrows - i ) ) #NEWLINE# row [ 'var0' ] = s . encode ( 'ascii' ) #NEWLINE# row [ 'var1' ] = s . encode ( 'ascii' ) #NEWLINE# row [ 'var7' ] = s [ ( - 1 ) ] . encode ( 'ascii' ) #NEWLINE# row [ 'var1_' ] = ( i , 1 ) #NEWLINE# row [ 'var2' ] = ( ( i , 1 ) , ( 1 , 1 ) ) #NEWLINE# row [ 'var3' ] = ( i % self . maxshort ) #NEWLINE# if isinstance ( row [ 'var4' ] , np . ndarray ) : #NEWLINE# #INDENT# row [ 'var4' ] = [ float ( i ) , float ( ( i * i ) ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# row [ 'var4' ] = float ( i ) #NEWLINE# #UNINDENT# if isinstance ( row [ 'var5' ] , np . ndarray ) : #NEWLINE# #INDENT# row [ 'var5' ] = np . array ( ( ( float ( i ) , ) * 4 ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# row [ 'var5' ] = float ( i ) #NEWLINE# #UNINDENT# row . append ( ) #NEWLINE# #UNINDENT# table . flush ( ) #NEWLINE# result = [ r [ 'var2' ] [ 0 ] [ 0 ] for r in table . iterrows ( ) if ( r [ 'var2' ] [ 0 ] [ 0 ] < 20 ) ] #NEWLINE# row = [ r for r in table . iterrows ( ) if ( r [ 'var2' ] [ 0 ] [ 0 ] < 20 ) ] [ ( - 1 ) ] #NEWLINE# nrows = ( self . appendrows - 1 ) #NEWLINE# self . assertEqual ( ( row [ 'var0' ] [ 0 ] , row [ 'var1' ] [ 0 ] [ 0 ] , row [ 'var1_' ] [ 0 ] , row [ 'var2' ] [ 0 ] [ 0 ] , row [ 'var7' ] ) , ( b'0001' , b'0001' , nrows , nrows , b'1' ) ) #NEWLINE# if isinstance ( row [ 'var5' ] , np . ndarray ) : #NEWLINE# #INDENT# self . assertTrue ( allequal ( row [ 'var5' ] , np . array ( ( ( float ( nrows ) , ) * 4 ) , np . float32 ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . assertEqual ( row [ 'var5' ] , float ( nrows ) ) #NEWLINE# #UNINDENT# if ( self . appendrows <= 20 ) : #NEWLINE# #INDENT# add = self . appendrows #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# add = 20 #NEWLINE# #UNINDENT# self . assertEqual ( len ( result ) , ( 20 + add ) )