[Scipy-svn] r3479 - in trunk/scipy/sandbox/montecarlo: . src tests
scipy-svn at scipy.org
scipy-svn at scipy.org
Thu Nov 1 07:36:04 EDT 2007
Author: edschofield
Date: 2007-11-01 06:35:51 -0500 (Thu, 01 Nov 2007)
New Revision: 3479
Modified:
trunk/scipy/sandbox/montecarlo/montecarlo.py
trunk/scipy/sandbox/montecarlo/src/compact5table.c
trunk/scipy/sandbox/montecarlo/tests/test_dictsampler.py
trunk/scipy/sandbox/montecarlo/tests/test_intsampler.py
Log:
Clean up Monte Carlo code; make unit-test class names lowercase so they run
Modified: trunk/scipy/sandbox/montecarlo/montecarlo.py
===================================================================
--- trunk/scipy/sandbox/montecarlo/montecarlo.py 2007-11-01 01:31:37 UTC (rev 3478)
+++ trunk/scipy/sandbox/montecarlo/montecarlo.py 2007-11-01 11:35:51 UTC (rev 3479)
@@ -3,13 +3,12 @@
# Copyright: Ed Schofield, 2005-2006
# License: BSD-style (see LICENSE.txt at root of scipy tree)
-__author__ = "Ed Schofield"
-
from __future__ import division
import numpy
import scipy
from scipy.sandbox.montecarlo._intsampler import _intsampler
+__author__ = "Ed Schofield"
class genericsampler(object):
"""A base class for other samplers.
Modified: trunk/scipy/sandbox/montecarlo/src/compact5table.c
===================================================================
--- trunk/scipy/sandbox/montecarlo/src/compact5table.c 2007-11-01 01:31:37 UTC (rev 3478)
+++ trunk/scipy/sandbox/montecarlo/src/compact5table.c 2007-11-01 11:35:51 UTC (rev 3479)
@@ -97,16 +97,6 @@
break;
}
}
- // if (sampler->prob1event == -1)
- // {
- // /* This has been tested above, so I think this should never
- // occur... */
- // fprintf(stderr, "Error: invalid arguments to init_sampler5tbl()." \
- // "The sum of the probabilities is zero. Aborting!\n");
- // free(P);
- // free(sampler);
- // return NULL;
- // }
}
else
{
@@ -207,11 +197,12 @@
*/
if (j - sampler->t4 >= sampler->sizeEE)
{
- /* The random number generated is larger than the sizes of all tables.
- * This should happen only very rarely. For now, just generate another
- * random number. */
- fprintf(stderr,
- "Debug: random number is larger than the sizes of all tables!");
+ /* The random number generated is larger than the sizes of all
+ * tables. Why does this happen? Debug this! For now, just generate
+ * another random number.
+ */
+ /* fprintf(stderr,
+ "Debug: random number (%d) is larger than the sizes of all tables!\n", j); */
return Dran(sampler);
}
else
@@ -256,11 +247,11 @@
else if (j - sampler->t4 >= sampler->sizeEE)
{
/* The random number generated is larger than the sizes of all
- * tables. This should happen only very rarely. For now, just
- * generate another random number.
+ * tables. Why does this happen? Debug this! For now, just generate
+ * another random number.
*/
- fprintf(stderr,
- "Debug: random number is larger than the sizes of all tables!");
+ /* fprintf(stderr,
+ "Debug: random number (%d) is larger than the sizes of all tables\n!", j); */
i--;
}
else
Modified: trunk/scipy/sandbox/montecarlo/tests/test_dictsampler.py
===================================================================
--- trunk/scipy/sandbox/montecarlo/tests/test_dictsampler.py 2007-11-01 01:31:37 UTC (rev 3478)
+++ trunk/scipy/sandbox/montecarlo/tests/test_dictsampler.py 2007-11-01 11:35:51 UTC (rev 3479)
@@ -21,7 +21,7 @@
import unittest
-class TestDictSampler(NumpyTestCase):
+class test_dict_sampler(NumpyTestCase):
def check_simple(self):
"""
# Sample from this discrete distribution:
Modified: trunk/scipy/sandbox/montecarlo/tests/test_intsampler.py
===================================================================
--- trunk/scipy/sandbox/montecarlo/tests/test_intsampler.py 2007-11-01 01:31:37 UTC (rev 3478)
+++ trunk/scipy/sandbox/montecarlo/tests/test_intsampler.py 2007-11-01 11:35:51 UTC (rev 3479)
@@ -2,8 +2,7 @@
""" Test functions for generic discrete sampler 'intsampler'
-Author: Ed Schofield, 2003-2006
-Copyright: Ed Schofield, 2003-2006
+Author: Ed Schofield
"""
@@ -22,15 +21,12 @@
from numpy.testing import *
set_package_path()
from numpy import *
-#from scipy.montecarlo import *
from scipy.sandbox.montecarlo import *
from scipy import stats
restore_path()
-import unittest
-
-class TestIntSampler(NumpyTestCase):
+class test_int_sampler(NumpyTestCase):
def check_simple(self):
# Sample from a Poisson distribution, P(lambda = 10.0)
lam = 10.0
More information about the Scipy-svn
mailing list