Ignore:
Timestamp:
Nov 8, 2012, 1:13:53 PM (12 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, 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_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
9fd889
Parents:
cf18c5
git-author:
Frederik Heber <heber@…> (07/27/12 15:49:06)
git-committer:
Frederik Heber <heber@…> (11/08/12 13:13:53)
Message:

Changed Histogram's cstor to take offset and binwidth instead of CountBins.

  • CountBins was nonsense anyway, could have been taken from samples.size() as well.
  • with these two values, we may also add the samples lateron.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Histogram/unittests/HistogramUnitTest.cpp

    rcf18c5 r6bed1f  
    8484  sampled_values += 1.,2.,3.,4.;
    8585  CPPUNIT_ASSERT_EQUAL( (size_t)4, sampled_values.size() );
    86   histogram = new Histogram(sampled_values, 4);
     86  histogram = new Histogram(sampled_values, 1., 1.);
    8787  CPPUNIT_ASSERT_EQUAL( (size_t)4+1, histogram->bins.size() );
    8888  CPPUNIT_ASSERT( histogram->bins.end() != histogram->bins.begin() );
     
    9999  sampled_values += 1.,2.,3.,4.;
    100100  CPPUNIT_ASSERT_EQUAL( (size_t)4, sampled_values.size() );
    101   histogram = new Histogram(sampled_values, 4);
     101  histogram = new Histogram(sampled_values, 1., 1.);
    102102
    103103  // check values inside
     
    133133  sampled_values += 1.,2.,3.,4.;
    134134  CPPUNIT_ASSERT_EQUAL( (size_t)4, sampled_values.size() );
    135   histogram = new Histogram(sampled_values, 4);
     135  histogram = new Histogram(sampled_values, 1., 1.);
    136136
    137137  // check values inside
     
    172172  Histogram::samples_t sampled_values;
    173173  sampled_values += 1.,2.,3.,4.;
    174   histogram = new Histogram(sampled_values, 4);
     174  histogram = new Histogram(sampled_values, 1., 1.);
    175175
    176176  // go through each bin and check against getLowerEnd()
     
    189189void HistogramTest::isEmpty_Test()
    190190{
    191   histogram = new Histogram(std::vector<double>());
     191  histogram = new Histogram(1., 1.);
    192192  // test on empty histogramgram
    193193  CPPUNIT_ASSERT( histogram->isEmpty() );
     
    197197  sampled_values += 1.,2.,3.,4.;
    198198  delete histogram;
    199   histogram = new Histogram(sampled_values, 4);
     199  histogram = new Histogram(sampled_values, 1., 1.);
    200200  CPPUNIT_ASSERT( !histogram->isEmpty() );
    201201
     
    206206void HistogramTest::areaTest()
    207207{
    208   histogram = new Histogram(std::vector<double>());
     208  histogram = new Histogram(1., 1.);
    209209  // test on empty histogramgram
    210210  CPPUNIT_ASSERT_EQUAL( 0., histogram->area() );
     
    214214  sampled_values += 1.,2.,3.,4., 4.;
    215215  delete histogram;
    216   histogram = new Histogram(sampled_values, 4);
     216  histogram = new Histogram(sampled_values, 1., 1.);
    217217  CPPUNIT_ASSERT_EQUAL( 5., histogram->area() );
    218218  Histogram::samples_t more_values;
    219219  more_values += 1.75,2.5,3.;
    220   Histogram otherhistogram(more_values, 3);
     220  Histogram otherhistogram(more_values, 1.75, .625);
    221221  CPPUNIT_ASSERT_EQUAL( 3., otherhistogram.area() );
    222222
     
    230230  Histogram::samples_t sampled_values;
    231231  sampled_values += 1.,2.,3.,4.;
    232   histogram = new Histogram(sampled_values, 4);
     232  histogram = new Histogram(sampled_values, 1., 1.);
    233233  Histogram::samples_t more_values;
    234234  more_values += 1.75,2.5,3.;
    235   Histogram otherhistogram(more_values, 3);
     235  Histogram otherhistogram(more_values, 1.75, .625);
    236236
    237237  // check that size increases
     
    252252  Histogram::samples_t sampled_values;
    253253  sampled_values += 1.,2.,3.,4.;
    254   histogram = new Histogram(sampled_values, 4);
     254  histogram = new Histogram(sampled_values, 1., 1.);
    255255
    256256  // add upon larger
     
    258258    Histogram::samples_t more_values;
    259259    more_values += 0.5, 1.25, 2.5,3., 4.2;
    260     Histogram otherhistogram(more_values, 5);
     260    Histogram otherhistogram(more_values, 0.5, .625);
    261261    const double areas = histogram->area() + otherhistogram.area();
    262262
     
    271271    Histogram::samples_t more_values;
    272272    more_values += 1.75,2.5,3.;
    273     Histogram otherhistogram(more_values, 3);
     273    Histogram otherhistogram(more_values, 1.75, .625);
    274274    const double areas = histogram->area() + otherhistogram.area();
    275275
     
    288288  Histogram::samples_t sampled_values;
    289289  sampled_values += 1.,2.,3.,4.;
    290   histogram = new Histogram(sampled_values, 4);
     290  histogram = new Histogram(sampled_values, 1., 1.);
    291291
    292292  // subtract smaller
    293293  {
    294294    Histogram::samples_t more_values;
    295     more_values += 1.75,2.5,3.;
    296     Histogram otherhistogram(more_values, 3);
     295    more_values += 0.5, 1.25, 2.5,3., 4.2;
     296    Histogram otherhistogram(more_values, 0.5, .625);
    297297    const double difference = otherhistogram.area() - histogram->area();
    298298
     
    306306  {
    307307    Histogram::samples_t more_values;
    308     more_values += 0.5, 1.25, 2.5,3., 4.2;
    309     Histogram otherhistogram(more_values, 5);
     308    more_values += 1.75,2.5,3.;
     309    Histogram otherhistogram(more_values, 1.75, .625);
    310310    const double difference = otherhistogram.area() - histogram->area();
    311311
Note: See TracChangeset for help on using the changeset viewer.