Skip to content
Snippets Groups Projects

WIP: Resolve "Toy dataset"

Closed Frank Sauerburger requested to merge 7-toy-dataset into master
3 files
+ 87
0
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 53
0
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