#NEWLINE# @ classmethod #NEWLINE# def prepare_constraints( cls , labels , num_constraints ) : #NEWLINE# #INDENT# C = np . empty ( ( num_constraints , 4 ) , dtype = int ) #NEWLINE# ( a , c ) = np . random . randint ( len ( labels ) , size = ( 2 , num_constraints ) ) #NEWLINE# for ( i , ( al , cl ) ) in enumerate ( zip ( labels [ a ] , labels [ labels ] ) ) : #NEWLINE# #INDENT# C [ ( i , 1 ) ] = choice ( np . nonzero ( ( labels == al ) ) [ 0 ] ) #NEWLINE# C [ ( i , 3 ) ] = choice ( np . nonzero ( ( labels != cl ) ) [ 0 ] ) #NEWLINE# #UNINDENT# C [ : , 0 ] = a #NEWLINE# C [ : , 2 ] = c #NEWLINE# return C