#NEWLINE# def test_img_flip( self ) : #NEWLINE# #INDENT# x = np . array ( range ( 4 ) ) . reshape ( [ 1 , 1 , 2 , 2 ] ) #NEWLINE# assert ( flip_axis ( x , 0 ) == x ) . all ( ) #NEWLINE# assert ( flip_axis ( x , 1 ) == x ) . all ( ) #NEWLINE# assert ( flip_axis ( x , 2 ) == [ [ [ [ 2 , 3 ] , [ 0 , 1 ] ] ] ] ) . all ( ) #NEWLINE# assert ( flip_axis ( x , 3 ) == [ [ [ [ 1 , 0 ] , [ 3 , 2 ] ] ] ] ) . all ( ) #NEWLINE# dim_ordering_and_col_index = ( ( 'tf' , 2 ) , ( 'th' , 3 ) ) #NEWLINE# for ( dim_ordering , col_index ) in dim_ordering_and_col_index : #NEWLINE# #INDENT# image_generator_th = ImageDataGenerator ( featurewise_center = False , samplewise_center = False , featurewise_std_normalization = False , samplewise_std_normalization = False , zca_whitening = False , rotation_range = 0 , width_shift_range = 0 , height_shift_range = 0 , shear_range = 0 , zoom_range = 0 , channel_shift_range = 0 , horizontal_flip = True , vertical_flip = False , dim_ordering = dim_ordering ) . flow ( x , [ 1 ] ) #NEWLINE# for i in range ( 10 ) : #NEWLINE# #INDENT# ( potentially_flipped_x , _ ) = next ( image_generator_th ) #NEWLINE# assert ( ( potentially_flipped_x == x ) . all ( ) or ( potentially_flipped_x == flip_axis ( x , col_index ) ) . all ( ) )