[yoda-svn] r237 - in trunk: pyext tests

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Fri Aug 12 21:03:48 BST 2011


Author: buckley
Date: Fri Aug 12 21:03:48 2011
New Revision: 237

Log:
Python tweaks

Added:
   trunk/tests/PyTest.py
      - copied unchanged from r235, trunk/pyext/PyTest.py
   trunk/tests/TestNegWeights.py
      - copied unchanged from r235, trunk/pyext/TestNegWeights.py
   trunk/tests/TestSWIG.py
      - copied unchanged from r235, trunk/pyext/TestSWIG.py
Deleted:
   trunk/pyext/PyTest.py
   trunk/pyext/TestNegWeights.py
   trunk/pyext/TestSWIG.py
   trunk/pyext/ez_setup.py
Modified:
   trunk/pyext/Makefile.am
   trunk/pyext/setup.py.in   (props changed)
   trunk/tests/Makefile.am

Modified: trunk/pyext/Makefile.am
==============================================================================
--- trunk/pyext/Makefile.am	Fri Aug 12 20:16:50 2011	(r236)
+++ trunk/pyext/Makefile.am	Fri Aug 12 21:03:48 2011	(r237)
@@ -1,5 +1,3 @@
-EXTRA_DIST = ez_setup.py
-
 if ENABLE_PYEXT
 
 SUBDIRS = yoda .

Modified: trunk/tests/Makefile.am
==============================================================================
--- trunk/tests/Makefile.am	Fri Aug 12 20:16:50 2011	(r236)
+++ trunk/tests/Makefile.am	Fri Aug 12 21:03:48 2011	(r237)
@@ -18,7 +18,7 @@
 
 TESTS_ENVIRONMENT = \
   LD_LIBRARY_PATH=$(top_builddir)/src:$(top_builddir)/src/.libs:$(LD_LIBRARY_PATH) \
-  PYTHONPATH=$(top_builddir)/pyext/build \
+  PYTHONPATH=$(top_builddir)/pyext/build:$(PYTHONPATH) \
   PATH=$(top_builddir)/bin:$(PATH)
 
 TESTS = \

Copied: trunk/tests/PyTest.py (from r235, trunk/pyext/PyTest.py)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/tests/PyTest.py	Fri Aug 12 21:03:48 2011	(r237, copy of r235, trunk/pyext/PyTest.py)
@@ -0,0 +1,13 @@
+#! /usr/bin/env python
+
+from yoda import *
+NUM_SAMPLES = 1000
+
+h = Histo1D("/foo", "Title", 50, 0.0, 100.0)
+
+for i in range(NUM_SAMPLES):
+    exp = - (i-NUM_SAMPLES/2)**2 / float(NUM_SAMPLES/4)
+    val = 2.718 ** exp
+    h.fill(val);
+
+print h.mean(), "+-", h.stdDev()

Copied: trunk/tests/TestNegWeights.py (from r235, trunk/pyext/TestNegWeights.py)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/tests/TestNegWeights.py	Fri Aug 12 21:03:48 2011	(r237, copy of r235, trunk/pyext/TestNegWeights.py)
@@ -0,0 +1,46 @@
+#! /usr/bin/env python
+
+import sys
+from yoda import *
+
+def testmatch(name, v1, v2, tolerance=1e-3):
+    fracdiff = 2*abs(v1 - v2)/(v1 + v2)
+    match = (fracdiff < 1e-3)
+    passfail = "PASS" if match else "FAIL"
+    print "Testing %s: %f vs. %f => %e deviation. %s" % (name, v1, v2, fracdiff, passfail)
+    return match
+
+h1 = Histo1D(5, 0.0, 100.0)
+h1.fill(10,-200)
+h1.fill(20,1)
+h1.fill(30,0.2)
+h1.fill(10,+200)
+
+h2 = Histo1D(5, 0.0, 100.0)
+h2.fill(20,1)
+h2.fill(30,0.2)
+
+meanmatch   = testmatch("means",    h1.mean(),   h2.mean())
+stddevmatch = testmatch("std devs", h1.stdDev(), h2.stdDev())
+ok = (stddevmatch and meanmatch)
+
+p1 = Profile1D(5, 0.0, 100.0)
+p1.fill(10, 10, -200)
+p1.fill(10, 10, +200)
+p1.fill(20, 20, 1)
+p1.fill(25, 40, 4)
+p1.fill(70, 70, 0.2)
+
+p2 = Profile1D(5, 0.0, 100.0)
+p2.fill(20, 20, 1)
+p2.fill(25, 40, 4)
+p2.fill(70, 70, 0.2)
+
+for i, j in zip(p1.bins(), p2.bins()):
+    if i.numEntries() > 1 and j.numEntries() > 1:
+        meanmatch   = testmatch("y means",    i.mean(),   j.mean())
+        stddevmatch = testmatch("y std errs", i.stdErr(), j.stdErr())
+        ok = ok and stddevmatch and meanmatch
+
+if not ok:
+    sys.exit(1)

Copied: trunk/tests/TestSWIG.py (from r235, trunk/pyext/TestSWIG.py)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/tests/TestSWIG.py	Fri Aug 12 21:03:48 2011	(r237, copy of r235, trunk/pyext/TestSWIG.py)
@@ -0,0 +1,5 @@
+#! /usr/bin/env python
+
+from yoda import *
+h = Histo1D("/foo", "Title", 50, 0.0, 100.0)
+print h.bins()


More information about the yoda-svn mailing list