nus-yam/ex-repair huggingface dataset:
Program: 21540
Project: 21540
Buggy source:
default String toARFFString(List<Variable> vars){
  StringBuilder builder=new StringBuilder(vars.size() * 2);
  for (int i=0; i < vars.size() - 1; i++) {
    if (vars.get(i).getStateSpace().getStateSpaceType() == StateSpaceType.FINITE_SET) {
      FiniteStateSpace stateSpace=vars.get(i).getStateSpace();
      String nameState=stateSpace.getStatesName((int)this.getValue(vars.get(i)));
      builder.append(nameState + "String_Node_Str");
    }
 else {
      builder.append(this.getValue(vars.get(i)) + "String_Node_Str");
    }
  }
  if (vars.get(vars.size() - 1).getStateSpace().getStateSpaceType() == StateSpaceType.FINITE_SET) {
    FiniteStateSpace stateSpace=vars.get(vars.size() - 1).getStateSpace();
    String nameState=stateSpace.getStatesName((int)this.getValue(vars.get(vars.size() - 1)));
    builder.append(nameState);
  }
 else {
    builder.append(this.getValue(vars.get(vars.size() - 1)));
  }
  return builder.toString();
}

Fixed version (ground truth):
default String toARFFString(List<Variable> vars){
  StringBuilder builder=new StringBuilder(vars.size() * 2);
  for (int i=0; i < vars.size() - 1; i++) {
    if (vars.get(i).getStateSpace().getStateSpaceType() == StateSpaceType.FINITE_SET) {
      FiniteStateSpace stateSpace=vars.get(i).getStateSpace();
      String nameState=stateSpace.getStatesName((int)this.getValue(vars.get(i)));
      builder.append(nameState + "String_Node_Str");
    }
 else     if (vars.get(i).getStateSpace().getStateSpaceType() == StateSpaceType.REAL) {
      builder.append(this.getValue(vars.get(i)) + "String_Node_Str");
    }
 else {
      throw new IllegalArgumentException("String_Node_Str" + vars.get(i).getStateSpace().getStateSpaceType());
    }
  }
  if (vars.get(vars.size() - 1).getStateSpace().getStateSpaceType() == StateSpaceType.FINITE_SET) {
    FiniteStateSpace stateSpace=vars.get(vars.size() - 1).getStateSpace();
    String nameState=stateSpace.getStatesName((int)this.getValue(vars.get(vars.size() - 1)));
    builder.append(nameState);
  }
 else   if (vars.get(vars.size() - 1).getStateSpace().getStateSpaceType() == StateSpaceType.REAL) {
    builder.append(this.getValue(vars.get(vars.size() - 1)));
  }
 else {
    throw new IllegalArgumentException("String_Node_Str" + vars.get(vars.size() - 1).getStateSpace().getStateSpaceType());
  }
  return builder.toString();
}
Program: 21543
Project: 21543
Buggy source:
private void testParents(Variable amidstVar,Node huginVar) throws ExceptionHugin {
  ParentSet parentsAmidstVar=amidstBN.getDAG().getParentSet(amidstVar);
  NodeList parentsHuginVar=huginVar.getParents();
  int numParentsAmidstVar=parentsAmidstVar.getNumberOfParents();
  int numParentsHuginVar=parentsHuginVar.size();
  assertEquals(numParentsAmidstVar,numParentsHuginVar);
  for (int j=0; j < numParentsAmidstVar; j++) {
    Variable parentAmidstVar=parentsAmidstVar.getParents().get(j);
    String parentNameHuginVar=((Node)parentsHuginVar.get(j)).getName();
    String parentNameAmidstVar=parentAmidstVar.getName();
    assertEquals(parentNameAmidstVar,parentNameHuginVar);
  }
}

Fixed version (ground truth):
private void testParents(Variable amidstVar,Node huginVar) throws ExceptionHugin {
  ParentSet parentsAmidstVar=amidstBN.getDAG().getParentSet(amidstVar);
  NodeList parentsHuginVar=huginVar.getParents();
  int numParentsAmidstVar=parentsAmidstVar.getNumberOfParents();
  int numParentsHuginVar=parentsHuginVar.size();
  assertEquals(numParentsAmidstVar,numParentsHuginVar);
  ArrayList<Integer> multinomialParentsIndexes=new ArrayList();
  for (int j=0; j < parentsHuginVar.size(); j++) {
    Node huginParent=parentsHuginVar.get(j);
    if (huginParent.getKind().compareTo(NetworkModel.H_KIND_DISCRETE) == 0) {
      multinomialParentsIndexes.add(j);
    }
  }
  Collections.reverse(multinomialParentsIndexes);
  ArrayList<Integer> parentsIndexes=new ArrayList();
  for (int j=0; j < parentsHuginVar.size(); j++) {
    Node huginParent=parentsHuginVar.get(j);
    if (huginParent.getKind().compareTo(NetworkModel.H_KIND_DISCRETE) == 0) {
      parentsIndexes.add(multinomialParentsIndexes.get(0));
      multinomialParentsIndexes.remove(0);
    }
 else {
      parentsIndexes.add(j);
    }
  }
  for (int j=0; j < numParentsAmidstVar; j++) {
    Variable parentAmidstVar=parentsAmidstVar.getParents().get(j);
    String parentNameHuginVar=((Node)parentsHuginVar.get(parentsIndexes.get(j))).getName();
    String parentNameAmidstVar=parentAmidstVar.getName();
    assertEquals(parentNameAmidstVar,parentNameHuginVar);
  }
}
Program: 21548
Project: 21548
Buggy source:
private void testParents(Variable amidstVar,Node huginVar) throws ExceptionHugin {
  ParentSet parentsAmidstVar=amidstBN.getDAG().getParentSet(amidstVar);
  NodeList parentsHuginVar=huginVar.getParents();
  int numParentsAmidstVar=parentsAmidstVar.getNumberOfParents();
  int numParentsHuginVar=parentsHuginVar.size();
  assertEquals(numParentsAmidstVar,numParentsHuginVar);
  for (int j=0; j < numParentsAmidstVar; j++) {
    Variable parentAmidstVar=parentsAmidstVar.getParents().get(j);
    String parentNameHuginVar=((Node)parentsHuginVar.get(j)).getName();
    String parentNameAmidstVar=parentAmidstVar.getName();
    assertEquals(parentNameAmidstVar,parentNameHuginVar);
  }
}

