Program: 131263
Project: 131263
Buggy source:
/** 
 * Commenting out lines 80 and 83 in FastDepParseFeatureExtractor allows this test to (correctly) pass. // FastDepParseFe.add2ndOrderSiblingFeats(isent, f2.i, f2.j, f2.k, feats); // FastDepParseFe.add2ndOrderGrandparentFeats(isent, f2.k, f2.i, f2.j, feats); This compares the behavior a first-order model and a second-order model where the second order model has  some extra "dummy" factors that are only multiplying in the value 1.
 */
public void testEqualMarginalsAndParentsFirstVsSecondOrder(){
  AnnoSentenceCollection sents=AnnoSentenceReaderSpeedTest.readPtbYmConllx();
  int numParams=1000000;
  FgModel model=new FgModel(numParams);
  model.setRandomStandardNormal();
  CorpusStatistics cs=new CorpusStatistics(new CorpusStatisticsPrm());
  cs.init(sents);
  FeatureNames alphabet=new FeatureNames();
  boolean onlyFast=true;
  int s=0;
  int n=0;
  Timer t=new Timer();
  t.start();
  for (  AnnoSentence sent : sents) {
    FactorGraph fg1, fg2;
    ErmaBp bp1, bp2;
    int[] parents1, parents2;
{
      UFgExample ex=DepParseFactorGraphBuilderSpeedTest.get1stOrderFg(sent,cs,alphabet,numParams,onlyFast);
      fg1=ex.getFgLatPred();
      fg1.updateFromModel(model);
      bp1=DepParseInferenceSpeedTest.runBp(fg1);
      DepParseDecoder decode=new DepParseDecoder();
      parents1=decode.decode(bp1,ex,sent);
    }
{
      UFgExample ex=get2ndOrderFg(sent,cs,alphabet,numParams,onlyFast);
      fg2=ex.getFgLatPred();
      fg2.updateFromModel(model);
      bp2=DepParseInferenceSpeedTest.runBp(fg2);
      DepParseDecoder decode=new DepParseDecoder();
      parents2=decode.decode(bp2,ex,sent);
    }
    assertEqualMarginals(fg1,bp1,fg2,bp2,1e-7);
    assertArrayEquals(parents1,parents2);
    n+=sent.size();
    if (s++ % 1 == 0) {
      t.stop();
      System.out.println(String.format("String_Node_Str",s,n,n / t.totSec()));
      t.start();
    }
    if (s > 102) {
      break;
    }
  }
  t.stop();
  System.out.println("String_Node_Str" + t.totSec());
  System.out.println("String_Node_Str" + (sents.getNumTokens() / t.totSec()));
}

Fixed version (ground truth):
/** 
 * Commenting out lines 80 and 83 in   {@link FastDepParseFeatureExtractor} allows this test to (correctly) pass.// FastDepParseFe.add2ndOrderSiblingFeats(isent, f2.i, f2.j, f2.k, feats); // FastDepParseFe.add2ndOrderGrandparentFeats(isent, f2.k, f2.i, f2.j, feats); This compares the behavior a first-order model and a second-order model where the second order model has  some extra "dummy" factors that are only multiplying in the value 1. Errors: marginals=6 parents=0
 */
@Test public void testEqualMarginalsAndParentsFirstVsSecondOrder(){
  AnnoSentenceCollection sents=AnnoSentenceReaderSpeedTest.readPtbYmConllx();
  int numParams=1000000;
  FgModel model=new FgModel(numParams);
  model.setRandomStandardNormal();
  CorpusStatistics cs=new CorpusStatistics(new CorpusStatisticsPrm());
  cs.init(sents);
  FeatureNames alphabet=new FeatureNames();
  boolean onlyFast=true;
  int numSentsWithDiffMargs=0;
  int numSentsWithDiffParents=0;
  int s=0;
  int n=0;
  Timer t=new Timer();
  t.start();
  for (  AnnoSentence sent : sents) {
    if (sent.size() > 10) {
      continue;
    }
    FactorGraph fg1, fg2;
    ErmaBp bp1, bp2;
    int[] parents1, parents2;
{
      UFgExample ex=DepParseFactorGraphBuilderSpeedTest.get1stOrderFg(sent,cs,alphabet,numParams,onlyFast);
      fg1=ex.getFgLatPred();
      fg1.updateFromModel(model);
      bp1=DepParseInferenceSpeedTest.runBp(fg1);
      DepParseDecoder decode=new DepParseDecoder();
      parents1=decode.decode(bp1,ex,sent);
    }
{
      UFgExample ex=get2ndOrderFg(sent,cs,alphabet,numParams,onlyFast);
      fg2=ex.getFgLatPred();
      fg2.updateFromModel(model);
      bp2=DepParseInferenceSpeedTest.runBp(fg2);
      DepParseDecoder decode=new DepParseDecoder();
      parents2=decode.decode(bp2,ex,sent);
    }
    try {
      assertEqualMarginals(fg1,bp1,fg2,bp2,1e-5);
    }
 catch (    AssertionError e) {
      System.out.println(e.getMessage());
      numSentsWithDiffMargs++;
    }
    try {
      assertArrayEquals(parents1,parents2);
    }
 catch (    AssertionError e) {
      numSentsWithDiffParents++;
    }
    n+=sent.size();
    if (s++ % 1 == 0) {
      t.stop();
      System.out.println(String.format("String_Node_Str",s,n,n / t.totSec()));
      t.start();
    }
    if (s > 102) {
      break;
    }
  }
  t.stop();
  System.out.printf("String_Node_Str",numSentsWithDiffMargs,numSentsWithDiffParents);
  System.out.println("String_Node_Str" + t.totSec());
  System.out.println("String_Node_Str" + (sents.getNumTokens() / t.totSec()));
}