Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(50)  |  Call(48)  |  Derive(0)  |  Import(2)

src/c/o/cogent-1.5.3/tests/test_maths/test_stats/test_util.py   cogent(Download)
import numpy
from cogent.util.unit_test import TestCase, main
from cogent.maths.stats.util import SummaryStatistics, SummaryStatisticsError,\
        Numbers, UnsafeNumbers, Freqs, UnsafeFreqs, NumberFreqs, \
        UnsafeNumberFreqs
    def test_init(self):
        """SummaryStatistics should initialize correctly."""
        #check empty init -- can access private vars, but can't get
        #properties.
        s = SummaryStatistics()
        self.assertEqual(s._count, None)
        self.assertRaises(SummaryStatisticsError, getattr, s, 'Count')
        #check init with one positional parameter
        s = SummaryStatistics(1)
        #check init with all positional parameters.
        #note that inconsistent data can sneak in (c.f. sd vs var)
        s = SummaryStatistics(1,2,3,4,5,6)
        self.assertEqual(s.Count, 1)
        self.assertEqual(s.Sum, 2)
    def test_str(self):
        """SummaryStatistics str should print known fields."""
        s = SummaryStatistics()
        self.assertEqual(str(s), '')
        #note that additional fields will fill in if they can be calculated.

src/p/y/pycogent-HEAD/tests/test_maths/test_stats/test_util.py   pycogent(Download)
import numpy
from cogent.util.unit_test import TestCase, main
from cogent.maths.stats.util import SummaryStatistics, SummaryStatisticsError,\
        Numbers, UnsafeNumbers, Freqs, UnsafeFreqs, NumberFreqs, \
        UnsafeNumberFreqs
    def test_init(self):
        """SummaryStatistics should initialize correctly."""
        #check empty init -- can access private vars, but can't get
        #properties.
        s = SummaryStatistics()
        self.assertEqual(s._count, None)
        self.assertRaises(SummaryStatisticsError, getattr, s, 'Count')
        #check init with one positional parameter
        s = SummaryStatistics(1)
        #check init with all positional parameters.
        #note that inconsistent data can sneak in (c.f. sd vs var)
        s = SummaryStatistics(1,2,3,4,5,6)
        self.assertEqual(s.Count, 1)
        self.assertEqual(s.Sum, 2)
    def test_str(self):
        """SummaryStatistics str should print known fields."""
        s = SummaryStatistics()
        self.assertEqual(str(s), '')
        #note that additional fields will fill in if they can be calculated.