#NEWLINE# def test_run_quicksort_lt( self ) : #NEWLINE# #INDENT# def lt( a , b ) : #NEWLINE# #INDENT# return ( a > b ) #NEWLINE# #UNINDENT# f = self . make_quicksort ( lt = lt ) . run_quicksort #NEWLINE# for size_factor in ( 1 , 5 ) : #NEWLINE# #INDENT# sizes = ( 15 , 20 ) #NEWLINE# all_lists = [ self . make_sample_lists ( ( n * size_factor ) ) for n in sizes ] #NEWLINE# for chunks in itertools . product ( * all_lists ) : #NEWLINE# #INDENT# orig_keys = sum ( chunks , [ ] ) #NEWLINE# keys = self . array_factory ( orig_keys ) #NEWLINE# f ( keys ) #NEWLINE# self . assertSorted ( orig_keys , keys [ : : ( - 1 ) ] ) #NEWLINE# #UNINDENT# #UNINDENT# def lt_floats( a , b ) : #NEWLINE# #INDENT# return ( math . isnan ( b ) or ( a < b ) ) #NEWLINE# #UNINDENT# f = self . make_quicksort ( lt = lt_floats ) . run_quicksort #NEWLINE# np . random . seed ( 42 ) #NEWLINE# for size in ( 5 , 20 , 50 , 500 ) : #NEWLINE# #INDENT# orig = ( np . random . random ( size = size ) * 100 ) #NEWLINE# orig [ ( np . random . random ( size = size ) < 0.1 ) ] = float ( 'nan' ) #NEWLINE# orig_keys = list ( orig ) #NEWLINE# keys = self . array_factory ( orig_keys ) #NEWLINE# f ( non_nans ) #NEWLINE# non_nans = orig [ ( ~ np . isnan ( orig ) ) ] #NEWLINE# self . assertSorted ( non_nans , keys [ : len ( non_nans ) ] )