1515import numpy as np
1616import random
1717
18- from sklearn .externals .six .moves import xrange
1918from sklearn .utils .random import sample_without_replacement
2019
2120
@@ -90,49 +89,47 @@ def bench_sample(sampling, n_population, n_samples):
9089 # Set Python core input
9190 sampling_algorithm ["python-core-sample" ] = \
9291 lambda n_population , n_sample : \
93- random .sample (xrange (n_population ), n_sample )
92+ random .sample (range (n_population ), n_sample )
9493
95- ###########################################################################
94+ ###########################################################################
9695 # Set custom automatic method selection
9796 sampling_algorithm ["custom-auto" ] = \
9897 lambda n_population , n_samples , random_state = None : \
99- sample_without_replacement (n_population ,
100- n_samples ,
101- method = "auto" ,
102- random_state = random_state )
98+ sample_without_replacement (n_population , n_samples , method = "auto" ,
99+ random_state = random_state )
103100
104101 ###########################################################################
105102 # Set custom tracking based method
106103 sampling_algorithm ["custom-tracking-selection" ] = \
107104 lambda n_population , n_samples , random_state = None : \
108- sample_without_replacement (n_population ,
109- n_samples ,
110- method = "tracking_selection" ,
111- random_state = random_state )
105+ sample_without_replacement (n_population ,
106+ n_samples ,
107+ method = "tracking_selection" ,
108+ random_state = random_state )
112109
113110 ###########################################################################
114111 # Set custom reservoir based method
115112 sampling_algorithm ["custom-reservoir-sampling" ] = \
116113 lambda n_population , n_samples , random_state = None : \
117- sample_without_replacement (n_population ,
118- n_samples ,
119- method = "reservoir_sampling" ,
120- random_state = random_state )
114+ sample_without_replacement (n_population ,
115+ n_samples ,
116+ method = "reservoir_sampling" ,
117+ random_state = random_state )
121118
122119 ###########################################################################
123120 # Set custom reservoir based method
124121 sampling_algorithm ["custom-pool" ] = \
125122 lambda n_population , n_samples , random_state = None : \
126- sample_without_replacement (n_population ,
127- n_samples ,
128- method = "pool" ,
129- random_state = random_state )
123+ sample_without_replacement (n_population ,
124+ n_samples ,
125+ method = "pool" ,
126+ random_state = random_state )
130127
131128 ###########################################################################
132129 # Numpy permutation based
133130 sampling_algorithm ["numpy-permutation" ] = \
134131 lambda n_population , n_sample : \
135- np .random .permutation (n_population )[:n_sample ]
132+ np .random .permutation (n_population )[:n_sample ]
136133
137134 ###########################################################################
138135 # Remove unspecified algorithm
@@ -156,11 +153,11 @@ def bench_sample(sampling, n_population, n_samples):
156153 print ("Perform benchmarks for %s..." % name , end = "" )
157154 time [name ] = np .zeros (shape = (opts .n_steps , opts .n_times ))
158155
159- for step in xrange (opts .n_steps ):
160- for it in xrange (opts .n_times ):
156+ for step in range (opts .n_steps ):
157+ for it in range (opts .n_times ):
161158 time [name ][step , it ] = bench_sample (sampling_algorithm [name ],
162- opts .n_population ,
163- n_samples [step ])
159+ opts .n_population ,
160+ n_samples [step ])
164161
165162 print ("done" )
166163
0 commit comments