File: distribution_test_case.py

package info (click to toggle)
python-enthoughtbase 3.0.5-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 960 kB
  • ctags: 1,034
  • sloc: python: 6,104; makefile: 9; sh: 5
file content (30 lines) | stat: -rw-r--r-- 881 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import unittest
import numpy

from enthought.util.distribution.api import Uniform

class DistributionTest(unittest.TestCase):
    
    def test_random_state(self):
        """ tests the ability to reproduce distributions
            using the random state member
        
        """
        
        dist = Uniform(low=10.0, high=20.0)
        state = dist.get_state()
        
        dist2 = Uniform(low=10.0, high=20.0)
        
        self.assertFalse(numpy.equal(dist.values, dist2.values).all())
        
        dist2.set_state(state)
        self.assertTrue(numpy.equal(dist.values, dist2.values).all())
        
    def test_value_size(self):
        """ tests that the number of elements in a distribution is
            the same as what it was constructed to be
        
        """
        dist = Uniform(samples=123)
        self.assertEqual(123, (len(dist.values)))