Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve coverage isdb #1144

Open
wants to merge 7 commits into
base: v2.9
Choose a base branch
from

Conversation

Mertcan-Puncist
Copy link
Contributor

Description

this pull request focuses on enhancing the coverage test result for the isdb/metainference

1- regtest/isdb/rt-caliber-negres-zero

i coppyed this original test

  • rt-caliber

modified and name it

  • rt-caliber-negres-zero

to cover:

  • isdb/Caliber.cpp

covered isdb/Caliber.cpp lines|

 165           0 :     doregres_zero_=true;
 166           0 :     log.printf("  doing regression with zero intercept with stride: %d\n", nregres_zero_);

 225           4 :   if(doregres_zero_) {
 226           0 :     addComponent("scale");
 227           0 :     componentIsNotPeriodic("scale");
 228           0 :     valueScale=getPntrToComponent("scale");

2- regtest/isdb/rt-Metainference-averaging

i coppyed this original test

  • rt-jcouplings-mi

modified and name it

  • rt-Metainference-averaging

to cover:

  • isdb/Metainference.cpp

covered isdb/Metainference.cpp lines|

 410           0 :     average_weights_stride_ = averaging;
 411           0 :     optsigmamean_stride_    = averaging;

3- regtest/isdb/rt-coverage-EMMI-TEMP

i coppyed this original test

  • rt-emmi-gauss-mpi

modified and name it

  • rt-coverage-EMMI-TEMP

to cover:

  • isdb/EMMI.cpp

covered isdb/EMMI.cpp lines|

 513           0 :   else kbt_=plumed.getAtoms().getKbT();

4- regtest/isdb/rt-coverage-EMMI-anneal-fact

i coppyed this original test

  • rt-emmi-gauss-mpi

modified and name it

  • rt-coverage-EMMI-anneal-fact

to cover:

  • isdb/EMMI.cpp

covered isdb/EMMI.cpp lines|

 622           0 :     log.printf("  length of annealing cycle : %u\n",nanneal_);
 623           0 :     log.printf("  annealing factor : %f\n",kanneal_);

1596           0 :     anneal_ = get_annealing(step);
1597           0 :     getPntrToComponent("anneal")->set(anneal_);

5- regtest/isdb/rt-coverage-EMMI-ovstride

i coppyed this original test

  • rt-emmi-gauss-mpi

modified and name it

  • rt-coverage-EMMI-ovstride

to cover:

  • isdb/EMMI.cpp

covered isdb/EMMI.cpp lines|

 626           0 :     log.printf("  stride for writing model overlaps : %u\n",ovstride_);
 627           0 :     log.printf("  file for writing model overlaps : %s\n", ovfilename_.c_str());

6- regtest/isdb/rt-jcoupling-string-type

i coppyed this original test

  • rt-jcouplings-mi

modified and name it

  • rt-jcoupling-string-type

to cover:

  • isdb/Jcoupling.cpp

covered isdb/Jcoupling.cpp lines|

 173           0 :   } else if(string_type == "CUSTOM") {

7- regtest/isdb/rt-metainference-likelihood

i coppyed this original test

  • rt-noe-mi

modified and name it

  • rt-metainference-likelihood

to cover:

  • isdb/Metainference.cpp

covered isdb/Metainference.cpp lines|

 445           0 :     else if(stringa_like=="LOGN") gen_likelihood_ = LIKE_LOGN;

 726           0 :     else if(gen_likelihood_==LIKE_LOGN) log.printf(" and a log-normal likelihood\n");

8- regtest/isdb/rt-metainference-mc-chunksize

i coppyed this original test

  • rt-jcouplings-mi

modified and name it

  • rt-metainference-mc-chunksize

to cover:

  • isdb/Metainference.cpp

covered isdb/Metainference.cpp lines|

1185           0 :     if ((MCchunksize_ * i) >= sigma_.size()) {

1289           0 :       for (unsigned j=0; j<sigma_.size(); j++) {
1290           0 :         indices.push_back(j);

9- regtest/isdb/rt-metainference-optisigmamean-sem-max

i coppyed this original test

  • rt-jcouplings-mi

modified and name it

  • rt-metainference-optisigmamean-sem-max

to cover:

  • isdb/Metainference.cpp

covered isdb/Metainference.cpp lines|

 461           0 :   else if(stringa_optsigma=="SEM_MAX")  do_optsigmamean_=2;

1581         178 :   if(do_optsigmamean_>0) {
1582             :     // remove first entry of the history std::vector
1583           0 :     if(sigma_mean2_last_[iselect][0].size()==optsigmamean_stride_&&optsigmamean_stride_>0)
1584           0 :       for(unsigned i=0; i<narg; ++i) sigma_mean2_last_[iselect][i].erase(sigma_mean2_last_[iselect][i].begin());
1585             :     /* this is the current estimate of sigma mean for each argument
1586             :        there is one of this per argument in any case  because it is
1587             :        the maximum among these to be used in case of GAUSS/OUTLIER */
1588           0 :     std::vector<double> sigma_mean2_now(narg,0);
1589           0 :     if(master) {
1590           0 :       for(unsigned i=0; i<narg; ++i) sigma_mean2_now[i] = weight*(getArgument(i)-mean[i])*(getArgument(i)-mean[i]);
1591           0 :       if(nrep_>1) multi_sim_comm.Sum(&sigma_mean2_now[0], narg);
1592             :     }
1593           0 :     comm.Sum(&sigma_mean2_now[0], narg);
1594           0 :     for(unsigned i=0; i<narg; ++i) sigma_mean2_now[i] *= 1.0/(neff-1.)/norm;
1595             : 
1596             :     // add sigma_mean2 to history
1597           0 :     if(optsigmamean_stride_>0) {
1598           0 :       for(unsigned i=0; i<narg; ++i) sigma_mean2_last_[iselect][i].push_back(sigma_mean2_now[i]);
1599             :     } else {
1600           0 :       for(unsigned i=0; i<narg; ++i) if(sigma_mean2_now[i] > sigma_mean2_last_[iselect][i][0]) sigma_mean2_last_[iselect][i][0] = sigma_mean2_now[i];
1601             :     }
1602             : 
1603           0 :     if(noise_type_==MGAUSS||noise_type_==MOUTLIERS||noise_type_==GENERIC) {
1604           0 :       for(unsigned i=0; i<narg; ++i) {
1605             :         /* set to the maximum in history std::vector */
1606           0 :         sigma_mean2_tmp[i] = *max_element(sigma_mean2_last_[iselect][i].begin(), sigma_mean2_last_[iselect][i].end());
1607             :         /* the standard error of the mean */
1608           0 :         valueSigmaMean[i]->set(std::sqrt(sigma_mean2_tmp[i]));
1609           0 :         if(noise_type_==GENERIC) {
1610           0 :           sigma_min_[i] = std::sqrt(sigma_mean2_tmp[i]);
1611           0 :           if(sigma_[i] < sigma_min_[i]) sigma_[i] = sigma_min_[i];
1612             :         }
1613             :       }
1614           0 :     } else if(noise_type_==GAUSS||noise_type_==OUTLIERS) {
1615             :       // find maximum for each data point
1616             :       std::vector <double> max_values;
1617           0 :       for(unsigned i=0; i<narg; ++i) max_values.push_back(*max_element(sigma_mean2_last_[iselect][i].begin(), sigma_mean2_last_[iselect][i].end()));
1618             :       // find maximum across data points
1619           0 :       const double max_now = *max_element(max_values.begin(), max_values.end());
1620             :       // set new value
1621           0 :       sigma_mean2_tmp[0] = max_now;
1622           0 :       valueSigmaMean[0]->set(std::sqrt(sigma_mean2_tmp[0]));
1623             :     }
1624             :     // endif sigma mean optimization
1625             :     // start sigma max optimization
1626           0 :     if(do_optsigmamean_>1&&!sigmamax_opt_done_) {
1627           0 :       for(unsigned i=0; i<sigma_max_.size(); i++) {
1628           0 :         if(sigma_max_est_[i]<sigma_mean2_tmp[i]&&optimized_step_>optsigmamean_stride_) sigma_max_est_[i]=sigma_mean2_tmp[i];
1629             :         // ready to set once and for all the value of sigma_max
1630           0 :         if(optimized_step_==N_optimized_step_) {
1631           0 :           sigmamax_opt_done_=true;
1632           0 :           for(unsigned i=0; i<sigma_max_.size(); i++) {
1633           0 :             sigma_max_[i]=std::sqrt(sigma_max_est_[i]*dnrep);
1634           0 :             Dsigma_[i] = 0.05*(sigma_max_[i] - sigma_min_[i]);
1635           0 :             if(sigma_[i]>sigma_max_[i]) sigma_[i]=sigma_max_[i];
1636             :           }
1637             :         }
1638             :       }
1639           0 :       optimized_step_++;

10- regtest/isdb/rt-metainference-optisigmamean-sem

i coppyed this original test

  • rt-jcouplings-mi

modified and name it

  • rt-metainference-optisigmamean-sem

to cover:

  • isdb/Metainference.cpp

covered isdb/Metainference.cpp lines|

 460           0 :   else if(stringa_optsigma=="SEM")  do_optsigmamean_=1;

1581         178 :   if(do_optsigmamean_>0) {
1582             :     // remove first entry of the history std::vector
1583           0 :     if(sigma_mean2_last_[iselect][0].size()==optsigmamean_stride_&&optsigmamean_stride_>0)
1584           0 :       for(unsigned i=0; i<narg; ++i) sigma_mean2_last_[iselect][i].erase(sigma_mean2_last_[iselect][i].begin());
1585             :     /* this is the current estimate of sigma mean for each argument
1586             :        there is one of this per argument in any case  because it is
1587             :        the maximum among these to be used in case of GAUSS/OUTLIER */
1588           0 :     std::vector<double> sigma_mean2_now(narg,0);
1589           0 :     if(master) {
1590           0 :       for(unsigned i=0; i<narg; ++i) sigma_mean2_now[i] = weight*(getArgument(i)-mean[i])*(getArgument(i)-mean[i]);
1591           0 :       if(nrep_>1) multi_sim_comm.Sum(&sigma_mean2_now[0], narg);
1592             :     }
1593           0 :     comm.Sum(&sigma_mean2_now[0], narg);
1594           0 :     for(unsigned i=0; i<narg; ++i) sigma_mean2_now[i] *= 1.0/(neff-1.)/norm;
1595             : 
1596             :     // add sigma_mean2 to history
1597           0 :     if(optsigmamean_stride_>0) {
1598           0 :       for(unsigned i=0; i<narg; ++i) sigma_mean2_last_[iselect][i].push_back(sigma_mean2_now[i]);
1599             :     } else {
1600           0 :       for(unsigned i=0; i<narg; ++i) if(sigma_mean2_now[i] > sigma_mean2_last_[iselect][i][0]) sigma_mean2_last_[iselect][i][0] = sigma_mean2_now[i];
1601             :     }
1602             : 
1603           0 :     if(noise_type_==MGAUSS||noise_type_==MOUTLIERS||noise_type_==GENERIC) {
1604           0 :       for(unsigned i=0; i<narg; ++i) {
1605             :         /* set to the maximum in history std::vector */
1606           0 :         sigma_mean2_tmp[i] = *max_element(sigma_mean2_last_[iselect][i].begin(), sigma_mean2_last_[iselect][i].end());
1607             :         /* the standard error of the mean */
1608           0 :         valueSigmaMean[i]->set(std::sqrt(sigma_mean2_tmp[i]));
1609           0 :         if(noise_type_==GENERIC) {
1610           0 :           sigma_min_[i] = std::sqrt(sigma_mean2_tmp[i]);
1611           0 :           if(sigma_[i] < sigma_min_[i]) sigma_[i] = sigma_min_[i];
1612             :         }
1613             :       }
1614           0 :     } else if(noise_type_==GAUSS||noise_type_==OUTLIERS) {
1615             :       // find maximum for each data point
1616             :       std::vector <double> max_values;
1617           0 :       for(unsigned i=0; i<narg; ++i) max_values.push_back(*max_element(sigma_mean2_last_[iselect][i].begin(), sigma_mean2_last_[iselect][i].end()));
1618             :       // find maximum across data points
1619           0 :       const double max_now = *max_element(max_values.begin(), max_values.end());
1620             :       // set new value
1621           0 :       sigma_mean2_tmp[0] = max_now;
1622           0 :       valueSigmaMean[0]->set(std::sqrt(sigma_mean2_tmp[0]));
1623             :     }
1624             :     // endif sigma mean optimization
1625             :     // start sigma max optimization
1626           0 :     if(do_optsigmamean_>1&&!sigmamax_opt_done_) {
1627           0 :       for(unsigned i=0; i<sigma_max_.size(); i++) {
1628           0 :         if(sigma_max_est_[i]<sigma_mean2_tmp[i]&&optimized_step_>optsigmamean_stride_) sigma_max_est_[i]=sigma_mean2_tmp[i];
1629             :         // ready to set once and for all the value of sigma_max
1630           0 :         if(optimized_step_==N_optimized_step_) {
1631           0 :           sigmamax_opt_done_=true;
1632           0 :           for(unsigned i=0; i<sigma_max_.size(); i++) {
1633           0 :             sigma_max_[i]=std::sqrt(sigma_max_est_[i]*dnrep);
1634           0 :             Dsigma_[i] = 0.05*(sigma_max_[i] - sigma_min_[i]);
1635           0 :             if(sigma_[i]>sigma_max_[i]) sigma_[i]=sigma_max_[i];
1636             :           }
1637             :         }
1638             :       }
1639           0 :       optimized_step_++;

Note about test 9 and 10 :

These two tests covers the same lines between 1581-1639

11-regtest/isdb/rt-metainference-regres-zero

i coppyed this original test

  • rt-jcouplings-mi

modified and name it

  • rt-metainference-regres-zero

to cover:

  • isdb/Metainference.cpp

covered isdb/Metainference.cpp lines|

 547           0 :     doregres_zero_=true;
 548             :     // check if already sampling scale and offset
 549           0 :     if(doscale_)  error("REGRES_ZERO and SCALEDATA are mutually exclusive");
 550           0 :     if(dooffset_) error("REGRES_ZERO and ADDOFFSET are mutually exclusive");

 790           0 :     log.printf("  doing regression with zero intercept with stride: %d\n", nregres_zero_);

12- regtest/isdb/rt-metainferencebase-averaging

i coppyed this original test:

  • rt-jcouplings-mi

modified and name it:

  • rt-metainferencebase-averaging

to cover:

  • isdb/MetainferenceBase.cpp

covered isdb/MetainferenceBase.cpp lines|

 168           0 :     decay_w_ = 1./static_cast<double> (averaging);
 169           0 :     optsigmamean_stride_ = averaging;

1365          84 :     if(optsigmamean_stride_>0) {
1366           0 :       for(unsigned i=0; i<narg; ++i) sigma_mean2_last_[iselect][i].push_back(sigma_mean2_now[i]);

13- regtest/isdb/rt-metainferencebase-likelihood

i coppyed this original test:

  • rt-noe-mi

modified and name it:

  • rt-metainferencebase-likelihood

to cover:

  • isdb/MetainferenceBase.cpp

covered isdb/MetainferenceBase.cpp lines|

 185           0 :     else if(stringa_like=="LOGN") gen_likelihood_ = LIKE_LOGN;

 587           0 :     else if(gen_likelihood_==LIKE_LOGN) log.printf(" and a log-normal likelihood\n");

14- regtest/isdb/rt-metainferencebase-regres-zero

i coppyed this original test:

  • rt-jcouplings-mi

modified and name it:

  • rt-metainferencebase-regres-zero

to cover:

  • isdb/MetainferenceBase.cpp

covered isdb/MetainferenceBase.cpp lines|

 274           0 :     doregres_zero_=true;

 650          31 :   if(doregres_zero_)
 651           0 :     log.printf("  doing regression with zero intercept with stride: %d\n", nregres_zero_);

15- regtest/isdb/rt-metainferencebase-sem-max

i coppyed this original test:

  • rt-jcouplings-mi

modified and name it:

  • rt-metainferencebase-sem-max

to cover:

  • isdb/MetainferenceBase.cpp

covered isdb/MetainferenceBase.cpp lines|

 200           0 :   else if(stringa_optsigma=="SEM_MAX")  do_optsigmamean_=2;
Target release

I would like my code to appear in release v2.9

Type of contribution
  • changes to code or doc authored by PLUMED developers, or additions of code in the core or within the default modules
  • changes to a module not authored by you
  • new module contribution or edit of a module authored by you
Copyright
  • I agree to transfer the copyright of the code I have written to the PLUMED developers or to the author of the code I am modifying.
  • the module I added or modified contains a COPYRIGHT file with the correct license information. Code should be released under an open source license. I also used the command cd src && ./header.sh mymodulename in order to make sure the headers of the module are correct.
Tests
  • I added a new regtest or modified an existing regtest to validate my changes.
  • I verified that all regtests are passed successfully on GitHub Actions.

@Iximiel
Copy link
Member

Iximiel commented Oct 21, 2024

Before going down in particular (I think someone like @carlocamilloni or @GiovanniBussi should be better than me at commenting on the scientific side of the tests)

I took your comment and ran diff on all the couples of directories you listed.

Output in spoiler

Using diffstat to produce a readable report:

  • diff rt-caliber rt-caliber-negres-zero | diffstat
 allforce.0.reference |62712 +++++++++++++++++++++++++--------------------------
 plumed.dat           |    1 
 2 files changed, 31357 insertions(+), 31356 deletions(-)
  • diff rt-jcouplings-mi rt-Metainference-averaging | diffstat
 plumed.dat |    1 +
 report.txt |only
 tmp        |only
 3 files changed, 1 insertion(+)
  • diff rt-emmi-gauss-mpi rt-coverage-EMMI-TEMP | diffstat
 COLVAR.reference |    2 
 deriva.reference |  412 +++++++++++++++++++++++++++----------------------------
 plumed.dat       |    2 
 3 files changed, 208 insertions(+), 208 deletions(-)
  • diff rt-emmi-gauss-mpi rt-coverage-EMMI-anneal-fact | diffstat
 plumed.dat |    2 ++
 1 file changed, 2 insertions(+)
  • diff rt-emmi-gauss-mpi rt-coverage-EMMI-ovstride | diffstat
 plumed.dat |    2 ++
 1 file changed, 2 insertions(+)
  • diff rt-jcouplings-mi rt-jcoupling-string-type | diffstat
 atom_forces.reference |  276 +++++++++++++++++++++++++-------------------------
 miorig.reference      |   12 +-
 plumed.dat            |    2 
 3 files changed, 145 insertions(+), 145 deletions(-)
  • diff rt-noe-mi rt-metainference-likelihood | diffstat
 COLVAR.reference |   24 ++++++++++++------------
 plumed.dat       |    1 +
 2 files changed, 13 insertions(+), 12 deletions(-)
  • diff rt-jcouplings-mi rt-metainference-mc-chunksize | diffstat
 plumed.dat |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  • diff rt-jcouplings-mi rt-metainference-optisigmamean-sem-max | diffstat
 plumed.dat |    1 +
 1 file changed, 1 insertion(+)
  • diff rt-jcouplings-mi rt-metainference-optisigmamean-sem | diffstat
 plumed.dat |    1 +
 1 file changed, 1 insertion(+)
  • diff rt-jcouplings-mi rt-metainference-regres-zero | diffstat
 MISTATUSmij.reference |    2 
 atom_forces.reference |  274 +++++++++++++++++++++++++-------------------------
 miorig.reference      |   14 +-
 plumed.dat            |    3 
 4 files changed, 147 insertions(+), 146 deletions(-)
  • diff rt-jcouplings-mi rt-metainferencebase-averaging | diffstat
 plumed.dat |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
  • diff rt-noe-mi rt-metainferencebase-likelihood | diffstat
 COLVAR.reference |   24 ++++++++++++------------
 plumed.dat       |    1 +
 2 files changed, 13 insertions(+), 12 deletions(-)
  • diff rt-jcouplings-mi rt-metainferencebase-regres-zero | diffstat
 plumed.dat |    2 ++
 1 file changed, 2 insertions(+)
  • diff rt-jcouplings-mi rt-metainferencebase-sem-max | diffstat
 plumed.dat |    2 ++
 1 file changed, 2 insertions(+)

in rt-Metainference-averaging you accidentally pushed tmp and the report.txt

For some tests there is no difference between the original one and the modified one:

  • rt-emmi-gauss-mpi rt-coverage-EMMI-anneal-fact
  • rt-emmi-gauss-mpi rt-coverage-EMMI-ovstride
  • rt-jcouplings-mi rt-metainference-mc-chunksize
  • rt-jcouplings-mi rt-metainference-optisigmamean-sem-max
  • rt-jcouplings-mi rt-metainference-optisigmamean-sem
  • rt-jcouplings-mi rt-metainferencebase-averaging
  • rt-jcouplings-mi rt-metainferencebase-regres-zero
  • rt-jcouplings-mi rt-metainferencebase-sem-max
  • rt-jcouplings-mi rt-Metainference-averaging

This means that the test is passing through those lines (since the coverage is improving) but there is no proof of that happening in the output, we should either rethink the new tests or add some extra output references.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants