Ignore:
Timestamp:
Nov 4, 2016, 9:37:50 AM (8 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_ChronosMutex, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, GeometryObjects, Gui_displays_atomic_force_velocity, IndependentFragmentGrids_IntegrationTest, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, RotateToPrincipalAxisSystem_UndoRedo, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, ThirdParty_MPQC_rebuilt_buildsystem, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, Ubuntu_1604_changes, stable
Children:
c7aac9
Parents:
16c6f7
git-author:
Frederik Heber <heber@…> (10/02/16 13:59:35)
git-committer:
Frederik Heber <heber@…> (11/04/16 09:37:50)
Message:

REFACTOR: Removed many unused functions from Extractor namespace.

  • TESTFIX: Extractor unit test now only checks on getAllSymmetricDistances().
Location:
src/FunctionApproximation/unittests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/FunctionApproximation/unittests/ExtractorsUnitTest.cpp

    r16c6f7 re47ac7  
    7272}
    7373
    74 /** UnitTest for gatherAllDistanceArguments()
     74/** UnitTest for gatherAllSymmetricDistances()
    7575 */
    76 void ExtractorsTest::gatherAllDistanceArgumentsTest()
     76void ExtractorsTest::gatherAllSymmetricDistancesTest()
    7777{
    7878  // create positions
     
    9090  // create distances
    9191  FunctionModel::arguments_t args =
    92       Extractors::gatherAllDistanceArguments(positions, charges, 0);
    93   CPPUNIT_ASSERT_EQUAL( (size_t)(5*4), args.size() );
     92      Extractors::gatherAllSymmetricDistances(positions, charges, 0);
     93  CPPUNIT_ASSERT_EQUAL( (size_t)(5*4/2), args.size() );
    9494
    9595  // check created args
    96   for (size_t i=0; i< 5*4; ++i)
     96  for (size_t i=0; i< (5*4)/2; ++i)
    9797    CPPUNIT_ASSERT( (args[i].distance >= 0) && (args[i].distance <= 4));
    9898}
    99 
    100 /** UnitTest for gatherPositionsFromFragment()
    101  */
    102 void ExtractorsTest::gatherPositionsFromFragmentTest()
    103 {
    104   // create positions
    105   Fragment::positions_t positions;
    106   Fragment::position_t pos(3, 0.);
    107   for (double i = 0; i < 5; i+=1.) {
    108     pos[0] = i;
    109     positions.push_back(pos);
    110   }
    111 
    112   // create charges
    113   Fragment::charges_t charges;
    114   charges += 6., 6., 1., 1., 1.;
    115 
    116   {
    117     // extract carbon pairs
    118     Fragment::charges_t carbonpair;
    119     carbonpair += 6.,6.;
    120     Fragment::positions_t filtered_positions =
    121         Extractors::gatherPositionsFromFragment(positions, charges, carbonpair);
    122     CPPUNIT_ASSERT_EQUAL( (size_t)2, filtered_positions.size() );
    123   }
    124 
    125   {
    126     // extract hydrogen triple
    127     Fragment::charges_t hydrogentriple;
    128     hydrogentriple += 1.,1.,1.;
    129     Fragment::positions_t filtered_positions =
    130         Extractors::gatherPositionsFromFragment(positions, charges, hydrogentriple);
    131     CPPUNIT_ASSERT_EQUAL( (size_t)3, filtered_positions.size() );
    132   }
    133 }
    134 
    135 /** UnitTest for gatherDistancesFromFragment()
    136  */
    137 void ExtractorsTest::gatherDistancesFromFragmentTest()
    138 {
    139   // create positions
    140   Fragment::positions_t positions;
    141   Fragment::position_t pos(3, 0.);
    142   for (double i = 0; i < 5; i+=1.) {
    143     pos[0] = i;
    144     positions.push_back(pos);
    145   }
    146 
    147   // create charges
    148   Fragment::charges_t charges;
    149   charges += 6., 6., 1., 1., 1.;
    150 
    151   {
    152     // extract carbon pairs
    153     Fragment::charges_t carbonpair;
    154     carbonpair += 6.,6.;
    155     FunctionModel::arguments_t args =
    156         Extractors::gatherDistancesFromFragment(positions, charges, carbonpair, 0);
    157     CPPUNIT_ASSERT_EQUAL( (size_t)1, args.size() );
    158   }
    159 
    160   {
    161     // extract hydrogen triple
    162     Fragment::charges_t hydrogentriple;
    163     hydrogentriple += 1.,1.,1.;
    164     FunctionModel::arguments_t args =
    165         Extractors::gatherDistancesFromFragment(positions, charges, hydrogentriple, 0);
    166     CPPUNIT_ASSERT_EQUAL( (size_t)3, args.size() );
    167   }
    168 }
    169 
    170 /** UnitTest for reorderArgumentsByIncreasingDistance()
    171  */
    172 void ExtractorsTest::reorderArgumentsByIncreasingDistanceTest()
    173 {
    174   // prepare some arguments
    175   FunctionModel::arguments_t args;
    176   argument_t arg;
    177   arg.distance = 0.1;
    178   args.push_back(arg);
    179   arg.distance = 0.9;
    180   args.push_back(arg);
    181   arg.distance = 0.3;
    182   args.push_back(arg);
    183   CPPUNIT_ASSERT_EQUAL( (size_t)3, args.size() );
    184   FunctionModel::list_of_arguments_t listargs(1, args);
    185 
    186   // reorder
    187   FunctionModel::list_of_arguments_t listargs_sorted =
    188       Extractors::reorderArgumentsByIncreasingDistance(listargs);
    189   CPPUNIT_ASSERT_EQUAL( (size_t)1, listargs_sorted.size() );
    190   FunctionModel::arguments_t args_sorted = *(listargs_sorted.begin());
    191   CPPUNIT_ASSERT_EQUAL( (size_t)3, args_sorted.size() );
    192   CPPUNIT_ASSERT_EQUAL( args[0].distance, args_sorted[0].distance );
    193   CPPUNIT_ASSERT_EQUAL( args[1].distance, args_sorted[2].distance );
    194   CPPUNIT_ASSERT_EQUAL( args[2].distance, args_sorted[1].distance );
    195 }
  • src/FunctionApproximation/unittests/ExtractorsUnitTest.hpp

    r16c6f7 re47ac7  
    2222{
    2323    CPPUNIT_TEST_SUITE( ExtractorsTest) ;
    24     CPPUNIT_TEST ( gatherAllDistanceArgumentsTest );
    25     CPPUNIT_TEST ( reorderArgumentsByIncreasingDistanceTest );
    26     CPPUNIT_TEST ( gatherPositionsFromFragmentTest );
    27     CPPUNIT_TEST ( gatherDistancesFromFragmentTest );
     24    CPPUNIT_TEST ( gatherAllSymmetricDistancesTest );
    2825    CPPUNIT_TEST_SUITE_END();
    2926
     
    3128      void setUp();
    3229      void tearDown();
    33       void gatherAllDistanceArgumentsTest();
    34       void reorderArgumentsByIncreasingDistanceTest();
    35       void gatherPositionsFromFragmentTest();
    36       void gatherDistancesFromFragmentTest();
     30      void gatherAllSymmetricDistancesTest();
    3731
    3832private:
Note: See TracChangeset for help on using the changeset viewer.