- added resize(0) for subGraph data boxes (potential bug fixed)
authorAnatoly <Titov_AI@pnpi.nrcki.ru>
Wed, 29 Jul 2020 11:18:11 +0000 (14:18 +0300)
committerAnatoly <Titov_AI@pnpi.nrcki.ru>
Wed, 29 Jul 2020 11:18:11 +0000 (14:18 +0300)
- minor tests touches

src/corrtype.cpp
src/spacetimecorrtests.cpp

index feafe11fc1d725ba5c9bd874281b9945bc14a925..467deb6b548d42e78f5b594cd7451b88112fa3aa 100644 (file)
@@ -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));
     }
index c50c30697fa3dd415d2f48fbf3ace20dfbdf7ed1..707e53b89a1fffaf39430dddbc515c59411bfdce 100644 (file)
 #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;