Fixed version (ground truth):
private void testParents(Variable amidstVar,Node huginVar) throws ExceptionHugin {
  ParentSet parentsAmidstVar=amidstBN.getDAG().getParentSet(amidstVar);
  NodeList parentsHuginVar=huginVar.getParents();
  int numParentsAmidstVar=parentsAmidstVar.getNumberOfParents();
  int numParentsHuginVar=parentsHuginVar.size();
  assertEquals(numParentsAmidstVar,numParentsHuginVar);
  ArrayList<Integer> multinomialParentsIndexes=new ArrayList();
  for (int j=0; j < parentsHuginVar.size(); j++) {
    Node huginParent=parentsHuginVar.get(j);
    if (huginParent.getKind().compareTo(NetworkModel.H_KIND_DISCRETE) == 0) {
      multinomialParentsIndexes.add(j);
    }
  }
  Collections.reverse(multinomialParentsIndexes);
  ArrayList<Integer> parentsIndexes=new ArrayList();
  for (int j=0; j < parentsHuginVar.size(); j++) {
    Node huginParent=parentsHuginVar.get(j);
    if (huginParent.getKind().compareTo(NetworkModel.H_KIND_DISCRETE) == 0) {
      parentsIndexes.add(multinomialParentsIndexes.get(0));
      multinomialParentsIndexes.remove(0);
    }
 else {
      parentsIndexes.add(j);
    }
  }
  for (int j=0; j < numParentsAmidstVar; j++) {
    Variable parentAmidstVar=parentsAmidstVar.getParents().get(j);
    String parentNameHuginVar=((Node)parentsHuginVar.get(parentsIndexes.get(j))).getName();
    String parentNameAmidstVar=parentAmidstVar.getName();
    assertEquals(parentNameAmidstVar,parentNameHuginVar);
  }
}
Program: 21551
Project: 21551
Buggy source:
private void testParents(Variable amidstVar,Node huginVar) throws ExceptionHugin {
  ParentSet parentsAmidstVar=amidstBN.getDAG().getParentSet(amidstVar);
  NodeList parentsHuginVar=huginVar.getParents();
  int numParentsAmidstVar=parentsAmidstVar.getNumberOfParents();
  int numParentsHuginVar=parentsHuginVar.size();
  assertEquals(numParentsAmidstVar,numParentsHuginVar);
  for (int j=0; j < numParentsAmidstVar; j++) {
    Variable parentAmidstVar=parentsAmidstVar.getParents().get(j);
    String parentNameHuginVar=((Node)parentsHuginVar.get(j)).getName();
    String parentNameAmidstVar=parentAmidstVar.getName();
    assertEquals(parentNameAmidstVar,parentNameHuginVar);
  }
}

Fixed version (ground truth):
private void testParents(Variable amidstVar,Node huginVar) throws ExceptionHugin {
  ParentSet parentsAmidstVar=amidstBN.getDAG().getParentSet(amidstVar);
  NodeList parentsHuginVar=huginVar.getParents();
  int numParentsAmidstVar=parentsAmidstVar.getNumberOfParents();
  int numParentsHuginVar=parentsHuginVar.size();
  assertEquals(numParentsAmidstVar,numParentsHuginVar);
  ArrayList<Integer> multinomialParentsIndexes=new ArrayList();
  for (int j=0; j < parentsHuginVar.size(); j++) {
    Node huginParent=parentsHuginVar.get(j);
    if (huginParent.getKind().compareTo(NetworkModel.H_KIND_DISCRETE) == 0) {
      multinomialParentsIndexes.add(j);
    }
  }
  Collections.reverse(multinomialParentsIndexes);
  ArrayList<Integer> parentsIndexes=new ArrayList();
  for (int j=0; j < parentsHuginVar.size(); j++) {
    Node huginParent=parentsHuginVar.get(j);
    if (huginParent.getKind().compareTo(NetworkModel.H_KIND_DISCRETE) == 0) {
      parentsIndexes.add(multinomialParentsIndexes.get(0));
      multinomialParentsIndexes.remove(0);
    }
 else {
      parentsIndexes.add(j);
    }
  }
  for (int j=0; j < numParentsAmidstVar; j++) {
    Variable parentAmidstVar=parentsAmidstVar.getParents().get(j);
    String parentNameHuginVar=((Node)parentsHuginVar.get(parentsIndexes.get(j))).getName();
    String parentNameAmidstVar=parentAmidstVar.getName();
    assertEquals(parentNameAmidstVar,parentNameHuginVar);
  }
}
Program: 21557
Project: 21557
Buggy source:
public static DataOnMemory samplingNumberOfSamples(int numberOfSamples,DataBase dataBase){
  Random random=new Random(0);
  DataOnMemoryListContainer dataOnMemoryList=new DataOnMemoryListContainer(dataBase.getAttributes());
  int count=0;
  for (  DataInstance instance : dataBase) {
    if (count < numberOfSamples) {
      dataOnMemoryList.add(count,instance);
    }
 else {
      int r=random.nextInt(count);
      if (r < numberOfSamples)       dataOnMemoryList.add(r,instance);
    }
    count++;
  }
  return dataOnMemoryList;
}

Fixed version (ground truth):
public static DataOnMemory samplingNumberOfSamples(int numberOfSamples,DataBase dataBase){
  Random random=new Random(0);
  DataOnMemoryListContainer dataOnMemoryList=new DataOnMemoryListContainer(dataBase.getAttributes());
  int count=0;
  for (  DataInstance instance : dataBase) {
    if (count < numberOfSamples) {
      dataOnMemoryList.add(count,instance);
    }
 else {
      int r=random.nextInt(count + 1);
      if (r < numberOfSamples)       dataOnMemoryList.set(r,instance);
    }
    count++;
  }
  return dataOnMemoryList;
}
Program: 21559
Project: 21559
Buggy source:
public static DataOnMemory samplingNumberOfSamples(int numberOfSamples,DataBase dataBase){
  Random random=new Random(0);
  DataOnMemoryListContainer dataOnMemoryList=new DataOnMemoryListContainer(dataBase.getAttributes());
  int count=0;
  for (  DataInstance instance : dataBase) {
    if (count < numberOfSamples) {
      dataOnMemoryList.add(count,instance);
    }
 else {
      int r=random.nextInt(count);
      if (r < numberOfSamples)       dataOnMemoryList.add(r,instance);
    }
    count++;
  }
  return dataOnMemoryList;
}

Fixed version (ground truth):
public static DataOnMemory samplingNumberOfSamples(int numberOfSamples,DataBase dataBase){
  Random random=new Random(0);
  DataOnMemoryListContainer dataOnMemoryList=new DataOnMemoryListContainer(dataBase.getAttributes());
  int count=0;
  for (  DataInstance instance : dataBase) {
    if (count < numberOfSamples) {
      dataOnMemoryList.add(count,instance);
    }
 else {
      int r=random.nextInt(count + 1);
      if (r < numberOfSamples)       dataOnMemoryList.set(r,instance);
    }
    count++;
  }
  return dataOnMemoryList;
}
Program: 21561
Project: 21561
Buggy source:
public static DataOnMemory samplingNumberOfSamples(int numberOfSamples,DataBase dataBase){
  Random random=new Random(0);
  DataOnMemoryListContainer dataOnMemoryList=new DataOnMemoryListContainer(dataBase.getAttributes());
  int count=0;
  for (  DataInstance instance : dataBase) {
    if (count < numberOfSamples) {
      dataOnMemoryList.add(count,instance);
    }
 else {
      int r=random.nextInt(count);
      if (r < numberOfSamples)       dataOnMemoryList.add(r,instance);
    }
    count++;
  }
  return dataOnMemoryList;
}

