#NEWLINE# def test_cochransq( ) : #NEWLINE# #INDENT# x = np . array ( [ [ 1 , 1 , 1 ] , [ 1 , 1 , 1 ] , [ 0 , 1 , 0 ] , [ 1 , 1 , 0 ] , [ 0 , 0 , 0 ] , [ 1 , 1 , 1 ] , [ 1 , 1 , 1 ] , [ 1 , 1 , 0 ] , [ 0 , 0 , 1 ] , [ 0 , 1 , 0 ] , [ 1 , 1 , 1 ] , [ 1 , 1 , 1 ] ] ) #NEWLINE# res_qstat = 2.8 #NEWLINE# res_pvalue = 0.246597 #NEWLINE# assert_almost_equal ( cochrans_q ( x ) , [ res_qstat , res_pvalue ] ) #NEWLINE# ( a , b ) = x [ : , : 2 ] . T #NEWLINE# assert_almost_equal ( mcnemar ( res_qstat , b , exact = False , correction = False ) , cochrans_q ( x [ : , : 2 ] ) )