#NEWLINE# @ ignore_warnings #NEWLINE# def test_format_invariance_with_1d_vectors( ) : #NEWLINE# #INDENT# random_state = check_random_state ( 0 ) #NEWLINE# y1 = random_state . randint ( 0 , 2 , size = ( 20 , ) ) #NEWLINE# y2 = random_state . randint ( 0 , 2 , size = ( 20 , ) ) #NEWLINE# y1_list = list ( y1 ) #NEWLINE# y2_list = list ( y2 ) #NEWLINE# ( y1_1d , y2_1d ) = ( np . array ( y1 ) , np . array ( y2 ) ) #NEWLINE# assert_equal ( y1_1d . ndim , 1 ) #NEWLINE# assert_equal ( y2_1d . ndim , 1 ) #NEWLINE# y1_column = np . reshape ( y1_1d , ( ( - 1 ) , 1 ) ) #NEWLINE# y2_column = np . reshape ( y2_1d , ( ( - 1 ) , 1 ) ) #NEWLINE# y1_row = np . reshape ( y1_1d , ( 1 , ( - 1 ) ) ) #NEWLINE# y2_row = np . reshape ( y2_1d , ( 1 , ( - 1 ) ) ) #NEWLINE# for ( name , metric ) in ALL_METRICS . items ( ) : #NEWLINE# #INDENT# if ( name in METRIC_UNDEFINED_BINARY_MULTICLASS ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# measure = metric ( y1 , y2 ) #NEWLINE# assert_almost_equal ( metric ( y1_list , y2_list ) , measure , err_msg = ( '%s is not representation invariant with list' % name ) ) #NEWLINE# assert_almost_equal ( metric ( y1_1d , y2_1d ) , measure , err_msg = ( '%s is not representation invariant with np-array-1d' % name ) ) #NEWLINE# assert_almost_equal ( metric ( y1_column , y2_column ) , measure , err_msg = ( '%s is not representation invariant with np-array-column' % name ) ) #NEWLINE# assert_almost_equal ( metric ( y1_1d , y2_list ) , measure , err_msg = ( '%s is not representation invariant with mix np-array-1d and list' % name ) ) #NEWLINE# assert_almost_equal ( metric ( y1_list , y2_1d ) , measure , err_msg = ( '%s is not representation invariant with mix np-array-1d and list' % name ) ) #NEWLINE# assert_almost_equal ( metric ( y1_1d , y2_column ) , measure , err_msg = ( '%s is not representation invariant with mix np-array-1d and np-array-column' % name ) ) #NEWLINE# assert_almost_equal ( metric ( y1_column , y2_1d ) , measure , err_msg = ( '%s is not representation invariant with mix np-array-1d and np-array-column' % name ) ) #NEWLINE# assert_almost_equal ( metric ( y1_list , y2_column ) , measure , err_msg = ( '%s is not representation invariant with mix list and np-array-column' % name ) ) #NEWLINE# assert_almost_equal ( metric ( y1_column , y2_list ) , measure , err_msg = ( '%s is not representation invariant with mix list and np-array-column' % name ) ) #NEWLINE# assert_raises ( ValueError , metric , y1_1d , y2_row ) #NEWLINE# assert_raises ( ValueError , metric , y1_row , y2_1d ) #NEWLINE# assert_raises ( ValueError , metric , y1_list , y2_row ) #NEWLINE# assert_raises ( ValueError , metric , y1_row , y2_list ) #NEWLINE# assert_raises ( ValueError , y1_1d , y1_column , y2_row ) #NEWLINE# assert_raises ( ValueError , metric , y1_row , y2_column ) #NEWLINE# if ( name not in ( ( MULTIOUTPUT_METRICS + THRESHOLDED_MULTILABEL_METRICS ) + MULTILABELS_METRICS ) ) : #NEWLINE# #INDENT# assert_raises ( ValueError , metric , y1_row , y2_row )