Fixed version (ground truth):
public static DataOnMemory samplingNumberOfSamples(int numberOfSamples,DataBase dataBase){
  Random random=new Random(0);
  DataOnMemoryListContainer dataOnMemoryList=new DataOnMemoryListContainer(dataBase.getAttributes());
  int count=0;
  for (  DataInstance instance : dataBase) {
    if (count < numberOfSamples) {
      dataOnMemoryList.add(count,instance);
    }
 else {
      int r=random.nextInt(count + 1);
      if (r < numberOfSamples)       dataOnMemoryList.set(r,instance);
    }
    count++;
  }
  return dataOnMemoryList;
}
Program: 21563
Project: 21563
Buggy source:
public static DataOnMemory samplingNumberOfSamples(int numberOfSamples,DataBase dataBase){
  Random random=new Random(0);
  DataOnMemoryListContainer dataOnMemoryList=new DataOnMemoryListContainer(dataBase.getAttributes());
  int count=0;
  for (  DataInstance instance : dataBase) {
    if (count < numberOfSamples) {
      dataOnMemoryList.add(count,instance);
    }
 else {
      int r=random.nextInt(count);
      if (r < numberOfSamples)       dataOnMemoryList.add(r,instance);
    }
    count++;
  }
  return dataOnMemoryList;
}

Fixed version (ground truth):
public static DataOnMemory samplingNumberOfSamples(int numberOfSamples,DataBase dataBase){
  Random random=new Random(0);
  DataOnMemoryListContainer dataOnMemoryList=new DataOnMemoryListContainer(dataBase.getAttributes());
  int count=0;
  for (  DataInstance instance : dataBase) {
    if (count < numberOfSamples) {
      dataOnMemoryList.add(count,instance);
    }
 else {
      int r=random.nextInt(count + 1);
      if (r < numberOfSamples)       dataOnMemoryList.set(r,instance);
    }
    count++;
  }
  return dataOnMemoryList;
}
Program: 21564
Project: 21564
Buggy source:
private CompoundVector createCompoundVector(){
  return new CompoundVector((EF_ConditionalDistribution)this.getEF_BaseDistribution(0),this.numberOfConfigurations());
}

Fixed version (ground truth):
private CompoundVector createCompoundVector(){
  return new CompoundVector((EF_Distribution)this.getEF_BaseDistribution(0),this.numberOfConfigurations());
}
Program: 21565
Project: 21565
Buggy source:
public CompoundVector(EF_ConditionalDistribution baseDist1,int nConf1){
  nConf=nConf1;
  this.baseConf=new double[nConf];
  baseDist=baseDist1;
  baseVectors=new SparseVector(baseDist1::createZeroedVector,nConf);
  baseSSLength=baseDist.sizeOfSufficientStatistics();
}

Fixed version (ground truth):
public CompoundVector(EF_Distribution baseDist1,int nConf1){
  nConf=nConf1;
  this.baseConf=new double[nConf];
  baseDist=baseDist1;
  baseVectors=new SparseVector(baseDist1::createZeroedVector,nConf);
  baseSSLength=baseDist.sizeOfSufficientStatistics();
}
Program: 21566
Project: 21566
Buggy source:
public static void main(String[] args) throws IOException {
  BayesianNetworkGenerator.setNumberOfContinuousVars(0);
  BayesianNetworkGenerator.setNumberOfDiscreteVars(5000);
  BayesianNetworkGenerator.setNumberOfStates(3);
  BayesianNetwork bn=BayesianNetworkGenerator.generateNaiveBayes(new Random(0));
  int sampleSize=10000;
  BayesianNetworkSampler sampler=new BayesianNetworkSampler(bn);
  sampler.setParallelMode(false);
  String file="String_Node_Str";
  sampler.sampleToAnARFFFile(file,sampleSize);
  DataBase data=new DynamicDataOnDiskFromFile(new ARFFDataReader(file));
  for (int i=1; i <= 5; i++) {
    DynamicNaiveBayesClassifier model=new DynamicNaiveBayesClassifier();
    model.setClassVarID(data.getAttributes().getNumberOfAttributes() - 1);
    model.setParallelMode(true);
    model.learn(data);
    DynamicBayesianNetwork nbClassifier=model.getDynamicBNModel();
  }
}

Fixed version (ground truth):
public static void main(String[] args) throws IOException {
  BayesianNetworkGenerator.setNumberOfContinuousVars(0);
  BayesianNetworkGenerator.setNumberOfDiscreteVars(5);
  BayesianNetworkGenerator.setNumberOfStates(3);
  BayesianNetwork bn=BayesianNetworkGenerator.generateNaiveBayes(new Random(0));
  int sampleSize=10000;
  BayesianNetworkSampler sampler=new BayesianNetworkSampler(bn);
  sampler.setParallelMode(false);
  String file="String_Node_Str";
  sampler.sampleToAnARFFFile(file,sampleSize);
  DataBase data=new DynamicDataOnDiskFromFile(new ARFFDataReader(file));
  for (int i=1; i <= 5; i++) {
    DynamicNaiveBayesClassifier model=new DynamicNaiveBayesClassifier();
    model.setClassVarID(data.getAttributes().getNumberOfAttributes() - 1);
    model.setParallelMode(true);
    model.learn(data);
    DynamicBayesianNetwork nbClassifier=model.getDynamicBNModel();
    System.out.println(nbClassifier.toString());
  }
}
Program: 21567
Project: 21567
Buggy source:
private CompoundVector createCompoundVector(){
  return new CompoundVector((EF_ConditionalDistribution)this.getEF_BaseDistribution(0),this.numberOfConfigurations());
}

Fixed version (ground truth):
private CompoundVector createCompoundVector(){
  return new CompoundVector((EF_Distribution)this.getEF_BaseDistribution(0),this.numberOfConfigurations());
}
Program: 21568
Project: 21568
Buggy source:
public CompoundVector(EF_ConditionalDistribution baseDist1,int nConf1){
  nConf=nConf1;
  this.baseConf=new double[nConf];
  baseDist=baseDist1;
  baseVectors=new SparseVector(baseDist1::createZeroedVector,nConf);
  baseSSLength=baseDist.sizeOfSufficientStatistics();
}

Fixed version (ground truth):
public CompoundVector(EF_Distribution baseDist1,int nConf1){
  nConf=nConf1;
  this.baseConf=new double[nConf];
  baseDist=baseDist1;
  baseVectors=new SparseVector(baseDist1::createZeroedVector,nConf);
  baseSSLength=baseDist.sizeOfSufficientStatistics();
}
Program: 21569
Project: 21569
Buggy source:
public static void main(String[] args) throws IOException {
  BayesianNetworkGenerator.setNumberOfContinuousVars(0);
  BayesianNetworkGenerator.setNumberOfDiscreteVars(5000);
  BayesianNetworkGenerator.setNumberOfStates(3);
  BayesianNetwork bn=BayesianNetworkGenerator.generateNaiveBayes(new Random(0));
  int sampleSize=10000;
  BayesianNetworkSampler sampler=new BayesianNetworkSampler(bn);
  sampler.setParallelMode(false);
  String file="String_Node_Str";
  sampler.sampleToAnARFFFile(file,sampleSize);
  DataBase data=new DynamicDataOnDiskFromFile(new ARFFDataReader(file));
  for (int i=1; i <= 5; i++) {
    DynamicNaiveBayesClassifier model=new DynamicNaiveBayesClassifier();
    model.setClassVarID(data.getAttributes().getNumberOfAttributes() - 1);
    model.setParallelMode(true);
    model.learn(data);
    DynamicBayesianNetwork nbClassifier=model.getDynamicBNModel();
  }
}

Fixed version (ground truth):
public static void main(String[] args) throws IOException {
  BayesianNetworkGenerator.setNumberOfContinuousVars(0);
  BayesianNetworkGenerator.setNumberOfDiscreteVars(5);
  BayesianNetworkGenerator.setNumberOfStates(3);
  BayesianNetwork bn=BayesianNetworkGenerator.generateNaiveBayes(new Random(0));
  int sampleSize=10000;
  BayesianNetworkSampler sampler=new BayesianNetworkSampler(bn);
  sampler.setParallelMode(false);
  String file="String_Node_Str";
  sampler.sampleToAnARFFFile(file,sampleSize);
  DataBase data=new DynamicDataOnDiskFromFile(new ARFFDataReader(file));
  for (int i=1; i <= 5; i++) {
    DynamicNaiveBayesClassifier model=new DynamicNaiveBayesClassifier();
    model.setClassVarID(data.getAttributes().getNumberOfAttributes() - 1);
    model.setParallelMode(true);
    model.learn(data);
    DynamicBayesianNetwork nbClassifier=model.getDynamicBNModel();
    System.out.println(nbClassifier.toString());
  }
}
Program: 21570
Project: 21570
Buggy source:
private CompoundVector createCompoundVector(){
  return new CompoundVector((EF_ConditionalDistribution)this.getEF_BaseDistribution(0),this.numberOfConfigurations());
}

Fixed version (ground truth):
private CompoundVector createCompoundVector(){
  return new CompoundVector((EF_Distribution)this.getEF_BaseDistribution(0),this.numberOfConfigurations());
}
Program: 21571
Project: 21571
Buggy source:
public CompoundVector(EF_ConditionalDistribution baseDist1,int nConf1){
  nConf=nConf1;
  this.baseConf=new double[nConf];
  baseDist=baseDist1;
  baseVectors=new SparseVector(baseDist1::createZeroedVector,nConf);
  baseSSLength=baseDist.sizeOfSufficientStatistics();
}

Fixed version (ground truth):
public CompoundVector(EF_Distribution baseDist1,int nConf1){
  nConf=nConf1;
  this.baseConf=new double[nConf];
  baseDist=baseDist1;
  baseVectors=new SparseVector(baseDist1::createZeroedVector,nConf);
  baseSSLength=baseDist.sizeOfSufficientStatistics();
}
Program: 21572
Project: 21572
Buggy source:
public static void main(String[] args) throws IOException {
  BayesianNetworkGenerator.setNumberOfContinuousVars(0);
  BayesianNetworkGenerator.setNumberOfDiscreteVars(5000);
  BayesianNetworkGenerator.setNumberOfStates(3);
  BayesianNetwork bn=BayesianNetworkGenerator.generateNaiveBayes(new Random(0));
  int sampleSize=10000;
  BayesianNetworkSampler sampler=new BayesianNetworkSampler(bn);
  sampler.setParallelMode(false);
  String file="String_Node_Str";
  sampler.sampleToAnARFFFile(file,sampleSize);
  DataBase data=new DynamicDataOnDiskFromFile(new ARFFDataReader(file));
  for (int i=1; i <= 5; i++) {
    DynamicNaiveBayesClassifier model=new DynamicNaiveBayesClassifier();
    model.setClassVarID(data.getAttributes().getNumberOfAttributes() - 1);
    model.setParallelMode(true);
    model.learn(data);
    DynamicBayesianNetwork nbClassifier=model.getDynamicBNModel();
  }
}

Fixed version (ground truth):
public static void main(String[] args) throws IOException {
  BayesianNetworkGenerator.setNumberOfContinuousVars(0);
  BayesianNetworkGenerator.setNumberOfDiscreteVars(5);
  BayesianNetworkGenerator.setNumberOfStates(3);
  BayesianNetwork bn=BayesianNetworkGenerator.generateNaiveBayes(new Random(0));
  int sampleSize=10000;
  BayesianNetworkSampler sampler=new BayesianNetworkSampler(bn);
  sampler.setParallelMode(false);
  String file="String_Node_Str";
  sampler.sampleToAnARFFFile(file,sampleSize);
  DataBase data=new DynamicDataOnDiskFromFile(new ARFFDataReader(file));
  for (int i=1; i <= 5; i++) {
    DynamicNaiveBayesClassifier model=new DynamicNaiveBayesClassifier();
    model.setClassVarID(data.getAttributes().getNumberOfAttributes() - 1);
    model.setParallelMode(true);
    model.learn(data);
    DynamicBayesianNetwork nbClassifier=model.getDynamicBNModel();
    System.out.println(nbClassifier.toString());
  }
}
Program: 21573
Project: 21573
Buggy source:
private CompoundVector createCompoundVector(){
  return new CompoundVector((EF_ConditionalDistribution)this.getEF_BaseDistribution(0),this.numberOfConfigurations());
}

Fixed version (ground truth):
private CompoundVector createCompoundVector(){
  return new CompoundVector((EF_Distribution)this.getEF_BaseDistribution(0),this.numberOfConfigurations());
}
Program: 21574
Project: 21574
Buggy source:
public CompoundVector(EF_ConditionalDistribution baseDist1,int nConf1){
  nConf=nConf1;
  this.baseConf=new double[nConf];
  baseDist=baseDist1;
  baseVectors=new SparseVector(baseDist1::createZeroedVector,nConf);
  baseSSLength=baseDist.sizeOfSufficientStatistics();
}

Fixed version (ground truth):
public CompoundVector(EF_Distribution baseDist1,int nConf1){
  nConf=nConf1;
  this.baseConf=new double[nConf];
  baseDist=baseDist1;
  baseVectors=new SparseVector(baseDist1::createZeroedVector,nConf);
  baseSSLength=baseDist.sizeOfSufficientStatistics();
}
Program: 21575
Project: 21575
Buggy source:
public static void main(String[] args) throws IOException {
  BayesianNetworkGenerator.setNumberOfContinuousVars(0);
  BayesianNetworkGenerator.setNumberOfDiscreteVars(5000);
  BayesianNetworkGenerator.setNumberOfStates(3);
  BayesianNetwork bn=BayesianNetworkGenerator.generateNaiveBayes(new Random(0));
  int sampleSize=10000;
  BayesianNetworkSampler sampler=new BayesianNetworkSampler(bn);
  sampler.setParallelMode(false);
  String file="String_Node_Str";
  sampler.sampleToAnARFFFile(file,sampleSize);
  DataBase data=new DynamicDataOnDiskFromFile(new ARFFDataReader(file));
  for (int i=1; i <= 5; i++) {
    DynamicNaiveBayesClassifier model=new DynamicNaiveBayesClassifier();
    model.setClassVarID(data.getAttributes().getNumberOfAttributes() - 1);
    model.setParallelMode(true);
    model.learn(data);
    DynamicBayesianNetwork nbClassifier=model.getDynamicBNModel();
  }
}

Fixed version (ground truth):
public static void main(String[] args) throws IOException {
  BayesianNetworkGenerator.setNumberOfContinuousVars(0);
  BayesianNetworkGenerator.setNumberOfDiscreteVars(5);
  BayesianNetworkGenerator.setNumberOfStates(3);
  BayesianNetwork bn=BayesianNetworkGenerator.generateNaiveBayes(new Random(0));
  int sampleSize=10000;
  BayesianNetworkSampler sampler=new BayesianNetworkSampler(bn);
  sampler.setParallelMode(false);
  String file="String_Node_Str";
  sampler.sampleToAnARFFFile(file,sampleSize);
  DataBase data=new DynamicDataOnDiskFromFile(new ARFFDataReader(file));
  for (int i=1; i <= 5; i++) {
    DynamicNaiveBayesClassifier model=new DynamicNaiveBayesClassifier();
    model.setClassVarID(data.getAttributes().getNumberOfAttributes() - 1);
    model.setParallelMode(true);
    model.learn(data);
    DynamicBayesianNetwork nbClassifier=model.getDynamicBNModel();
    System.out.println(nbClassifier.toString());
  }
}
Program: 21576
Project: 21576
Buggy source:
private void setMultinomial_MultinomialParents(Node huginVar) throws ExceptionHugin {
  int indexNode=this.huginBN.getNodes().indexOf(huginVar);
  Variable amidstVar=this.amidstBN.getStaticVariables().getVariableById(indexNode);
  int numStates=amidstVar.getNumberOfStates();
  double[] huginProbabilities=huginVar.getTable().getData();
  List<Variable> parents=this.amidstBN.getDAG().getParentSet(amidstVar).getParents();
  int numParentAssignments=MultinomialIndex.getNumberOfPossibleAssignments(parents);
  int pos=0;
  for (int i=0; i < numParentAssignments; i++) {
    double[] amidstProbabilities=new double[numStates];
    for (int k=0; k < numStates; k++) {
      amidstProbabilities[k]=huginProbabilities[i * numStates + k];
    }
    Multinomial_MultinomialParents dist=this.amidstBN.getDistribution(amidstVar);
    dist.getMultinomial(i).setProbabilities(amidstProbabilities);
    pos=pos + numStates;
  }
}

Fixed version (ground truth):
private void setMultinomial_MultinomialParents(Node huginVar) throws ExceptionHugin {
  int indexNode=this.huginBN.getNodes().indexOf(huginVar);
  Variable amidstVar=this.amidstBN.getStaticVariables().getVariableById(indexNode);
  int numStates=amidstVar.getNumberOfStates();
  double[] huginProbabilities=huginVar.getTable().getData();
  List<Variable> parents=this.amidstBN.getDAG().getParentSet(amidstVar).getParents();
  int numParentAssignments=MultinomialIndex.getNumberOfPossibleAssignments(parents);
  for (int i=0; i < numParentAssignments; i++) {
    double[] amidstProbabilities=new double[numStates];
    for (int k=0; k < numStates; k++) {
      amidstProbabilities[k]=huginProbabilities[i * numStates + k];
    }
    Multinomial_MultinomialParents dist=this.amidstBN.getDistribution(amidstVar);
    dist.getMultinomial(i).setProbabilities(amidstProbabilities);
  }
}
Program: 21578
Project: 21578
Buggy source:
public static Class convertToHugin(DynamicBayesianNetwork amidstDBN) throws ExceptionHugin {
  DBNConverterToHugin DBNconverterToHugin=new DBNConverterToHugin();
  DBNconverterToHugin.setVariables(amidstDBN);
  DBNconverterToHugin.setTemporalClones(amidstDBN);
  DBNconverterToHugin.setStructure(amidstDBN);
  DBNconverterToHugin.setDistributions(amidstDBN);
  return DBNconverterToHugin.huginDBN;
}

Fixed version (ground truth):
public static Class convertToHugin(DynamicBayesianNetwork amidstDBN) throws ExceptionHugin {
  DBNConverterToHugin DBNconverterToHugin=new DBNConverterToHugin();
  DBNconverterToHugin.setNodesAndTemporalClones(amidstDBN);
  DBNconverterToHugin.setStructure(amidstDBN);
  DBNconverterToHugin.setDistributions(amidstDBN);
  return DBNconverterToHugin.huginDBN;
}
Program: 21579
Project: 21579
Buggy source:
private void setDistributions(DynamicBayesianNetwork amidstDBN) throws ExceptionHugin {
  List<Variable> amidstVars=amidstDBN.getDynamicVariables().getListOfDynamicVariables();
  for (  Variable amidstVar : amidstVars) {
    if (amidstVar.getDistributionType().compareTo(DistType.MULTINOMIAL) != 0)     throw new IllegalArgumentException("String_Node_Str");
    Node huginVar=this.huginDBN.getNodeByName(amidstVar.getName());
    Multinomial_MultinomialParents dist=amidstDBN.getDistributionTimeT(amidstVar);
    Multinomial[] probabilities=dist.getProbabilities();
    List<Variable> conditioningVariables=dist.getConditioningVariables();
    int numParentAssignments=MultinomialIndex.getNumberOfPossibleAssignments(conditioningVariables);
    int nStates=amidstVar.getNumberOfStates();
    int sizeArray=numParentAssignments * nStates;
    double[] finalArray=new double[sizeArray];
    for (int i=0; i < numParentAssignments; i++) {
      double[] sourceArray=probabilities[i].getProbabilities();
      System.arraycopy(sourceArray,0,finalArray,i * nStates,nStates);
    }
    huginVar.getTable().setData(finalArray);
    if (huginVar.getTemporalClone() != null) {
      Multinomial_MultinomialParents distClone=amidstDBN.getDistributionTime0(amidstVar);
      finalArray=distClone.getProbabilities()[0].getProbabilities();
      huginVar.getTemporalClone().getTable().setData(finalArray);
    }
  }
}

Fixed version (ground truth):
private void setDistributions(DynamicBayesianNetwork amidstDBN) throws ExceptionHugin {
  NodeList huginNodes=this.huginDBN.getNodes();
  int numNodes=huginNodes.size();
  Multinomial_MultinomialParents dist=null;
  int nStates=0;
  for (int i=0; i < numNodes; i++) {
    Node huginNode=huginNodes.get(i);
    if (huginNode.getTemporalMaster() == null) {
      Variable amidstVar=amidstDBN.getDynamicVariables().getVariableByName(huginNode.getName());
      dist=amidstDBN.getDistributionTimeT(amidstVar);
      nStates=amidstVar.getNumberOfStates();
    }
    if (huginNode.getTemporalClone() == null) {
      Variable amidstVar=amidstDBN.getDynamicVariables().getVariableByName(huginNode.getTemporalMaster().getName());
      dist=amidstDBN.getDistributionTime0(amidstVar);
      nStates=amidstVar.getNumberOfStates();
    }
    Multinomial[] probabilities=dist.getProbabilities();
    List<Variable> conditioningVariables=dist.getConditioningVariables();
    int numParentAssignments=MultinomialIndex.getNumberOfPossibleAssignments(conditioningVariables);
    int sizeArray=numParentAssignments * nStates;
    double[] finalArray=new double[sizeArray];
    for (int j=0; j < numParentAssignments; j++) {
      double[] sourceArray=probabilities[j].getProbabilities();
      System.arraycopy(sourceArray,0,finalArray,j * nStates,nStates);
    }
    huginNode.getTable().setData(finalArray);
  }
}
Program: 21580
Project: 21580
Buggy source:
private void setStructure(DynamicBayesianNetwork amidstDBN) throws ExceptionHugin {
  DynamicDAG dynamicDAG=amidstDBN.getDynamicDAG();
  DynamicVariables dynamicVariables=amidstDBN.getDynamicVariables();
  List<Variable> amidstVars=dynamicVariables.getListOfDynamicVariables();
  for (  Variable amidstChild : amidstVars) {
    List<Variable> amidstParents=dynamicDAG.getParentSetTimeT(amidstChild).getParents();
    Node huginChild=this.huginDBN.getNodeByName(amidstChild.getName());
    for (    Variable amidstParent : amidstParents) {
      if (amidstParent.isTemporalClone()) {
        huginChild.addParent(huginChild.getTemporalClone());
      }
 else {
        Node huginParent=this.huginDBN.getNodeByName(amidstParent.getName());
        huginChild.addParent(huginParent);
      }
    }
  }
}

Fixed version (ground truth):
private void setStructure(DynamicBayesianNetwork amidstDBN) throws ExceptionHugin {
  DynamicDAG dynamicDAG=amidstDBN.getDynamicDAG();
  DynamicVariables dynamicVariables=amidstDBN.getDynamicVariables();
  List<Variable> amidstVars=dynamicVariables.getListOfDynamicVariables();
  for (  Variable amidstChild : amidstVars) {
    List<Variable> amidstParents=dynamicDAG.getParentSetTimeT(amidstChild).getParents();
    Node huginChild=this.huginDBN.getNodeByName(amidstChild.getName());
    for (    Variable amidstParent : amidstParents) {
      if (amidstParent.isTemporalClone()) {
        huginChild.addParent(huginChild.getTemporalClone());
      }
 else {
        Node huginParent=this.huginDBN.getNodeByName(amidstParent.getName());
        huginChild.addParent(huginParent);
        Node huginParentClone=huginParent.getTemporalClone();
        Node huginChildClone=huginChild.getTemporalClone();
        huginChildClone.addParent(huginParentClone);
      }
    }
  }
}
Program: 21581
Project: 21581
Buggy source:
@Before public void setUp() throws ExceptionHugin {
  ParseListener parseListener=new DefaultClassParseListener();
  this.huginBN=new Domain("String_Node_Str",parseListener);
  System.out.println("String_Node_Str");
  this.amidstBN=ConverterToAMIDST.convertToAmidst(this.huginBN);
  System.out.println("String_Node_Str");
}

Fixed version (ground truth):
@Before public void setUp() throws ExceptionHugin {
  ParseListener parseListener=new DefaultClassParseListener();
  Domain huginBN=new Domain("String_Node_Str",parseListener);
  System.out.println("String_Node_Str");
  BayesianNetwork amidstBN=ConverterToAMIDST.convertToAmidst(huginBN);
  System.out.println("String_Node_Str");
}
Program: 21582
Project: 21582
Buggy source:
@Override public void updateNaturalFromMomentParameters(){
  CompoundVector globalMomentsParam=(CompoundVector)this.momentParameters;
  CompoundVector vectorNatural=this.createCompoundVector();
  this.distributionList.stream().forEach(w -> {
    MomentParameters localMomentParam=(MomentParameters)globalMomentsParam.getVectorByPosition(w.getVariable().getVarID());
    w.setMomentParameters(localMomentParam);
    vectorNatural.setVectorByPosition(w.getVariable().getVarID(),w.getNaturalParameters());
  }
);
}

Fixed version (ground truth):
@Override public void updateNaturalFromMomentParameters(){
  CompoundVector globalMomentsParam=(CompoundVector)this.momentParameters;
  CompoundVector vectorNatural=this.createCompoundVector();
  this.distributionList.stream().forEach(w -> {
    MomentParameters localMomentParam=(MomentParameters)globalMomentsParam.getVectorByPosition(w.getVariable().getVarID());
    w.setMomentParameters(localMomentParam);
    vectorNatural.setVectorByPosition(w.getVariable().getVarID(),w.getNaturalParameters());
  }
);
  this.naturalParameters=vectorNatural;
}
Program: 21583
Project: 21583
Buggy source:
public BayesianNetwork learnBN(DataBase dataBase){
  LearningEngine.setStaticStructuralLearningAlgorithm(this::learnDAG);
  LearningEngine.setStaticParameterLearningAlgorithm(MaximumLikelihood::serialLearnStatic);
  return LearningEngine.learnStaticModel(dataBase);
}

Fixed version (ground truth):
public BayesianNetwork learnBN(DataBase dataBase){
  LearningEngine.setStaticStructuralLearningAlgorithm(this::learnDAG);
  MaximumLikelihood.setParallelMode(this.parallelMode);
  LearningEngine.setStaticParameterLearningAlgorithm(MaximumLikelihood::learnParametersStaticModel);
  return LearningEngine.learnStaticModel(dataBase);
}
Program: 21584
Project: 21584
Buggy source:
public ParallelTAN(){
  this.numSamplesOnMemory=10000;
  this.numCores=1;
}

Fixed version (ground truth):
public ParallelTAN(){
  this.numSamplesOnMemory=10000;
  this.numCores=Runtime.getRuntime().availableProcessors();
  this.parallelMode=true;
}
Program: 21585
Project: 21585
Buggy source:
public static void main(String[] args) throws Exception {
  String dataFile=new String("String_Node_Str");
  DataBase data=new StaticDataOnDiskFromFile(new ARFFDataReader(dataFile));
  ParallelTAN tan=new ParallelTAN();
  tan.setNumCores(4);
  tan.setNumSamplesOnMemory(1000);
  tan.setNameRoot("String_Node_Str");
  tan.setNameTarget("String_Node_Str");
  LearningEngine.setStaticStructuralLearningAlgorithm(tan::learnDAG);
  MaximumLikelihood.setBatchSize(1000);
  LearningEngine.setStaticParameterLearningAlgorithm(MaximumLikelihood::parallelLearnStatic);
  BayesianNetwork tanModel=LearningEngine.learnStaticModel(data);
}

Fixed version (ground truth):
public static void main(String[] args) throws Exception {
  String dataFile=new String("String_Node_Str");
  DataBase data=new StaticDataOnDiskFromFile(new ARFFDataReader(dataFile));
  ParallelTAN tan=new ParallelTAN();
  tan.setNumCores(4);
  tan.setNumSamplesOnMemory(1000);
  tan.setNameRoot("String_Node_Str");
  tan.setNameTarget("String_Node_Str");
  LearningEngine.setStaticStructuralLearningAlgorithm(tan::learnDAG);
  MaximumLikelihood.setBatchSize(1000);
  LearningEngine.setStaticParameterLearningAlgorithm(MaximumLikelihood::learnParametersStaticModel);
  BayesianNetwork tanModel=LearningEngine.learnStaticModel(data);
}
Program: 21586
Project: 21586
Buggy source:
public void learn(DataBase dataBase){
  LearningEngine.setStaticStructuralLearningAlgorithm(this::staticNaiveBayesStructure);
  LearningEngine.setStaticParameterLearningAlgorithm(MaximumLikelihood::parallelLearnStatic);
  bnModel=LearningEngine.learnStaticModel(dataBase);
}

Fixed version (ground truth):
public void learn(DataBase dataBase){
  LearningEngine.setStaticStructuralLearningAlgorithm(this::staticNaiveBayesStructure);
  LearningEngine.setStaticParameterLearningAlgorithm(MaximumLikelihood::learnParametersStaticModel);
  bnModel=LearningEngine.learnStaticModel(dataBase);
}
Program: 21587
Project: 21587
Buggy source:
public static BayesianNetwork newBayesianNetwork(DAG dag,List<ConditionalDistribution> dists){
  return new BayesianNetwork(dag);
}

Fixed version (ground truth):
public static BayesianNetwork newBayesianNetwork(DAG dag,List<ConditionalDistribution> dists){
  return new BayesianNetwork(dag,dists);
}
Program: 21588
Project: 21588
Buggy source:
default String toARFFString(List<Variable> vars){
  StringBuilder builder=new StringBuilder(vars.size() * 2);
  for (int i=0; i < vars.size() - 1; i++) {
    Attribute att=vars.get(i).getAttribute();
    String nameState=((FiniteStateSpace)att.getStateSpace()).getStatesName((int)this.getValue(vars.get(i)));
    builder.append(nameState + "String_Node_Str");
  }
  Attribute att=vars.get(vars.size() - 1).getAttribute();
  String nameState=((FiniteStateSpace)att.getStateSpace()).getStatesName((int)this.getValue(vars.get(vars.size() - 1)));
  builder.append(nameState);
  return builder.toString();
}

Fixed version (ground truth):
default String toARFFString(List<Variable> vars){
  StringBuilder builder=new StringBuilder(vars.size() * 2);
  for (int i=0; i < vars.size() - 1; i++) {
    FiniteStateSpace stateSpace=vars.get(i).getStateSpace();
    String nameState=stateSpace.getStatesName((int)this.getValue(vars.get(i)));
    builder.append(nameState + "String_Node_Str");
  }
  FiniteStateSpace stateSpace=vars.get(vars.size() - 1).getStateSpace();
  String nameState=stateSpace.getStatesName((int)this.getValue(vars.get(vars.size() - 1)));
  builder.append(nameState);
  return builder.toString();
}
Program: 21589
Project: 21589
Buggy source:
private void setMultinomial_MultinomialParents(Node huginVar) throws ExceptionHugin {
  int indexNode=this.huginBN.getNodes().indexOf(huginVar);
  Variable amidstVar=this.amidstBN.getStaticVariables().getVariableById(indexNode);
  int numStates=amidstVar.getNumberOfStates();
  double[] huginProbabilities=huginVar.getTable().getData();
  List<Variable> parents=this.amidstBN.getDAG().getParentSet(amidstVar).getParents();
  int numParentAssignments=MultinomialIndex.getNumberOfPossibleAssignments(parents);
  int pos=0;
  for (int i=0; i < numParentAssignments; i++) {
    double[] amidstProbabilities=new double[numStates];
    for (int k=0; k < numStates; k++) {
      amidstProbabilities[k]=huginProbabilities[i * numStates + k];
    }
    Multinomial_MultinomialParents dist=this.amidstBN.getDistribution(amidstVar);
    dist.getMultinomial(i).setProbabilities(amidstProbabilities);
    pos=pos + numStates;
  }
}

Fixed version (ground truth):
private void setMultinomial_MultinomialParents(Node huginVar) throws ExceptionHugin {
  int indexNode=this.huginBN.getNodes().indexOf(huginVar);
  Variable amidstVar=this.amidstBN.getStaticVariables().getVariableById(indexNode);
  int numStates=amidstVar.getNumberOfStates();
  double[] huginProbabilities=huginVar.getTable().getData();
  List<Variable> parents=this.amidstBN.getDAG().getParentSet(amidstVar).getParents();
  int numParentAssignments=MultinomialIndex.getNumberOfPossibleAssignments(parents);
  for (int i=0; i < numParentAssignments; i++) {
    double[] amidstProbabilities=new double[numStates];
    for (int k=0; k < numStates; k++) {
      amidstProbabilities[k]=huginProbabilities[i * numStates + k];
    }
    Multinomial_MultinomialParents dist=this.amidstBN.getDistribution(amidstVar);
    dist.getMultinomial(i).setProbabilities(amidstProbabilities);
  }
}
Program: 21591
Project: 21591
Buggy source:
public static Class convertToHugin(DynamicBayesianNetwork amidstDBN) throws ExceptionHugin {
  DBNConverterToHugin DBNconverterToHugin=new DBNConverterToHugin();
  DBNconverterToHugin.setVariables(amidstDBN);
  DBNconverterToHugin.setTemporalClones(amidstDBN);
  DBNconverterToHugin.setStructure(amidstDBN);
  DBNconverterToHugin.setDistributions(amidstDBN);
  return DBNconverterToHugin.huginDBN;
}

Fixed version (ground truth):
public static Class convertToHugin(DynamicBayesianNetwork amidstDBN) throws ExceptionHugin {
  DBNConverterToHugin DBNconverterToHugin=new DBNConverterToHugin();
  DBNconverterToHugin.setNodesAndTemporalClones(amidstDBN);
  DBNconverterToHugin.setStructure(amidstDBN);
  DBNconverterToHugin.setDistributions(amidstDBN);
  return DBNconverterToHugin.huginDBN;
}
Program: 21592
Project: 21592
Buggy source:
private void setDistributions(DynamicBayesianNetwork amidstDBN) throws ExceptionHugin {
  List<Variable> amidstVars=amidstDBN.getDynamicVariables().getListOfDynamicVariables();
  for (  Variable amidstVar : amidstVars) {
    if (amidstVar.getDistributionType().compareTo(DistType.MULTINOMIAL) != 0)     throw new IllegalArgumentException("String_Node_Str");
    Node huginVar=this.huginDBN.getNodeByName(amidstVar.getName());
    Multinomial_MultinomialParents dist=amidstDBN.getDistributionTimeT(amidstVar);
    Multinomial[] probabilities=dist.getProbabilities();
    List<Variable> conditioningVariables=dist.getConditioningVariables();
    int numParentAssignments=MultinomialIndex.getNumberOfPossibleAssignments(conditioningVariables);
    int nStates=amidstVar.getNumberOfStates();
    int sizeArray=numParentAssignments * nStates;
    double[] finalArray=new double[sizeArray];
    for (int i=0; i < numParentAssignments; i++) {
      double[] sourceArray=probabilities[i].getProbabilities();
      System.arraycopy(sourceArray,0,finalArray,i * nStates,nStates);
    }
    huginVar.getTable().setData(finalArray);
    if (huginVar.getTemporalClone() != null) {
      Multinomial_MultinomialParents distClone=amidstDBN.getDistributionTime0(amidstVar);
      finalArray=distClone.getProbabilities()[0].getProbabilities();
      huginVar.getTemporalClone().getTable().setData(finalArray);
    }
  }
}

