#NEWLINE# @ ignore_warnings #NEWLINE# def test_symmetry( ) : #NEWLINE# #INDENT# random_state = check_random_state ( 0 ) #NEWLINE# y_true = random_state . randint ( 0 , 2 , size = ( 20 , ) ) #NEWLINE# y_pred = random_state . randint ( 0 , 2 , size = ( 20 , ) ) #NEWLINE# assert_equal ( set ( SYMMETRIC_METRICS ) . union ( NOT_SYMMETRIC_METRICS , THRESHOLDED_METRICS , METRIC_UNDEFINED_BINARY_MULTICLASS ) , set ( ALL_METRICS ) ) #NEWLINE# assert_equal ( set ( SYMMETRIC_METRICS ) . intersection ( set ( NOT_SYMMETRIC_METRICS ) ) , set ( [ ] ) ) #NEWLINE# for name in SYMMETRIC_METRICS : #NEWLINE# #INDENT# metric = ALL_METRICS [ name ] #NEWLINE# assert_almost_equal ( metric ( y_true , y_pred ) , metric ( y_pred , y_true ) , err_msg = ( '%s is not symmetric' % name ) ) #NEWLINE# #UNINDENT# for name in NOT_SYMMETRIC_METRICS : #NEWLINE# #INDENT# metric = ALL_METRICS [ name ] #NEWLINE# assert_true ( np . any ( ( metric ( y_true , y_pred ) != metric ( y_pred , y_true ) ) ) , msg = ( '%s seems to be symmetric' % name ) )