[riot-notifications] [RIOT-OS/RIOT] sys/hashes/pbkdf2: Add PBKDF2-sha256 implementation. [TAKEOVER] (#15199)
Francisco
notifications at github.com
Tue Nov 3 15:25:38 CET 2020
@fjmolinas commented on this pull request.
> +# Murdock uses python 3.5 where random.choices is not available, this
+# is a verbatim copy from python 3.6
+def choices(population, weights=None, *, cum_weights=None, k=1):
+ """Return a k sized list of population elements chosen with replacement.
+ If the relative weights or cumulative weights are not specified,
+ the selections are made with equal probability.
+ """
+ n = len(population)
+ if cum_weights is None:
+ if weights is None:
+ _int = int
+ n += 0.0 # convert to float for a small speed improvement
+ return [population[_int(random.random() * n)] for i in _repeat(None, k)]
+ cum_weights = list(_accumulate(weights))
+ elif weights is not None:
+ raise TypeError('Cannot specify both weights and cumulative weights')
+ if len(cum_weights) != n:
+ raise ValueError('The number of weights does not match the population')
+ bisect = _bisect
+ total = cum_weights[-1] + 0.0 # convert to float
+ hi = n - 1
+ return [population[bisect(cum_weights, random.random() * total, 0, hi)]
+ for i in _repeat(None, k)]
Lets see if now it works
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/15199#discussion_r516704273
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20201103/a42d9f41/attachment-0001.htm>
More information about the notifications
mailing list