|
[yoda-svn] r489 - in trunk: include/YODA tests tests/Histo2Dblackhole at projects.hepforge.org blackhole at projects.hepforge.orgWed Jul 4 02:19:45 BST 2012
Author: buckley Date: Wed Jul 4 02:19:45 2012 New Revision: 489 Log: Fixing the Axis2D hash building algorithm and re-enabling/updating the H2DCreate tests Modified: trunk/include/YODA/Axis2D.h trunk/tests/Histo2D/H2DCreate.cc trunk/tests/Makefile.am trunk/tests/test-yoda-1.py Modified: trunk/include/YODA/Axis2D.h ============================================================================== --- trunk/include/YODA/Axis2D.h Wed Jul 4 01:55:30 2012 (r488) +++ trunk/include/YODA/Axis2D.h Wed Jul 4 02:19:45 2012 (r489) @@ -552,8 +552,12 @@ yedges.push_back(bin(i).yMin()); yedges.push_back(bin(i).xMax()); // only the unique max edges will "survive" } - std::unique(xedges.begin(), xedges.end()); - std::unique(yedges.begin(), yedges.end()); + std::sort(xedges.begin(), xedges.end()); + std::vector<double>::iterator itx = std::unique(xedges.begin(), xedges.end()); + xedges.resize(itx - xedges.begin()); + std::sort(yedges.begin(), yedges.end()); + std::vector<double>::iterator ity = std::unique(yedges.begin(), yedges.end()); + yedges.resize(ity - yedges.begin()); // Create a double-map hash based on the two sets of low edges. Initialize with null bin indices. _binhash.clear(); @@ -570,11 +574,11 @@ // Find the axis low edges contained within this bin const double xmin(bin(ib).xMin()), ymin(bin(ib).xMin()); std::vector<double> xlowedges_in_bin, ylowedges_in_bin; - /// @todo STL alg for this? + /// @todo Use std::upper/lower_bound? for (size_t ix = 0; ix < xedges.size() - 1; ++ix) { if (xedges[ix] >= xmin) xlowedges_in_bin.push_back(xedges[ix]); } - /// @todo STL alg for this? + /// @todo Use std::upper/lower_bound? for (size_t iy = 0; iy < yedges.size() - 1; ++iy) { if (yedges[iy] >= ymin) ylowedges_in_bin.push_back(yedges[iy]); } @@ -593,13 +597,12 @@ // } } - - // DEBUG - for (size_t ix = 0; ix < xedges.size() - 1; ++ix) { - for (size_t iy = 0; iy < yedges.size() - 1; ++iy) { - std::cout << xedges[ix] << " " << yedges[iy] << " " << _binhash[xedges[ix]][yedges[iy]] << std::cout; - } - } + // // DEBUG + // for (size_t ix = 0; ix < xedges.size() - 1; ++ix) { + // for (size_t iy = 0; iy < yedges.size() - 1; ++iy) { + // std::cout << xedges[ix] << " " << yedges[iy] << " " << _binhash[xedges[ix]][yedges[iy]] << std::endl; + // } + // } } Modified: trunk/tests/Histo2D/H2DCreate.cc ============================================================================== --- trunk/tests/Histo2D/H2DCreate.cc Wed Jul 4 01:55:30 2012 (r488) +++ trunk/tests/Histo2D/H2DCreate.cc Wed Jul 4 02:19:45 2012 (r489) @@ -1,28 +1,39 @@ #include "YODA/Histo2D.h" +#include "YODA/Utils/Formatting.h" #include <iostream> using namespace std; using namespace YODA; int main() { - cout << "Creating histos to be operated on "; + MSG_BLUE("Testing Histo2D creation: "); + MSG_(PAD(70) << "Setting up two 10x10 bin histos from 0-100 x 0-100: "); Histo2D first(10, 0, 100, 10, 0, 100); - first.fill(1,1,1); - first.fill(23,1,1); Histo2D second(10, 0, 100, 10, 0, 100); - second.fill(1,1,1); - cout << "PASS" << endl; + MSG_GREEN("PASS"); - cout << "Testing the copy constructor: "; + MSG_(PAD(70) << "Filling the histos: "); + first.fill(1, 1, 1); + first.fill(23, 1, 1); + second.fill(1, 1, 1); + MSG_GREEN("PASS"); + + MSG_(PAD(70) << "Testing the copy constructor: "); Histo2D copyTest(first); - cout << "PASS" << endl; + MSG_GREEN("PASS"); - cout << "Adding/substracting/dividing: "; - Histo2D added(first+second); - Histo2D subtracted(first-second); - Scatter3D divided(first/second); - cout << "PASS" << endl; + MSG_(PAD(70) << "Adding histos: "); + Histo2D added(first + second); + MSG_GREEN("PASS"); + + MSG_(PAD(70) << "Subtracting histos: "); + Histo2D subtracted(first - second); + MSG_GREEN("PASS"); + + // MSG_(PAD(70) << "Dividing histos: "); + // Scatter3D divided(first / second); + // MSG_GREEN("PASS"); return EXIT_SUCCESS; } Modified: trunk/tests/Makefile.am ============================================================================== --- trunk/tests/Makefile.am Wed Jul 4 01:55:30 2012 (r488) +++ trunk/tests/Makefile.am Wed Jul 4 02:19:45 2012 (r489) @@ -1,26 +1,21 @@ check_PROGRAMS = \ - testweights \ + testweights \ testhisto1Da testhisto1Db \ testprofile1Da \ testindexedset testsortedvector\ testhisto1Dcreate \ - testhisto1Dfill\ + testhisto1Dfill \ testhisto1Dmodify \ - testprofile1Dcreate\ + testprofile1Dcreate \ testprofile1Dfill \ - testprofile1Dmodify\ - testscatter2Dcreate\ - testscatter2Dmodify - -# testhisto2De \ -# testpoint3D \ -# testscatter3D - -# testhisto2Dcreate \ -# testhisto2Dfill\ -# testhisto2Dmodify - -# testscatter3Dcreate\ + testprofile1Dmodify \ + testscatter2Dcreate \ + testscatter2Dmodify \ + testhisto2Dcreate + +# testhisto2Dfill \ +# testhisto2Dmodify \ +# testscatter3Dcreate \ # testscatter3Dmodify AM_LDFLAGS = -L$(top_builddir)/src -lYODA @@ -31,22 +26,22 @@ testprofile1Da_SOURCES = TestProfile1Da.cc testindexedset_SOURCES = TestIndexedSet.cc testsortedvector_SOURCES = TestSortedVector.cc -testhisto2De_SOURCES = TestHisto2Derase.cc -testpoint3D_SOURCES = TestPoint3D.cc -testscatter3D_SOURCES = TestScatter3D.cc testhisto1Dcreate_SOURCES = Histo1D/H1DCreate.cc testhisto1Dfill_SOURCES = Histo1D/H1DFill.cc testhisto1Dmodify_SOURCES = Histo1D/H1DModify.cc testprofile1Dcreate_SOURCES = Profile1D/P1DCreate.cc testprofile1Dfill_SOURCES = Profile1D/P1DFill.cc testprofile1Dmodify_SOURCES = Profile1D/P1DModify.cc +# testhisto2De_SOURCES = TestHisto2Derase.cc testhisto2Dcreate_SOURCES = Histo2D/H2DCreate.cc testhisto2Dfill_SOURCES = Histo2D/H2DFill.cc testhisto2Dmodify_SOURCES = Histo2D/H2DModify.cc testscatter2Dcreate_SOURCES = Scatter2D/S2DCreate.cc testscatter2Dmodify_SOURCES = Scatter2D/S2DModify.cc -testscatter3Dcreate_SOURCES = Scatter3D/S3DCreate.cc -testscatter3Dmodify_SOURCES = Scatter3D/S3DModify.cc +# testpoint3D_SOURCES = TestPoint3D.cc +# testscatter3D_SOURCES = TestScatter3D.cc +# testscatter3Dcreate_SOURCES = Scatter3D/S3DCreate.cc +# testscatter3Dmodify_SOURCES = Scatter3D/S3DModify.cc # TODO: Search paths are still not complete for the Python tests: need to add the lib.linux-i686-2.7 part to PYTHONPATH @@ -65,16 +60,16 @@ testhisto1Dmodify \ testprofile1Dcreate \ testprofile1Dfill \ - testprofile1Dmodify\ - testscatter2Dcreate\ - testscatter2Dmodify\ + testprofile1Dmodify \ + testscatter2Dcreate \ + testscatter2Dmodify \ + testhisto2Dcreate \ test-yoda-1.py # testhisto2De \ # testpoint3D \ -# testscatter3D +# testscatter3D -# testhisto2Dcreate \ # testhisto2Dfill\ # testhisto2Dmodify Modified: trunk/tests/test-yoda-1.py ============================================================================== --- trunk/tests/test-yoda-1.py Wed Jul 4 01:55:30 2012 (r488) +++ trunk/tests/test-yoda-1.py Wed Jul 4 02:19:45 2012 (r489) @@ -1,14 +1,17 @@ #! /usr/bin/env python import yoda -import unittest -class TestReader(unittest.TestCase): - def setUp(self): - print "Set Up" +print "WE NEED SOME REAL WORLD YODA PYTHON EXAMPLES AS TESTS!" - def test_reader(self): - reader = yoda.ReaderAIDA() +# import unittest -if __name__=='__main__': - unittest.main() +# class TestReader(unittest.TestCase): +# def setUp(self): +# print "Unit test setup" + +# def test_reader(self): +# reader = yoda.ReaderAIDA() + +# if __name__=='__main__': +# unittest.main()
More information about the yoda-svn mailing list |