Kaydet (Commit) 8567e58a authored tarafından Raymond Hettinger's avatar Raymond Hettinger

Minor code beautification

üst 16ef5d4a
...@@ -350,8 +350,7 @@ class Random(_random.Random): ...@@ -350,8 +350,7 @@ class Random(_random.Random):
_int = int _int = int
total = len(population) total = len(population)
return [population[_int(random() * total)] for i in range(k)] return [population[_int(random() * total)] for i in range(k)]
else: cum_weights = list(_itertools.accumulate(weights))
cum_weights = list(_itertools.accumulate(weights))
elif weights is not None: elif weights is not None:
raise TypeError('Cannot specify both weights and cumulative_weights') raise TypeError('Cannot specify both weights and cumulative_weights')
if len(cum_weights) != len(population): if len(cum_weights) != len(population):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment