#NEWLINE# @ for_each_factor_dtype #NEWLINE# def test_rank_after_mask( 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# mask_data = ( ~ eye ( 5 , dtype = bool ) ) #NEWLINE# initial_workspace = { #NEWLINE# #INDENT# f : data , #NEWLINE# Mask ( ) : mask_data , #NEWLINE# #UNINDENT# } #NEWLINE# graph = TermGraph ( { #NEWLINE# #INDENT# 'ascending_nomask' : f . rank ( ascending = True ) , #NEWLINE# 'ascending_mask' : f . rank ( ascending = True , mask = Mask ( ) ) , #NEWLINE# 'descending_nomask' : f . rank ( ascending = False ) , #NEWLINE# 'descending_mask' : f . rank ( ascending = False , mask = Mask ( ) ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# expected = { #NEWLINE# #INDENT# 'ascending_nomask' : 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# 'descending_nomask' : array ( [ [ 4.0 , 3.0 , 2.0 , 1.0 , 5.0 ] , [ 3.0 , 2.0 , 1.0 , 5.0 , 4.0 ] , [ 2.0 , 1.0 , 5.0 , 4.0 , 3.0 ] , [ 1.0 , 5.0 , 4.0 , 3.0 , 2.0 ] , [ 4.0 , 3.0 , 2.0 , 1.0 , 5.0 ] ] ) , #NEWLINE# 'ascending_mask' : array ( [ [ nan , 2.0 , 3.0 , 4.0 , 1.0 ] , [ 2.0 , nan , 4.0 , 1.0 , 3.0 ] , [ 2.0 , 4.0 , nan , 1.0 , 3.0 ] , [ 3.0 , 1.0 , 2.0 , nan , 4.0 ] , [ 1.0 , 2.0 , 3.0 , 4.0 , nan ] ] ) , #NEWLINE# 'descending_mask' : array ( [ [ nan , 3.0 , 2.0 , 1.0 , 4.0 ] , [ 2.0 , nan , 1.0 , 4.0 , 3.0 ] , [ 2.0 , 1.0 , nan , 4.0 , 3.0 ] , [ 1.0 , 4.0 , 3.0 , nan , 2.0 ] , [ 4.0 , 3.0 , 2.0 , 1.0 , nan ] ] ) , #NEWLINE# #UNINDENT# } #NEWLINE# results = self . run_graph ( graph , initial_workspace , mask = self . build_mask ( ones ( ( 5 , 5 ) ) ) ) #NEWLINE# for method in results : #NEWLINE# #INDENT# check_arrays ( expected [ method ] , results [ method ] )