mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
* Migrate sample distribution test from random.py to test_random.py.
* Use Sets module to more clearly articulate a couple of tests.
This commit is contained in:
parent
ee1bded046
commit
7b0cf76b72
2 changed files with 22 additions and 10 deletions
|
@ -743,9 +743,6 @@ def _test_generator(n, funccall):
|
|||
print 'avg %g, stddev %g, min %g, max %g' % \
|
||||
(avg, stddev, smallest, largest)
|
||||
|
||||
def _sample_generator(n, k):
|
||||
# Return a fixed element from the sample. Validates random ordering.
|
||||
return sample(xrange(n), k)[k//2]
|
||||
|
||||
def _test(N=2000):
|
||||
_test_generator(N, 'random()')
|
||||
|
@ -764,8 +761,6 @@ def _test(N=2000):
|
|||
_test_generator(N, 'gammavariate(200.0, 1.0)')
|
||||
_test_generator(N, 'gauss(0.0, 1.0)')
|
||||
_test_generator(N, 'betavariate(3.0, 3.0)')
|
||||
_test_generator(N, '_sample_generator(50, 5)') # expected s.d.: 14.4
|
||||
_test_generator(N, '_sample_generator(50, 45)') # expected s.d.: 14.4
|
||||
|
||||
# Create one instance, seeded from current time, and export its methods
|
||||
# as module-level functions. The functions share state across all uses
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue