Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
d6764934
Commit
d6764934
authored
Dec 22, 2014
by
Georgios Dagkakis
Committed by
Ioannis Papagiannopoulos
Jan 06, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testRandomNumberGenerator script updated
parent
6ccd5026
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
14 deletions
+18
-14
dream/tests/testRandomNumberGenerator.py
dream/tests/testRandomNumberGenerator.py
+18
-14
No files found.
dream/tests/testRandomNumberGenerator.py
View file @
d6764934
...
...
@@ -25,30 +25,32 @@ obj = Source(id='dummy_obj', name="Dummy obj to instanciate RNG")
class
RandomNumberGeneratorTestCase
(
TestCase
):
def
testFixed
(
self
):
rng
=
RandomNumberGenerator
(
obj
,
distribution
Type
=
'Fixed'
,
mean
=
32
)
rng
=
RandomNumberGenerator
(
obj
,
distribution
=
{
'Fixed'
:
{
'mean'
:
32
}}
)
self
.
assertEquals
(
rng
.
generateNumber
(),
32
)
self
.
assertEquals
(
rng
.
generateNumber
(),
32
)
def
testExp
(
self
):
rng
=
RandomNumberGenerator
(
obj
,
distribution
Type
=
'Exp'
,
mean
=
10
)
rng
=
RandomNumberGenerator
(
obj
,
distribution
=
{
'Exp'
:
{
'mean'
:
10
}}
)
number
=
rng
.
generateNumber
()
# at least we make sure we generate a number
self
.
assertTrue
(
number
>=
0
)
def
testErlang
(
self
):
rng
=
RandomNumberGenerator
(
obj
,
distribution
Type
=
'Erlang'
,
alpha
=
1
,
beta
=
2
)
distribution
=
{
'Erlang'
:
{
'alpha'
:
1
,
'beta'
:
2
}}
)
number
=
rng
.
generateNumber
()
# at least we make sure we generate a number
self
.
assertTrue
(
number
>=
0
)
def
testNormal
(
self
):
rng
=
RandomNumberGenerator
(
obj
,
distributionType
=
'Normal'
,
min
=
0
,
max
=
3
,
stdev
=
.
5
,
mean
=
2
)
distribution
=
{
'Normal'
:
{
'min'
:
0
,
'max'
:
3
,
'stdev'
:.
5
,
'mean'
:
2
}
})
for
i
in
range
(
10
):
number
=
rng
.
generateNumber
()
self
.
assertTrue
(
number
>=
0
)
...
...
@@ -56,14 +58,16 @@ class RandomNumberGeneratorTestCase(TestCase):
def
testNormalWrongParameter
(
self
):
rng
=
RandomNumberGenerator
(
obj
,
distributionType
=
'Normal'
,
min
=
3
,
max
=
0
,
# here min > max
stdev
=
.
5
,
mean
=
2
)
distribution
=
{
'Normal'
:
{
'min'
:
3
,
'max'
:
0
,
# here min > max
'stdev'
:.
5
,
'mean'
:
2
}
})
self
.
assertRaises
(
ValueError
,
rng
.
generateNumber
)
def
testUnkonwnDistribution
(
self
):
rng
=
RandomNumberGenerator
(
obj
,
distribution
Type
=
'Unknown'
)
rng
=
RandomNumberGenerator
(
obj
,
distribution
=
'Unknown'
)
self
.
assertRaises
(
ValueError
,
rng
.
generateNumber
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment