Lines Matching refs:choices
154 choices = self.gen.choices
162 choices(data, k=5),
163 choices(data, range(4), k=5),
164 choices(k=5, population=data, weights=range(4)),
165 choices(k=5, population=data, cum_weights=range(4)),
173 choices(2)
175 self.assertEqual(choices(data, k=0), []) # k == 0
176 …self.assertEqual(choices(data, k=-1), []) # negative k behaves like ``[0] *…
178 choices(data, k=2.5) # k is a float
180 … self.assertTrue(set(choices(str_data, k=5)) <= set(str_data)) # population is a string sequence
181 self.assertTrue(set(choices(range_data, k=5)) <= set(range_data)) # population is a range
183 … choices(set_data, k=2) # population is not a sequence
185 self.assertTrue(set(choices(data, None, k=5)) <= set(data)) # weights is None
186 self.assertTrue(set(choices(data, weights=None, k=5)) <= set(data))
188 … choices(data, [1,2], k=5) # len(weights) != len(population)
190 choices(data, 10, k=5) # non-iterable weights
192 choices(data, [None]*4, k=5) # non-numeric weights
199 self.assertTrue(set(choices(data, weights, k=5)) <= set(data))
202 … choices(data, cum_weights=[1,2], k=5) # len(weights) != len(population)
204 choices(data, cum_weights=10, k=5) # non-iterable cum_weights
206 choices(data, cum_weights=[None]*4, k=5) # non-numeric cum_weights
208 … choices(data, range(4), cum_weights=range(4), k=5) # both weights and cum_weights
214 self.assertTrue(set(choices(data, cum_weights=weights, k=5)) <= set(data))
217 self.assertEqual(choices('abcd', [1, 0, 0, 0]), ['a'])
218 self.assertEqual(choices('abcd', [0, 1, 0, 0]), ['b'])
219 self.assertEqual(choices('abcd', [0, 0, 1, 0]), ['c'])
220 self.assertEqual(choices('abcd', [0, 0, 0, 1]), ['d'])
224 choices([], k=1)
226 choices([], weights=[], k=1)
228 choices([], cum_weights=[], k=5)
235 choices = self.gen.choices
236 choices(population=[1, 2], weights=[1e-323, 1e-323], k=5000)
696 choices = self.gen.choices
700 a = self.gen.choices(range(n), k=10000)
703 b = self.gen.choices(range(n), [1]*n, k=10000)
707 c = self.gen.choices(range(n), cum_weights=range(1, n+1), k=10000)
717 a = self.gen.choices(expanded_population, k=10000)
720 b = self.gen.choices(population, weights, k=10000)
724 c = self.gen.choices(population, cum_weights=cum_weights, k=10000)