Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
FreeForestML
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CERN
fsauerbu
FreeForestML
Merge requests
!10
WIP: Resolve "Toy dataset"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Closed
WIP: Resolve "Toy dataset"
7-toy-dataset
into
master
Overview
1
Commits
8
Pipelines
1
Changes
3
Closed
Frank Sauerburger
requested to merge
7-toy-dataset
into
master
5 years ago
Overview
1
Commits
8
Pipelines
1
Changes
3
Expand
Closes
#7 (closed)
0
0
Merge request reports
Viewing commit
c1764636
Prev
Next
Show latest version
3 files
+
87
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
Unverified
c1764636
Add pseudo random number generator
· c1764636
Frank Sauerburger
authored
5 years ago
nnfwtbn/tests/test_toydata.py
0 → 100644
+
53
−
0
Options
import
unittest
import
numpy
as
np
from
nnfwtbn.toydata
import
rand
class
ToyDataTestBase
(
unittest
.
TestCase
):
def
test_rand_length
(
self
):
"""
Check that the returned array has the requested length.
"""
self
.
assertEqual
(
len
(
rand
()),
1
)
self
.
assertEqual
(
len
(
rand
(
size
=
1
)),
1
)
self
.
assertEqual
(
len
(
rand
(
312
)),
312
)
def
test_rand_repeatable
(
self
):
"""
Check that the method returns the same array twice when called with
the same seed.
"""
numbers_1
=
list
(
rand
(
143
))
numbers_2
=
list
(
rand
(
143
))
self
.
assertEqual
(
numbers_1
,
numbers_2
)
def
test_rand_seed
(
self
):
"""
Check that using different seeds returns different values.
"""
numbers_1
=
list
(
rand
(
143
,
seed
=
1
))
numbers_2
=
list
(
rand
(
143
,
seed
=
2
))
self
.
assertNotEqual
(
numbers_1
,
numbers_2
)
def
test_rand_independent
(
self
):
"""
Check that setting the numpy seed does not affect return value.
"""
np
.
random
.
seed
(
1234
)
numbers_1
=
list
(
rand
(
143
))
np
.
random
.
seed
(
4321
)
numbers_2
=
list
(
rand
(
143
))
self
.
assertEqual
(
numbers_1
,
numbers_2
)
def
test_rand_values
(
self
):
"""
Check for specific values.
"""
a
,
b
,
c
=
rand
(
3
)
self
.
assertAlmostEqual
(
a
,
0.90141859
)
self
.
assertAlmostEqual
(
b
,
0.85225178
)
self
.
assertAlmostEqual
(
c
,
0.93632300
)
Loading