Fixed version (ground truth):
private void setDistributions(DynamicBayesianNetwork amidstDBN) throws ExceptionHugin {
  NodeList huginNodes=this.huginDBN.getNodes();
  int numNodes=huginNodes.size();
  Multinomial_MultinomialParents dist=null;
  int nStates=0;
  for (int i=0; i < numNodes; i++) {
    Node huginNode=huginNodes.get(i);
    if (huginNode.getTemporalMaster() == null) {
      Variable amidstVar=amidstDBN.getDynamicVariables().getVariableByName(huginNode.getName());
      dist=amidstDBN.getDistributionTimeT(amidstVar);
      nStates=amidstVar.getNumberOfStates();
    }
    if (huginNode.getTemporalClone() == null) {
      Variable amidstVar=amidstDBN.getDynamicVariables().getVariableByName(huginNode.getTemporalMaster().getName());
      dist=amidstDBN.getDistributionTime0(amidstVar);
      nStates=amidstVar.getNumberOfStates();
    }
    Multinomial[] probabilities=dist.getProbabilities();
    List<Variable> conditioningVariables=dist.getConditioningVariables();
    int numParentAssignments=MultinomialIndex.getNumberOfPossibleAssignments(conditioningVariables);
    int sizeArray=numParentAssignments * nStates;
    double[] finalArray=new double[sizeArray];
    for (int j=0; j < numParentAssignments; j++) {
      double[] sourceArray=probabilities[j].getProbabilities();
      System.arraycopy(sourceArray,0,finalArray,j * nStates,nStates);
    }
    huginNode.getTable().setData(finalArray);
  }
}
Program: 21593
Project: 21593
Buggy source:
private void setStructure(DynamicBayesianNetwork amidstDBN) throws ExceptionHugin {
  DynamicDAG dynamicDAG=amidstDBN.getDynamicDAG();
  DynamicVariables dynamicVariables=amidstDBN.getDynamicVariables();
  List<Variable> amidstVars=dynamicVariables.getListOfDynamicVariables();
  for (  Variable amidstChild : amidstVars) {
    List<Variable> amidstParents=dynamicDAG.getParentSetTimeT(amidstChild).getParents();
    Node huginChild=this.huginDBN.getNodeByName(amidstChild.getName());
    for (    Variable amidstParent : amidstParents) {
      if (amidstParent.isTemporalClone()) {
        huginChild.addParent(huginChild.getTemporalClone());
      }
 else {
        Node huginParent=this.huginDBN.getNodeByName(amidstParent.getName());
        huginChild.addParent(huginParent);
      }
    }
  }
}

Fixed version (ground truth):
private void setStructure(DynamicBayesianNetwork amidstDBN) throws ExceptionHugin {
  DynamicDAG dynamicDAG=amidstDBN.getDynamicDAG();
  DynamicVariables dynamicVariables=amidstDBN.getDynamicVariables();
  List<Variable> amidstVars=dynamicVariables.getListOfDynamicVariables();
  for (  Variable amidstChild : amidstVars) {
    List<Variable> amidstParents=dynamicDAG.getParentSetTimeT(amidstChild).getParents();
    Node huginChild=this.huginDBN.getNodeByName(amidstChild.getName());
    for (    Variable amidstParent : amidstParents) {
      if (amidstParent.isTemporalClone()) {
        huginChild.addParent(huginChild.getTemporalClone());
      }
 else {
        Node huginParent=this.huginDBN.getNodeByName(amidstParent.getName());
        huginChild.addParent(huginParent);
        Node huginParentClone=huginParent.getTemporalClone();
        Node huginChildClone=huginChild.getTemporalClone();
        huginChildClone.addParent(huginParentClone);
      }
    }
  }
}
Program: 21594
Project: 21594
Buggy source:
@Before public void setUp() throws ExceptionHugin {
  ParseListener parseListener=new DefaultClassParseListener();
  this.huginBN=new Domain("String_Node_Str",parseListener);
  System.out.println("String_Node_Str");
  this.amidstBN=ConverterToAMIDST.convertToAmidst(this.huginBN);
  System.out.println("String_Node_Str");
}

Fixed version (ground truth):
@Before public void setUp() throws ExceptionHugin {
  ParseListener parseListener=new DefaultClassParseListener();
  Domain huginBN=new Domain("String_Node_Str",parseListener);
  System.out.println("String_Node_Str");
  BayesianNetwork amidstBN=ConverterToAMIDST.convertToAmidst(huginBN);
  System.out.println("String_Node_Str");
}
Program: 21595
Project: 21595
Buggy source:
@Override public void updateNaturalFromMomentParameters(){
  CompoundVector globalMomentsParam=(CompoundVector)this.momentParameters;
  CompoundVector vectorNatural=this.createCompoundVector();
  this.distributionList.stream().forEach(w -> {
    MomentParameters localMomentParam=(MomentParameters)globalMomentsParam.getVectorByPosition(w.getVariable().getVarID());
    w.setMomentParameters(localMomentParam);
    vectorNatural.setVectorByPosition(w.getVariable().getVarID(),w.getNaturalParameters());
  }
);
}

Fixed version (ground truth):
@Override public void updateNaturalFromMomentParameters(){
  CompoundVector globalMomentsParam=(CompoundVector)this.momentParameters;
  CompoundVector vectorNatural=this.createCompoundVector();
  this.distributionList.stream().forEach(w -> {
    MomentParameters localMomentParam=(MomentParameters)globalMomentsParam.getVectorByPosition(w.getVariable().getVarID());
    w.setMomentParameters(localMomentParam);
    vectorNatural.setVectorByPosition(w.getVariable().getVarID(),w.getNaturalParameters());
  }
);
  this.naturalParameters=vectorNatural;
}
Program: 21596
Project: 21596
Buggy source:
public BayesianNetwork learnBN(DataBase dataBase){
  LearningEngine.setStaticStructuralLearningAlgorithm(this::learnDAG);
  LearningEngine.setStaticParameterLearningAlgorithm(MaximumLikelihood::serialLearnStatic);
  return LearningEngine.learnStaticModel(dataBase);
}

Fixed version (ground truth):
public BayesianNetwork learnBN(DataBase dataBase){
  LearningEngine.setStaticStructuralLearningAlgorithm(this::learnDAG);
  MaximumLikelihood.setParallelMode(this.parallelMode);
  LearningEngine.setStaticParameterLearningAlgorithm(MaximumLikelihood::learnParametersStaticModel);
  return LearningEngine.learnStaticModel(dataBase);
}