#NEWLINE# @ for_each_factor_dtype #NEWLINE# def test_rank_ascending( self , name , factor_dtype ) : #NEWLINE# #INDENT# f = F ( dtype = factor_dtype ) #NEWLINE# data = array ( [ [ 0 , 1 , 2 , 3 , 0 ] , [ 1 , 2 , 3 , 0 , 1 ] , [ 2 , 3 , 0 , 1 , 2 ] , [ 3 , 0 , 1 , 2 , 3 ] , [ 0 , 1 , 2 , 3 , 0 ] ] , dtype = factor_dtype ) #NEWLINE# expected_ranks = { #NEWLINE# #INDENT# 'ordinal' : array ( [ [ 1.0 , 3.0 , 4.0 , 5.0 , 2.0 ] , [ 2.0 , 4.0 , 5.0 , 1.0 , 3.0 ] , [ 3.0 , 5.0 , 1.0 , 2.0 , 4.0 ] , [ 4.0 , 1.0 , 2.0 , 3.0 , 5.0 ] , [ 1.0 , 3.0 , 4.0 , 5.0 , 2.0 ] ] ) , #NEWLINE# 'average' : array ( [ [ 1.5 , 3.0 , 4.0 , 5.0 , 1.5 ] , [ 2.5 , 4.0 , 5.0 , 1.0 , 2.5 ] , [ 3.5 , 5.0 , 1.0 , 2.0 , 3.5 ] , [ 4.5 , 1.0 , 2.0 , 3.0 , 4.5 ] , [ 1.5 , 3.0 , 4.0 , 5.0 , 1.5 ] ] ) , #NEWLINE# 'min' : array ( [ [ 1.0 , 3.0 , 4.0 , 5.0 , 1.0 ] , [ 2.0 , 4.0 , 5.0 , 1.0 , 2.0 ] , [ 3.0 , 5.0 , 1.0 , 2.0 , 3.0 ] , [ 4.0 , 1.0 , 2.0 , 3.0 , 4.0 ] , [ 1.0 , 3.0 , 4.0 , 5.0 , 1.0 ] ] ) , #NEWLINE# 'max' : array ( [ [ 2.0 , 3.0 , 4.0 , 5.0 , 2.0 ] , [ 3.0 , 4.0 , 5.0 , 1.0 , 3.0 ] , [ 4.0 , 5.0 , 1.0 , 2.0 , 4.0 ] , [ 5.0 , 1.0 , 2.0 , 3.0 , 5.0 ] , [ 2.0 , 3.0 , 4.0 , 5.0 , 2.0 ] ] ) , #NEWLINE# 'dense' : array ( [ [ 1.0 , 2.0 , 3.0 , 4.0 , 1.0 ] , [ 2.0 , 3.0 , 4.0 , 1.0 , 2.0 ] , [ 3.0 , 4.0 , 1.0 , 2.0 , 3.0 ] , [ 4.0 , 1.0 , 2.0 , 3.0 , 4.0 ] , [ 1.0 , 2.0 , 3.0 , 4.0 , 1.0 ] ] ) , #NEWLINE# #UNINDENT# } #NEWLINE# def check( terms ) : #NEWLINE# #INDENT# graph = TermGraph ( terms ) #NEWLINE# results = self . run_graph ( graph , initial_workspace = { #NEWLINE# #INDENT# f : data , #NEWLINE# #UNINDENT# } , mask = self . build_mask ( ones ( ( 5 , 5 ) ) ) ) #NEWLINE# for method in terms : #NEWLINE# #INDENT# check_arrays ( results [ method ] , expected_ranks [ method ] ) #NEWLINE# #UNINDENT# #UNINDENT# check ( { meth : f . rank ( method = meth ) for meth in expected_ranks } ) #NEWLINE# check ( { meth : f . rank ( method = meth , ascending = True ) for meth in expected_ranks } ) #NEWLINE# check ( { #NEWLINE# #INDENT# 'ordinal' : f . rank ( ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# check ( { #NEWLINE# #INDENT# 'ordinal' : f . rank ( ascending = True ) , #NEWLINE# #UNINDENT# } )