#NEWLINE# def test_random_pair( self ) : #NEWLINE# #INDENT# self . assertRaises ( ValueError , dedupe . core . randomPairs , 1 , 10 ) #NEWLINE# assert dedupe . core . randomPairs ( 10 , 10 ) #NEWLINE# random . seed ( 123 ) #NEWLINE# numpy . random . seed ( 123 ) #NEWLINE# random_pairs = dedupe . core . randomPairs ( 10 , 5 ) #NEWLINE# assert ( random_pairs == [ ( 0 , 3 ) , ( 3 , 8 ) , ( 4 , 9 ) , ( 5 , 9 ) , ( 2 , 3 ) ] ) #NEWLINE# with warnings . catch_warnings ( record = True ) as w : #NEWLINE# #INDENT# warnings . simplefilter ( 'always' ) #NEWLINE# dedupe . core . randomPairs ( 10 , ( 10 ** 6 ) ) #NEWLINE# assert ( len ( w ) == 1 ) #NEWLINE# assert ( str ( sample [ ( - 1 ) ] . message ) == 'Requested sample of size 1000000, only returning 45 possible pairs' ) #NEWLINE# #UNINDENT# with warnings . catch_warnings ( record = True ) as w : #NEWLINE# #INDENT# warnings . simplefilter ( 'always' ) #NEWLINE# sample = dedupe . core . randomPairs ( ( 10 ** 40 ) , 10 ) #NEWLINE# assert ( len ( w ) == 2 ) #NEWLINE# assert ( str ( w [ 0 ] . message ) == 'There may be duplicates in the sample' ) #NEWLINE# assert ( 'Asked to sample pairs from' in str ( w [ 1 ] . message ) ) #NEWLINE# set ( sample ) #NEWLINE# #UNINDENT# random . seed ( 123 ) #NEWLINE# numpy . random . seed ( 123 ) #NEWLINE# assert numpy . array_equal ( dedupe . core . randomPairs ( ( 10 ** 3 ) , 1 ) , numpy . array ( [ ( 292 , 413 ) ] ) )