From 454ab58aebf592ef28d740cc90d05dbca3aabbe1 Mon Sep 17 00:00:00 2001 From: Anatoly Date: Wed, 29 Jul 2020 14:18:11 +0300 Subject: [PATCH] - added resize(0) for subGraph data boxes (potential bug fixed) - minor tests touches --- src/corrtype.cpp | 2 ++ src/spacetimecorrtests.cpp | 59 ++++++++++++++++++++++++++++++++------ 2 files changed, 53 insertions(+), 8 deletions(-) diff --git a/src/corrtype.cpp b/src/corrtype.cpp index feafe11..467deb6 100644 --- a/src/corrtype.cpp +++ b/src/corrtype.cpp @@ -193,6 +193,8 @@ void correlationType::correlationEval() { void correlationType::graphCalculations(unsigned int tauStart, unsigned int tauEnd) { graph.resize(0); graph.resize(index.size()); + subGraphPoints.resize(0); + subGraphRbr.resize(0); for (unsigned int i = 0; i < index.size(); i++) { graph[i].resize(index.size(), std::make_pair(0, -1)); } diff --git a/src/spacetimecorrtests.cpp b/src/spacetimecorrtests.cpp index c50c306..707e53b 100644 --- a/src/spacetimecorrtests.cpp +++ b/src/spacetimecorrtests.cpp @@ -10,17 +10,30 @@ #include "newfit.h" #include "corrtype.h" +void trajectoryPartitionRoutine(int ndxSz, std::vector< std::vector < std::vector < unsigned int > > > sls, std::vector< int > &tstFlgs) { + tstFlgs.resize(0); + tstFlgs.resize(ndxSz, 0); + for (unsigned int i0 = 0; i0 < sls.size(); i0++) { + for (unsigned int i1 = 0; i1 < sls[i0].size(); i1++) { + for (unsigned int i2 = 0; i2 < sls[i0][i1].size(); i2++) { + tstFlgs[sls[i0][i1][i2]]++; + } + } + } +} + TEST( corrTests, corrTests_trajectoryPartition ) { - correlationType testCorrs; + correlationType testCorrs; std::vector< RVec > testReference; testReference.resize(0); std::vector< std::vector < std::vector < unsigned int > > > testSels; testSels.resize(0); std::vector< int > testIndex; testIndex.resize(0); - RVec a; a[0] = 1; a[1] = 2; a[2] = 3; - + RVec a(1, 2, 3); + std::vector< int > testFlags; + testFlags.resize(0); testSels.resize(1); testSels[0].resize(1); testSels[0][0].resize(0); @@ -34,7 +47,36 @@ TEST( corrTests, corrTests_trajectoryPartition ) testCorrs.index = testIndex; testCorrs.trajectoryPartition(); - // по аналогии проверить различные варианты дробления молекулы + trajectoryPartitionRoutine(testIndex.size(), testCorrs.selections, testFlags); + for (unsigned int i = 0; i < testFlags.size(); i++) { + ASSERT_EQ(testFlags[i], 1); + } + + testSels[0].resize(0); testSels[0].resize(2); + for (unsigned int i = 0; i < 50; i++) { + testSels[0][0].push_back(i); + testSels[0][1].push_back(i + 50); + } + testCorrs.selections = testSels; + testCorrs.trajectoryPartition(); + trajectoryPartitionRoutine(testIndex.size(), testCorrs.selections, testFlags); + for (unsigned int i = 0; i < testFlags.size(); i++) { + ASSERT_EQ(testFlags[i], 1); + } + + testSels[0].resize(0); testSels[0].resize(2); + for (unsigned int i = 0; i < 50; i++) { + testSels[0][0].push_back(i); + testSels[0][1].push_back(i + 50); + } + testCorrs.selections = testSels; + testCorrs.trajectoryPartition(); + trajectoryPartitionRoutine(testIndex.size(), testCorrs.selections, testFlags); + for (unsigned int i = 0; i < testFlags.size(); i++) { + ASSERT_EQ(testFlags[i], 1); + } + + // по аналогии проверить различные варианты дробления молекулы ??? } TEST( corrTests, corrTests_setDefaults ) @@ -54,10 +96,9 @@ TEST( corrTests, corrTests_setDefaults ) float testCrl_border = 0.5; float testEff_rad = 1.5; std::string testOutPutName = "testString"; - RVec a; a[0] = 1; a[1] = 2; a[2] = 3; + RVec a(1, 2, 3); correlationType testCorrs; - testSels.resize(1); testSels[0].resize(1); testSels[0][0].resize(0); @@ -102,14 +143,16 @@ TEST( corrTests, corrTests_correlationEval ) } } // вычисление корреляционных матриц на основе траектории + // вопрос по функциональности: сейчас происходит вынужденное фитирование траектории что может непредсказуемо сказаться на тестах + // что с этим делать и стоит ли / или стоит оставить как есть но подумать как это проверять } TEST( corrTests, corrTests_graphCalculations ) { std::vector< std::vector< std::vector< double > > > matrixes; - std::vector< std::vector< std::pair< double, int > > > graph; + /*std::vector< std::vector< std::pair< double, int > > > graph; std::vector< std::vector< unsigned int > > subGraphPoints; - std::vector< std::vector< std::pair< unsigned int, unsigned int > > > subGraphRbr; + std::vector< std::vector< std::pair< unsigned int, unsigned int > > > subGraphRbr;*/ std::vector< int > index; std::vector< RVec > reference; -- 2.22.0