Ejemplo n.º 1
0
def _debugstdout():
    print "Messages ON"
    _test_stdout()
    _test_stderr()
    print "Messages OFF"
    with nostdout(stdout=True, stderr=False):
        _test_stdout()
    with nostdout(stdout=False, stderr=True):
        _test_stderr()
    print "Messages ON"
    _test_stdout()
    _test_stderr()
    print "done."
    return
Ejemplo n.º 2
0
def _debugstdout():
    print "Messages ON"
    _test_stdout()
    _test_stderr()
    print "Messages OFF"
    with nostdout(stdout=True, stderr=False):
        _test_stdout()
    with nostdout(stdout=False, stderr=True):
        _test_stderr()
    print "Messages ON"
    _test_stdout()
    _test_stderr()
    print "done."
    return
Ejemplo n.º 3
0
def _runtest(*args, **kwargs):
        strio = StringIO()
        stdout = sys.stdout
        stderr = sys.stderr
        sys.stdout = strio
        sys.stderr = strio
        with nostdout(*args, **kwargs):
            _test_stdout()
            _test_stderr()
        sys.stdout = stdout
        sys.stderr = stderr
        return strio.getvalue()
Ejemplo n.º 4
0
def _runtest(*args, **kwargs):
    strio = StringIO()
    stdout = sys.stdout
    stderr = sys.stderr
    sys.stdout = strio
    sys.stderr = strio
    with nostdout(*args, **kwargs):
        _test_stdout()
        _test_stderr()
    sys.stdout = stdout
    sys.stderr = stderr
    return strio.getvalue()
Ejemplo n.º 5
0
 def test_mean_and_stddev(self):
     expectedmu = np.arange(0.0, 10.0)
     names = ["par"+str(x) for x in expectedmu]
     expectedsigma = np.arange(0.0, 10.0)
     mu = Mean()
     gen = GaussianGenerator(names, expectedmu, expectedsigma, seed=1290)
     statistics = [Mean(), StandardDeviation(), FractionalStandardDeviation()]
     with nostdout():
         calculate_statistics(gen, statistics, 10**4, name="test")
     for s, expected in itertools.izip_longest(statistics, [expectedmu, expectedsigma, safedivide(expectedsigma, expectedmu)]):
         for x, err, exp in itertools.izip_longest(s.eval(), s.err(), expected):
             self.assertAlmostEquals(x, exp, delta=5.0*err)
     return
Ejemplo n.º 6
0
 def test_mean_and_stddev(self):
     expectedmu = np.arange(0.0, 10.0)
     names = ["par" + str(x) for x in expectedmu]
     expectedsigma = np.arange(0.0, 10.0)
     mu = Mean()
     gen = GaussianGenerator(names, expectedmu, expectedsigma, seed=1290)
     statistics = [
         Mean(), StandardDeviation(),
         FractionalStandardDeviation()
     ]
     with nostdout():
         calculate_statistics(gen, statistics, 10**4, name="test")
     for s, expected in itertools.izip_longest(
             statistics,
         [expectedmu, expectedsigma,
          safedivide(expectedsigma, expectedmu)]):
         for x, err, exp in itertools.izip_longest(s.eval(), s.err(),
                                                   expected):
             self.assertAlmostEquals(x, exp, delta=5.0 * err)
     return
Ejemplo n.º 7
0
 def test_prof_both(self):
     with nostdout():
         profile_func(sum_inv, [100], {"start":10})
Ejemplo n.º 8
0
 def test_prof_kwargs(self):
     with nostdout():
         profile_func(sum_inv, [], {"N":100, "start":10})
Ejemplo n.º 9
0
 def test_prof_args(self):
     with nostdout():
         profile_func(sum_inv, [100])
Ejemplo n.º 10
0
 def test_prof_noargs(self):
     with nostdout():
         profile_func(sum_inv)