nus-yam/ex-repair huggingface dataset:
Program: 32879
Project: 32879
Buggy source:
/** 
 * This method cancels the batch execution mode. All stacked calls are discarded.
 * @see ArangoDriver#startBatchMode()
 * @see ArangoDriver#executeBatch()
 * @throws com.arangodb.ArangoException
 */
public void cancelBatchMode() throws ArangoException {
  if (!this.httpManager.isBatchModeActive()) {
    throw new ArangoException("String_Node_Str");
  }
  this.httpManager.setBatchModeActive(false);
  this.createModuleDrivers(false);
}

Fixed version (ground truth):
/** 
 * This method cancels the batch execution mode. All stacked calls are discarded.
 * @see ArangoDriver#startBatchMode()
 * @see ArangoDriver#executeBatch()
 * @throws com.arangodb.ArangoException
 */
public void cancelBatchMode() throws ArangoException {
  if (!this.httpManager.isBatchModeActive()) {
    throw new ArangoException("String_Node_Str");
  }
  this.httpManager.setBatchModeActive(false);
  this.createModuleDrivers(false);
  this.httpManager.emptyCallStack();
  this.httpManager.setPreDefinedResponse(null);
}
Program: 32881
Project: 32881
Buggy source:
@Before public void before() throws ArangoException {
  for (  String col : new String[]{"String_Node_Str"}) {
    try {
      driver.deleteCollection(col);
    }
 catch (    ArangoException e) {
    }
  }
}

Fixed version (ground truth):
@Before public void before() throws ArangoException {
  try {
    driver.cancelBatchMode();
  }
 catch (  ArangoException e) {
  }
  try {
    driver.deleteCollection(colName);
  }
 catch (  ArangoException e) {
  }
}
Program: 32882
Project: 32882
Buggy source:
@After public void after(){
}

Fixed version (ground truth):
@After public void after(){
  try {
    driver.cancelBatchMode();
  }
 catch (  ArangoException e) {
  }
  try {
    driver.deleteCollection(colName);
  }
 catch (  ArangoException e) {
  }
}
Program: 32883
Project: 32883
Buggy source:
private static <T extends BaseEntity>T deserializeBaseParameter(JsonObject obj,T entity){
  if (obj.has("String_Node_Str")) {
    entity.error=obj.getAsJsonPrimitive("String_Node_Str").getAsBoolean();
  }
  if (obj.has("String_Node_Str")) {
    entity.code=obj.getAsJsonPrimitive("String_Node_Str").getAsInt();
  }
  if (obj.has("String_Node_Str")) {
    entity.errorNumber=obj.getAsJsonPrimitive("String_Node_Str").getAsInt();
  }
  if (obj.has("String_Node_Str")) {
    entity.errorMessage=obj.getAsJsonPrimitive("String_Node_Str").getAsString();
  }
  if (obj.has("String_Node_Str")) {
    entity.etag=obj.getAsJsonPrimitive("String_Node_Str").getAsLong();
  }
  return entity;
}

Fixed version (ground truth):
private static <T extends BaseEntity>T deserializeBaseParameter(JsonObject obj,T entity){
  if (obj.has("String_Node_Str")) {
    entity.error=obj.getAsJsonPrimitive("String_Node_Str").getAsBoolean();
  }
  if (obj.has("String_Node_Str") && obj.getAsJsonPrimitive("String_Node_Str").isNumber()) {
    entity.code=obj.getAsJsonPrimitive("String_Node_Str").getAsInt();
  }
  if (obj.has("String_Node_Str") && obj.getAsJsonPrimitive("String_Node_Str").isNumber()) {
    entity.errorNumber=obj.getAsJsonPrimitive("String_Node_Str").getAsInt();
  }
  if (obj.has("String_Node_Str")) {
    entity.errorMessage=obj.getAsJsonPrimitive("String_Node_Str").getAsString();
  }
  if (obj.has("String_Node_Str") && obj.getAsJsonPrimitive("String_Node_Str").isNumber()) {
    entity.etag=obj.getAsJsonPrimitive("String_Node_Str").getAsLong();
  }
  return entity;
}
Program: 32884
Project: 32884
Buggy source:
/** 
 * This method returns the result of a call to ArangoDB executed within a batch request.
 * @param String requestId - the id of a request.
 * @return <T> - A generic return value, containing the result.
 * @see ArangoDriver#startBatchMode()
 * @see ArangoDriver#executeBatch()
 * @see com.arangodb.ArangoDriver#cancelBatchMode()
 * @throws com.arangodb.ArangoException
 */
public <T>T getBatchResponseByRequestId(String requestId) throws ArangoException {
  BatchResponseEntity batchResponseEntity=this.batchDriver.getBatchResponseListEntity().getResponseFromRequestId(requestId);
  try {
    this.httpManager.setPreDefinedResponse(batchResponseEntity.getHttpResponseEntity());
    return (T)batchResponseEntity.getInvocationObject().getMethod().invoke(batchResponseEntity.getInvocationObject().getArangoDriver(),batchResponseEntity.getInvocationObject().getArgs());
  }
 catch (  Exception e) {
    throw new ArangoException(e);
  }
}

Fixed version (ground truth):
/** 
 * This method returns the result of a call to ArangoDB executed within a batch request.
 * @param String requestId - the id of a request.
 * @return <T> - A generic return value, containing the result.
 * @see ArangoDriver#startBatchMode()
 * @see ArangoDriver#executeBatch()
 * @see com.arangodb.ArangoDriver#cancelBatchMode()
 * @throws com.arangodb.ArangoException
 */
public <T>T getBatchResponseByRequestId(String requestId) throws ArangoException {
  BatchResponseEntity batchResponseEntity=this.batchDriver.getBatchResponseListEntity().getResponseFromRequestId(requestId);
  try {
    this.httpManager.setPreDefinedResponse(batchResponseEntity.getHttpResponseEntity());
    return (T)batchResponseEntity.getInvocationObject().getMethod().invoke(batchResponseEntity.getInvocationObject().getArangoDriver(),batchResponseEntity.getInvocationObject().getArgs());
  }
 catch (  InvocationTargetException e) {
    return (T)createEntity(batchResponseEntity.getHttpResponseEntity(),(Class)DefaultEntity.class);
  }
catch (  Exception e) {
    throw new ArangoException(e);
  }
}
Program: 32885
Project: 32885
Buggy source:
public DefaultEntity executeBatch() throws ArangoException {
  if (!this.httpManager.getClass().getSimpleName().equals("String_Node_Str")) {
    throw new ArangoException("String_Node_Str");
  }
  List<BatchPart> callStack=((BatchHttpManager)this.httpManager).getCallStack();
  this.cancelBatchMode();
  DefaultEntity result=this.batchDriver.executeBatch(callStack);
  return result;
}

Fixed version (ground truth):
public DefaultEntity executeBatch() throws ArangoException {
  if (!this.httpManager.getClass().getSimpleName().equals("String_Node_Str")) {
    throw new ArangoException("String_Node_Str");
  }
  List<BatchPart> callStack=((BatchHttpManager)this.httpManager).getCallStack();
  this.cancelBatchMode();
  DefaultEntity result=this.batchDriver.executeBatch(callStack,this.getDefaultDatabase());
  return result;
}
Program: 32886
Project: 32886
Buggy source:
@Override public Object invoke(Object proxy,Method method,Object[] args) throws Throwable {
  if (Object.class == method.getDeclaringClass()) {
    String name=method.getName();
    if ("String_Node_Str".equals(name)) {
      return proxy == args[0];
    }
 else     if ("String_Node_Str".equals(name)) {
      return System.identityHashCode(proxy);
    }
 else     if ("String_Node_Str".equals(name)) {
      return proxy.getClass().getName() + "String_Node_Str" + Integer.toHexString(System.identityHashCode(proxy))+ "String_Node_Str"+ this;
    }
 else {
      throw new IllegalStateException(String.valueOf(method));
    }
  }
  System.out.println("String_Node_Str");
  System.out.println(method.toGenericString());
  System.out.println(method.getDeclaringClass());
  for (  Object o : args) {
    System.out.println(o);
  }
  testImpl.getHttpManager().setCurrentObject(new InvocationObject(method,testImpl,args));
  return method.invoke(testImpl,args);
}

Fixed version (ground truth):
@Override public Object invoke(Object proxy,Method method,Object[] args) throws Throwable {
  if (Object.class == method.getDeclaringClass()) {
    String name=method.getName();
    if ("String_Node_Str".equals(name)) {
      return proxy == args[0];
    }
 else     if ("String_Node_Str".equals(name)) {
      return System.identityHashCode(proxy);
    }
 else     if ("String_Node_Str".equals(name)) {
      return proxy.getClass().getName() + "String_Node_Str" + Integer.toHexString(System.identityHashCode(proxy))+ "String_Node_Str"+ this;
    }
 else {
      throw new IllegalStateException(String.valueOf(method));
    }
  }
  testImpl.getHttpManager().setCurrentObject(new InvocationObject(method,testImpl,args));
  return method.invoke(testImpl,args);
}
Program: 32889
Project: 32889
Buggy source:
@Before public void before() throws ArangoException {
  for (  String col : new String[]{"String_Node_Str"}) {
    try {
      driver.deleteCollection(col);
    }
 catch (    ArangoException e) {
      System.out.println(driver.getDefaultDatabase() + e);
    }
  }
  logger.debug("String_Node_Str");
}

Fixed version (ground truth):
@Before public void before() throws ArangoException {
  for (  String col : new String[]{"String_Node_Str"}) {
    try {
      driver.deleteCollection(col);
    }
 catch (    ArangoException e) {
    }
  }
  logger.debug("String_Node_Str");
}
Program: 32890
Project: 32890
Buggy source:
private static void parseValue(PsiBuilder builder){
  if (builder.getTokenType() == ShaderLabTokens.LBRACKET) {
    ShaderLabParser.parseBracketReference(builder);
  }
 else {
    ShaderLabParser.validateIdentifier(builder,ourFactors);
  }
}

Fixed version (ground truth):
private static void parseValue(PsiBuilder builder){
  if (builder.getTokenType() == ShaderLabTokens.LBRACKET) {
    ShaderLabParser.parseBracketReference(builder);
  }
 else   if (builder.getTokenType() == ShaderLabTokens.IDENTIFIER) {
    ShaderLabParser.validateIdentifier(builder,ourFactors);
  }
 else {
    builder.error("String_Node_Str");
  }
}
Program: 32892
Project: 32892
Buggy source:
@Override public boolean visitFile(@NotNull VirtualFile file){
  if (file.getFileType() == fileType) {
    if (virtualFilesByModule.containsScalarValue(file)) {
      return true;
    }
    virtualFilesByModule.putValue(module,file);
    layer.addContentEntry(file);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean visitFile(@NotNull VirtualFile file){
  if (file.getFileType() == fileType) {
    if (virtualFilesByModule.containsScalarValue(file)) {
      return true;
    }
    virtualFilesByModule.putValue(module,file);
    toAdd.add(file);
  }
  return true;
}
Program: 32895
Project: 32895
Buggy source:
@Override public void onFinish(){
  Logger.d(TAG,"String_Node_Str");
  closeActivity();
}

Fixed version (ground truth):
@Override public void onFinish(){
  Logger.d(TAG,"String_Node_Str");
  CountdownTimerActivity.this.mSecondsWheel.setText("String_Node_Str");
  CountdownTimerActivity.this.mSecondsWheel.setProgress(0);
}
Program: 32896
Project: 32896
Buggy source:
private void configureViews(){
  this.mCountdownNote=(TextView)findViewById(R.id.activity_countdown_timer_note);
  this.mDaysWheel=(ProgressWheel)findViewById(R.id.activity_countdown_timer_days);
  this.mHoursWheel=(ProgressWheel)findViewById(R.id.activity_countdown_timer_hours);
  this.mMinutesWheel=(ProgressWheel)findViewById(R.id.activity_countdown_timer_minutes);
  this.mSecondsWheel=(ProgressWheel)findViewById(R.id.activity_countdown_timer_seconds);
  this.mDaysLabel=(TextView)findViewById(R.id.activity_countdown_timer_days_text);
  this.mHoursLabel=(TextView)findViewById(R.id.activity_countdown_timer_hours_text);
  this.mMinutesLabel=(TextView)findViewById(R.id.activity_countdown_timer_minutes_text);
  this.mSecondsLabel=(TextView)findViewById(R.id.activity_countdown_timer_seconds_text);
}

Fixed version (ground truth):
private void configureViews(){
  this.conferenceTime.setToNow();
  this.year=conferenceTime.year;
  this.mCountdownNote=(TextView)findViewById(R.id.activity_countdown_timer_note);
  this.mDaysWheel=(ProgressWheel)findViewById(R.id.activity_countdown_timer_days);
  this.mHoursWheel=(ProgressWheel)findViewById(R.id.activity_countdown_timer_hours);
  this.mMinutesWheel=(ProgressWheel)findViewById(R.id.activity_countdown_timer_minutes);
  this.mSecondsWheel=(ProgressWheel)findViewById(R.id.activity_countdown_timer_seconds);
  this.mDaysLabel=(TextView)findViewById(R.id.activity_countdown_timer_days_text);
  this.mHoursLabel=(TextView)findViewById(R.id.activity_countdown_timer_hours_text);
  this.mMinutesLabel=(TextView)findViewById(R.id.activity_countdown_timer_minutes_text);
  this.mSecondsLabel=(TextView)findViewById(R.id.activity_countdown_timer_seconds_text);
}
Program: 32898
Project: 32898
Buggy source:
public WeightedInput(Stream<Pair<Double,Integer>> stream){
  final int numBuckets=10000;
  double bucketLength=1.0 / numBuckets;
  double[] locations=new double[numBuckets];
  for (int i=0; i < numBuckets; i++) {
    locations[i]=i * bucketLength + 0.5 * bucketLength;
  }
  BucketInfo empty=new BucketInfo(numBuckets);
  BucketInfo total;
  total=stream.map(doubleIntegerPair -> {
    double probs=doubleIntegerPair.getFirst();
    double[] sum=new double[numBuckets];
    double[] sumProbs=new double[numBuckets];
    double[] count=new double[numBuckets];
    int index=(int)Math.floor(probs / bucketLength);
    if (index < 0) {
      index=0;
    }
    if (index >= numBuckets) {
      index=numBuckets - 1;
    }
    count[index]+=1;
    sumProbs[index]+=probs;
    sum[index]+=doubleIntegerPair.getSecond();
    return new BucketInfo(count,sum,sumProbs);
  }
).reduce(empty,BucketInfo::add,BucketInfo::add);
  double[] counts=total.counts;
  double[] sums=total.sums;
  this.countsNonEmpty=IntStream.range(0,counts.length).filter(i -> counts[i] != 0).mapToDouble(i -> counts[i]).toArray();
  this.locationNonEmpty=IntStream.range(0,counts.length).filter(i -> counts[i] != 0).mapToDouble(i -> locations[i]).toArray();
  double[] sumNonempty=IntStream.range(0,counts.length).filter(i -> counts[i] != 0).mapToDouble(i -> sums[i]).toArray();
  this.accsNonempty=IntStream.range(0,countsNonEmpty.length).mapToDouble(i -> sumNonempty[i] / countsNonEmpty[i]).toArray();
}

Fixed version (ground truth):
public WeightedInput(Stream<Pair<Double,Integer>> stream){
  final int numBuckets=10000;
  double bucketLength=1.0 / numBuckets;
  double[] locations=new double[numBuckets];
  for (int i=0; i < numBuckets; i++) {
    locations[i]=i * bucketLength + 0.5 * bucketLength;
  }
  BucketInfo total;
  total=stream.collect(() -> new BucketInfo(numBuckets),BucketInfo::add,BucketInfo::addAll);
  double[] counts=total.counts;
  double[] sums=total.sums;
  this.countsNonEmpty=IntStream.range(0,counts.length).filter(i -> counts[i] != 0).mapToDouble(i -> counts[i]).toArray();
  this.locationNonEmpty=IntStream.range(0,counts.length).filter(i -> counts[i] != 0).mapToDouble(i -> locations[i]).toArray();
  double[] sumNonempty=IntStream.range(0,counts.length).filter(i -> counts[i] != 0).mapToDouble(i -> sums[i]).toArray();
  this.accsNonempty=IntStream.range(0,countsNonEmpty.length).mapToDouble(i -> sumNonempty[i] / countsNonEmpty[i]).toArray();
}
Program: 32899
Project: 32899
Buggy source:
public static BucketInfo add(BucketInfo bucketInfo1,BucketInfo bucketInfo2){
  BucketInfo bucketInfo=new BucketInfo(bucketInfo1.counts.length);
  for (int i=0; i < bucketInfo1.counts.length; i++) {
    bucketInfo.counts[i]=bucketInfo1.counts[i] + bucketInfo2.counts[i];
    bucketInfo.sums[i]=bucketInfo1.sums[i] + bucketInfo2.sums[i];
    bucketInfo.sumProbs[i]=bucketInfo1.sumProbs[i] + bucketInfo2.sumProbs[i];
  }
  return bucketInfo;
}

Fixed version (ground truth):
public void add(Pair<Double,Integer> pair){
  final int numBuckets=this.counts.length;
  double bucketLength=1.0 / numBuckets;
  double prob=pair.getFirst();
  int index=(int)Math.floor(prob / bucketLength);
  if (index < 0) {
    index=0;
  }
  if (index >= numBuckets) {
    index=numBuckets - 1;
  }
  this.counts[index]+=1;
  this.sumProbs[index]+=prob;
  this.sums[index]+=pair.getSecond();
}
Program: 32901
Project: 32901
Buggy source:
public BucketInfo getBucketInfo(MultiLabelClfDataSet multiLabelClfDataSet){
  final int numBuckets=10;
  double bucketLength=1.0 / numBuckets;
  BucketInfo empty=new BucketInfo(numBuckets);
  BucketInfo total;
  total=IntStream.range(0,multiLabelClfDataSet.getNumDataPoints()).parallel().mapToObj(i -> {
    double[] probs=imlGradientBoosting.predictClassProbs(multiLabelClfDataSet.getRow(i));
    double[] calibratedProbs=IntStream.range(0,probs.length).mapToDouble(j -> isotonicRegressionList.get(j).predict(probs[j])).toArray();
    double[] count=new double[numBuckets];
    double[] sum=new double[numBuckets];
    double[] sumProbs=new double[numBuckets];
    for (int a=0; a < probs.length; a++) {
      int index=(int)Math.floor(calibratedProbs[a] / bucketLength);
      if (index < 0) {
        index=0;
      }
      if (index >= numBuckets) {
        index=numBuckets - 1;
      }
      count[index]+=1;
      sumProbs[index]+=calibratedProbs[a];
      if (multiLabelClfDataSet.getMultiLabels()[i].matchClass(a)) {
        sum[index]+=1;
      }
 else {
        sum[index]+=0;
      }
    }
    return new BucketInfo(count,sum,sumProbs);
  }
).reduce(empty,BucketInfo::add,BucketInfo::add);
  return total;
}

Fixed version (ground truth):
public BucketInfo getBucketInfo(MultiLabelClfDataSet multiLabelClfDataSet){
  final int numBuckets=10;
  double bucketLength=1.0 / numBuckets;
  BucketInfo empty=new BucketInfo(numBuckets);
  BucketInfo total;
  total=IntStream.range(0,multiLabelClfDataSet.getNumDataPoints()).parallel().mapToObj(i -> {
    double[] probs=imlGradientBoosting.predictClassProbs(multiLabelClfDataSet.getRow(i));
    double[] calibratedProbs=IntStream.range(0,probs.length).mapToDouble(j -> isotonicRegressionList.get(j).predict(probs[j])).toArray();
    double[] count=new double[numBuckets];
    double[] sum=new double[numBuckets];
    double[] sumProbs=new double[numBuckets];
    for (int a=0; a < probs.length; a++) {
      int index=(int)Math.floor(calibratedProbs[a] / bucketLength);
      if (index < 0) {
        index=0;
      }
      if (index >= numBuckets) {
        index=numBuckets - 1;
      }
      count[index]+=1;
      sumProbs[index]+=calibratedProbs[a];
      if (multiLabelClfDataSet.getMultiLabels()[i].matchClass(a)) {
        sum[index]+=1;
      }
 else {
        sum[index]+=0;
      }
    }
    return new BucketInfo(count,sum,sumProbs);
  }
).collect(() -> new BucketInfo(numBuckets),BucketInfo::addAll,BucketInfo::addAll);
  return total;
}
Program: 32902
Project: 32902
Buggy source:
public static void main(String[] args){
}

Fixed version (ground truth):
public static void main(String[] args) throws Exception {
  List<String> lines=FileUtils.readLines(new File("String_Node_Str"));
  int dim=lines.get(0).split("String_Node_Str").length;
  int rows=1000;
  RealMatrix data=new Array2DRowRealMatrix(rows,dim);
  for (int i=0; i < rows; i++) {
    String[] split=lines.get(i).split("String_Node_Str");
    for (int j=0; j < dim; j++) {
      data.setEntry(i,j,Double.parseDouble(split[j]) + Math.random());
    }
  }
  GMM gmm=new GMM(dim,5);
  GMMTrainer trainer=new GMMTrainer(data,gmm);
  for (int i=1; i <= 3; i++) {
    System.out.println("String_Node_Str" + i);
    trainer.iterate();
    double logLikelihood=IntStream.range(0,rows).parallel().mapToDouble(j -> gmm.logDensity(data.getRowVector(j))).sum();
    System.out.println("String_Node_Str" + logLikelihood);
    Serialization.serialize(gmm,"String_Node_Str" + i);
  }
  System.out.println(gmm);
  System.out.println(gmm.getGaussianDistributions()[0].getInverseCovariance());
  System.out.println(Arrays.toString(gmm.posteriors(data.getRowVector(0))));
  System.out.println(gmm.getGaussianDistributions()[0].logDensity(data.getRowVector(0)));
  FileUtils.writeStringToFile(new File("String_Node_Str"),gmm.toString());
  System.out.println(gmm);
}
Program: 32903
Project: 32903
Buggy source:
private double logDensity(RealVector instance){
  double[] arr=new double[numComponents];
  for (int k=0; k < numComponents; k++) {
    arr[k]=Math.log(mixtureCoefficients[k]) + gaussianDistributions[k].logDensity(instance);
  }
  return MathUtil.logSumExp(arr);
}

Fixed version (ground truth):
public double logDensity(RealVector instance){
  double[] arr=new double[numComponents];
  for (int k=0; k < numComponents; k++) {
    arr[k]=Math.log(mixtureCoefficients[k]) + gaussianDistributions[k].logDensity(instance);
  }
  return MathUtil.logSumExp(arr);
}
Program: 32904
Project: 32904
Buggy source:
@Override public String toString(){
  final StringBuilder sb=new StringBuilder("String_Node_Str");
  sb.append("String_Node_Str").append(numComponents);
  sb.append("String_Node_Str").append(Arrays.toString(gaussianDistributions));
  sb.append("String_Node_Str").append(Arrays.toString(mixtureCoefficients));
  sb.append('}');
  return sb.toString();
}

Fixed version (ground truth):
@Override public String toString(){
  final StringBuilder sb=new StringBuilder("String_Node_Str");
  sb.append("String_Node_Str").append(numComponents).append("String_Node_Str");
  for (int k=0; k < numComponents; k++) {
    sb.append("String_Node_Str" + k).append("String_Node_Str");
    sb.append("String_Node_Str" + mixtureCoefficients[k]).append("String_Node_Str");
    sb.append("String_Node_Str" + gaussianDistributions[k].getMean()).append("String_Node_Str");
    sb.append("String_Node_Str" + gaussianDistributions[k].getCovariance()).append("String_Node_Str");
  }
  sb.append('}');
  return sb.toString();
}
Program: 32905
Project: 32905
Buggy source:
double[] posteriors(RealVector instance){
  double[] arr=new double[numComponents];
  for (int k=0; k < numComponents; k++) {
    arr[k]=Math.log(mixtureCoefficients[k]) + gaussianDistributions[k].logDensity(instance);
  }
  double[] posteriors=new double[numComponents];
  double logDenominator=MathUtil.logSumExp(arr);
  for (int k=0; k < numComponents; k++) {
    posteriors[k]=Math.exp(arr[k] - logDenominator);
  }
  return posteriors;
}

Fixed version (ground truth):
public double[] posteriors(RealVector instance){
  double[] arr=new double[numComponents];
  for (int k=0; k < numComponents; k++) {
    arr[k]=Math.log(mixtureCoefficients[k]) + gaussianDistributions[k].logDensity(instance);
  }
  double[] posteriors=new double[numComponents];
  double logDenominator=MathUtil.logSumExp(arr);
  for (int k=0; k < numComponents; k++) {
    posteriors[k]=Math.exp(arr[k] - logDenominator);
  }
  return posteriors;
}
Program: 32906
Project: 32906
Buggy source:
public GMMTrainer(RealMatrix data,GMM gmm){
  this.data=data;
  this.gmm=gmm;
  this.gammas=new double[data.getRowDimension()][gmm.getNumComponents()];
}

Fixed version (ground truth):
public GMMTrainer(RealMatrix data,GMM gmm){
  this.data=data;
  this.gmm=gmm;
  this.gammas=new double[data.getRowDimension()][gmm.getNumComponents()];
  this.stabilizer=new Array2DRowRealMatrix(data.getColumnDimension(),data.getColumnDimension());
  for (int i=0; i < stabilizer.getRowDimension(); i++) {
    stabilizer.setEntry(i,i,reg);
  }
}
Program: 32907
Project: 32907
Buggy source:
private void mStep(){
  IntStream.range(0,gmm.getNumComponents()).parallel().forEach(k -> {
    double sumGamma=computeSumGamma(k);
    gmm.setMixtureCoefficient(k,sumGamma / data.getRowDimension());
    RealVector mean=computeMean(k,sumGamma);
    gmm.getGaussianDistributions()[k].setMean(mean);
    RealMatrix cov=computeCov(k,mean,sumGamma);
    gmm.getGaussianDistributions()[k].setCovariance(cov);
  }
);
}

Fixed version (ground truth):
private void mStep(){
  IntStream.range(0,gmm.getNumComponents()).parallel().forEach(k -> {
    double sumGamma=computeSumGamma(k);
    gmm.setMixtureCoefficient(k,sumGamma / data.getRowDimension());
    RealVector mean=computeMean(k,sumGamma);
    gmm.getGaussianDistributions()[k].setMean(mean);
    RealMatrix cov=computeCov(k,mean,sumGamma);
    RealMatrix stabilizedCov=stablize(cov);
    gmm.getGaussianDistributions()[k].setCovariance(stabilizedCov);
  }
);
}
Program: 32908
Project: 32908
Buggy source:
void iterate(){
  eStep();
  mStep();
}

Fixed version (ground truth):
public void iterate(){
  eStep();
  mStep();
}
Program: 32909
Project: 32909
Buggy source:
public double logDensity(RealVector x){
  RealVector diff=x.subtract(mean);
  int dim=mean.getDimension();
  return -0.5 * dim * Math.log(2 * Math.PI) - 0.5 * Math.log(detCovariance) - 0.5 * (inverseCovariance.preMultiply(diff).dotProduct(diff));
}

Fixed version (ground truth):
public double logDensity(RealVector x){
  RealVector diff=x.subtract(mean);
  int dim=mean.getDimension();
  return -0.5 * dim * Math.log(2 * Math.PI) - 0.5 * logDeterminant - 0.5 * (inverseCovariance.preMultiply(diff).dotProduct(diff));
}
Program: 32910
Project: 32910
Buggy source:
public void setCovariance(RealMatrix covariance){
  this.covariance=covariance;
  LUDecomposition decomposition=new LUDecomposition(covariance);
  this.inverseCovariance=decomposition.getSolver().getInverse();
  this.detCovariance=decomposition.getDeterminant();
}

Fixed version (ground truth):
public void setCovariance(RealMatrix covariance){
  this.covariance=covariance;
  CholeskyDecomposition decomposition=new CholeskyDecomposition(covariance);
  this.inverseCovariance=decomposition.getSolver().getInverse();
  RealMatrix lMatrix=decomposition.getL();
  double sum=0;
  for (int i=0; i < lMatrix.getRowDimension(); i++) {
    sum+=Math.log(lMatrix.getEntry(i,i));
  }
  this.logDeterminant=2 * sum;
}
Program: 32911
Project: 32911
Buggy source:
public GaussianDistribution(RealVector mean,RealMatrix covariance){
  this.mean=mean;
  this.covariance=covariance;
  LUDecomposition decomposition=new LUDecomposition(covariance);
  this.inverseCovariance=decomposition.getSolver().getInverse();
  this.detCovariance=decomposition.getDeterminant();
}

Fixed version (ground truth):
public GaussianDistribution(RealVector mean,RealMatrix covariance){
  this.mean=mean;
  this.setCovariance(covariance);
}
Program: 32915
Project: 32915
Buggy source:
private Optional<Double> predictNoMissingValue(Vector vector){
  Node node=root;
  while (!node.isLeaf()) {
    int featureIndex=node.getFeatureIndex();
    double featureValue=vector.get(featureIndex);
    if (Double.isNaN(featureValue)) {
      return Optional.empty();
    }
    double threshold=node.getThreshold();
    Node child;
    if (featureValue <= threshold) {
      child=root.getLeftChild();
    }
 else {
      child=root.getRightChild();
    }
    node=child;
  }
  return Optional.of(node.getValue());
}

Fixed version (ground truth):
private Optional<Double> predictNoMissingValue(Vector vector){
  Node node=root;
  while (!node.isLeaf()) {
    int featureIndex=node.getFeatureIndex();
    double featureValue=vector.get(featureIndex);
    if (Double.isNaN(featureValue)) {
      return Optional.empty();
    }
    double threshold=node.getThreshold();
    Node child;
    if (featureValue <= threshold) {
      child=node.getLeftChild();
    }
 else {
      child=node.getRightChild();
    }
    node=child;
  }
  return Optional.of(node.getValue());
}
Program: 32916
Project: 32916
Buggy source:
public static void main(String[] args){
  new Visualizer();
  String defaultDir="String_Node_Str";
  File inputDir=getInputDir(defaultDir);
  Utilities.echo("String_Node_Str" + inputDir + "String_Node_Str");
  processFolder(inputDir);
}

Fixed version (ground truth):
public static void main(String[] args){
  new Visualizer();
  String defaultDir="String_Node_Str";
  File inputDir=getInputDir(defaultDir);
  Utilities.echo("String_Node_Str" + inputDir + "String_Node_Str");
  processFolder(inputDir);
  System.exit(0);
}
Program: 32918
Project: 32918
Buggy source:
public IMLGBTrainer(IMLGBConfig config,IMLGradientBoosting boosting){
  if (config.getDataSet().getNumClasses() != boosting.getNumClasses()) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.config=config;
  this.boosting=boosting;
  MultiLabelClfDataSet dataSet=config.getDataSet();
  boosting.setFeatureList(dataSet.getFeatureList());
  boosting.setLabelTranslator(dataSet.getLabelTranslator());
  int numClasses=dataSet.getNumClasses();
  int numDataPoints=dataSet.getNumDataPoints();
  this.scoreMatrix=new ScoreMatrix(numDataPoints,numClasses);
  if (config.usePrior() && boosting.getRegressors(0).size() == 0) {
    this.setPriorProbs(dataSet);
  }
  this.initStagedClassScoreMatrix(boosting);
  List<MultiLabel> assignments=DataSetUtil.gatherMultiLabels(dataSet);
  boosting.setAssignments(assignments);
  this.shouldStop=new boolean[numClasses];
}

Fixed version (ground truth):
public IMLGBTrainer(IMLGBConfig config,IMLGradientBoosting boosting){
  if (config.getDataSet().getNumClasses() != boosting.getNumClasses()) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.config=config;
  this.boosting=boosting;
  MultiLabelClfDataSet dataSet=config.getDataSet();
  boosting.setFeatureList(dataSet.getFeatureList());
  boosting.setLabelTranslator(dataSet.getLabelTranslator());
  int numClasses=dataSet.getNumClasses();
  int numDataPoints=dataSet.getNumDataPoints();
  this.scoreMatrix=new ScoreMatrix(numDataPoints,numClasses);
  if (config.usePrior() && boosting.getRegressors(0).size() == 0) {
    this.setPriorProbs(dataSet);
  }
  this.initStagedClassScoreMatrix(boosting);
  this.shouldStop=new boolean[numClasses];
}
Program: 32919
Project: 32919
Buggy source:
public static MultiLabelClfDataSet loadMultiLabelClfDataSet(String libSvmFile,boolean dense,int numFeatures,int numClasses) throws IOException, ClassNotFoundException {
  int numDatapoints=getNumDataPoints(libSvmFile);
  System.out.println("String_Node_Str" + numDatapoints);
  System.out.println("String_Node_Str" + numClasses);
  System.out.println("String_Node_Str" + numFeatures);
  MultiLabelClfDataSet dataSet=new MLClfDataSetBuilder().numClasses(numClasses).numFeatures(numFeatures).numDataPoints(numDatapoints).dense(dense).build();
  try (BufferedReader br=new BufferedReader(new FileReader(libSvmFile))){
    String line=null;
    int lineCount=0;
    while ((line=br.readLine()) != null) {
      String[] lineInfo=line.split("String_Node_Str");
      String labels=lineInfo[0];
      for (      String label : labels.split("String_Node_Str")) {
        int l=Integer.parseInt(label);
        dataSet.addLabel(lineCount,l - 1);
      }
      for (int i=1; i < lineInfo.length; i++) {
        String[] featureValue=lineInfo[i].split("String_Node_Str");
        int feature=Integer.parseInt(featureValue[0]);
        double value=Double.parseDouble(featureValue[1]);
        dataSet.setFeatureValue(lineCount,feature - 1,value);
      }
      lineCount++;
    }
    br.close();
  }
   return dataSet;
}

Fixed version (ground truth):
public static MultiLabelClfDataSet loadMultiLabelClfDataSet(String libSvmFile,boolean dense,int numFeatures,int numClasses) throws IOException, ClassNotFoundException {
  int numDatapoints=getNumDataPoints(libSvmFile);
  System.out.println("String_Node_Str" + numDatapoints);
  System.out.println("String_Node_Str" + numClasses);
  System.out.println("String_Node_Str" + numFeatures);
  MultiLabelClfDataSet dataSet=new MLClfDataSetBuilder().numClasses(numClasses).numFeatures(numFeatures).numDataPoints(numDatapoints).density(Density.SPARSE_RANDOM).build();
  try (BufferedReader br=new BufferedReader(new FileReader(libSvmFile))){
    String line=null;
    int lineCount=0;
    while ((line=br.readLine()) != null) {
      String[] lineInfo=line.split("String_Node_Str");
      String labels=lineInfo[0];
      for (      String label : labels.split("String_Node_Str")) {
        int l=Integer.parseInt(label);
        dataSet.addLabel(lineCount,l - 1);
      }
      for (int i=1; i < lineInfo.length; i++) {
        String[] featureValue=lineInfo[i].split("String_Node_Str");
        int feature=Integer.parseInt(featureValue[0]);
        double value=Double.parseDouble(featureValue[1]);
        dataSet.setFeatureValue(lineCount,feature - 1,value);
      }
      lineCount++;
    }
    br.close();
  }
   return dataSet;
}
Program: 32920
Project: 32920
Buggy source:
public MLACPlattScaling(MultiLabelClfDataSet dataSet,MultiLabelClassifier.ClassScoreEstimator scoreEstimator){
  this.scoreEstimator=scoreEstimator;
  MultiLabelClfDataSet scoreDataSet=MLClfDataSetBuilder.getBuilder().numDataPoints(dataSet.getNumDataPoints()).numFeatures(dataSet.getNumClasses()).numClasses(dataSet.getNumClasses()).dense(true).missingValue(false).build();
  for (int i=0; i < scoreDataSet.getNumDataPoints(); i++) {
    scoreDataSet.addLabels(i,dataSet.getMultiLabels()[i].getMatchedLabels());
  }
  for (int i=0; i < scoreDataSet.getNumDataPoints(); i++) {
    double[] scores=scoreEstimator.predictClassScores(dataSet.getRow(i));
    for (int k=0; k < scoreDataSet.getNumClasses(); k++) {
      scoreDataSet.setFeatureValue(i,k,scores[k]);
    }
  }
  MLLogisticTrainer trainer=MLLogisticTrainer.getBuilder().setGaussianPriorVariance(100000).build();
  List<MultiLabel> assignments=DataSetUtil.gatherMultiLabels(scoreDataSet);
  this.logisticRegression=trainer.train(scoreDataSet,assignments);
}

Fixed version (ground truth):
public MLACPlattScaling(MultiLabelClfDataSet dataSet,MultiLabelClassifier.ClassScoreEstimator scoreEstimator){
  this.scoreEstimator=scoreEstimator;
  MultiLabelClfDataSet scoreDataSet=MLClfDataSetBuilder.getBuilder().numDataPoints(dataSet.getNumDataPoints()).numFeatures(dataSet.getNumClasses()).numClasses(dataSet.getNumClasses()).missingValue(false).build();
  for (int i=0; i < scoreDataSet.getNumDataPoints(); i++) {
    scoreDataSet.addLabels(i,dataSet.getMultiLabels()[i].getMatchedLabels());
  }
  for (int i=0; i < scoreDataSet.getNumDataPoints(); i++) {
    double[] scores=scoreEstimator.predictClassScores(dataSet.getRow(i));
    for (int k=0; k < scoreDataSet.getNumClasses(); k++) {
      scoreDataSet.setFeatureValue(i,k,scores[k]);
    }
  }
  MLLogisticTrainer trainer=MLLogisticTrainer.getBuilder().setGaussianPriorVariance(100000).build();
  List<MultiLabel> assignments=DataSetUtil.gatherMultiLabels(scoreDataSet);
  this.logisticRegression=trainer.train(scoreDataSet,assignments);
}
Program: 32921
Project: 32921
Buggy source:
private static void test1(){
  MultiLabelClfDataSet dataSet=MLClfDataSetBuilder.getBuilder().numDataPoints(10).numFeatures(3).numClasses(4).dense(true).missingValue(false).build();
  System.out.println(dataSet.getMetaInfo());
}

Fixed version (ground truth):
private static void test1(){
  MultiLabelClfDataSet dataSet=MLClfDataSetBuilder.getBuilder().numDataPoints(10).numFeatures(3).numClasses(4).missingValue(false).build();
  System.out.println(dataSet.getMetaInfo());
}
Program: 32924
Project: 32924
Buggy source:
double logProbability(MultiLabel y){
  double[] logPs=new double[numComponents];
  for (int k=0; k < numComponents; k++) {
    logPs[k]=logProportions[k] + logYGivenComponent(y,k);
  }
  return MathUtil.logSumExp(logPs);
}

Fixed version (ground truth):
double logProbability(MultiLabel y){
  double[] logPs=new double[numComponents];
  for (int k=0; k < numComponents; k++) {
    logPs[k]=logProportions[k] + logYGivenComponent(y,k);
  }
  double logP=MathUtil.logSumExp(logPs);
  return logP;
}
Program: 32925
Project: 32925
Buggy source:
public static void main(String[] args){
  test6();
}

Fixed version (ground truth):
public static void main(String[] args){
  test7();
}
Program: 32926
Project: 32926
Buggy source:
public static Pair<BM,double[][]> selectAll(int numClasses,MultiLabel[] multiLabels,int numClusters){
  DataSet dataSet=DataSetBuilder.getBuilder().numDataPoints(multiLabels.length).numFeatures(numClasses).dense(false).build();
  for (int i=0; i < multiLabels.length; i++) {
    MultiLabel multiLabel=multiLabels[i];
    for (    int label : multiLabel.getMatchedLabels()) {
      dataSet.setFeatureValue(i,label,1);
    }
  }
  BMTrainer trainer=BMSelector.selectTrainer(dataSet,numClusters,10);
  Pair<BM,double[][]> pair=new Pair<>();
  pair.setFirst(trainer.getBm());
  pair.setSecond(trainer.gammas);
  return pair;
}

Fixed version (ground truth):
public static Pair<BM,double[][]> selectAll(int numClasses,MultiLabel[] multiLabels,int numClusters){
  DataSet dataSet=DataSetBuilder.getBuilder().numDataPoints(multiLabels.length).numFeatures(numClasses).density(Density.SPARSE_RANDOM).build();
  for (int i=0; i < multiLabels.length; i++) {
    MultiLabel multiLabel=multiLabels[i];
    for (    int label : multiLabel.getMatchedLabels()) {
      dataSet.setFeatureValue(i,label,1);
    }
  }
  BMTrainer trainer=BMSelector.selectTrainer(dataSet,numClusters,10);
  Pair<BM,double[][]> pair=new Pair<>();
  pair.setFirst(trainer.getBm());
  pair.setSecond(trainer.gammas);
  return pair;
}
Program: 32927
Project: 32927
Buggy source:
public static double[][] selectGammas(int numClasses,MultiLabel[] multiLabels,int numClusters){
  DataSet dataSet=DataSetBuilder.getBuilder().numDataPoints(multiLabels.length).numFeatures(numClasses).dense(false).build();
  for (int i=0; i < multiLabels.length; i++) {
    MultiLabel multiLabel=multiLabels[i];
    for (    int label : multiLabel.getMatchedLabels()) {
      dataSet.setFeatureValue(i,label,1);
    }
  }
  BMTrainer trainer=BMSelector.selectTrainer(dataSet,numClusters,10);
  return trainer.gammas;
}

Fixed version (ground truth):
public static double[][] selectGammas(int numClasses,MultiLabel[] multiLabels,int numClusters){
  DataSet dataSet=DataSetBuilder.getBuilder().numDataPoints(multiLabels.length).numFeatures(numClasses).density(Density.SPARSE_RANDOM).build();
  for (int i=0; i < multiLabels.length; i++) {
    MultiLabel multiLabel=multiLabels[i];
    for (    int label : multiLabel.getMatchedLabels()) {
      dataSet.setFeatureValue(i,label,1);
    }
  }
  BMTrainer trainer=BMSelector.selectTrainer(dataSet,numClusters,10);
  return trainer.gammas;
}
Program: 32928
Project: 32928
Buggy source:
public double getValue(){
  Double loss=0.0;
  int numData=this.updatedEmbeddingMatrix.getNumDataPoints();
  for (int i=0; i < numData; i++) {
    Vector q_i=this.updatedEmbeddingMatrix.getRow(i);
    Vector q_i_orig=this.embeddingMatrix.getRow(i);
    loss+=this.alpha * q_i.getDistanceSquared(q_i_orig);
    for (int j=0; j < numData; j++) {
      Vector q_j=this.updatedEmbeddingMatrix.getRow(j);
      double pi_x=this.projMatrix.getColumn(0).dot(q_i);
      double pi_y=this.projMatrix.getColumn(1).dot(q_i);
      double pj_x=this.projMatrix.getColumn(0).dot(q_j);
      double pj_y=this.projMatrix.getColumn(1).dot(q_j);
      double p_sq=(pi_x - pj_x) * (pi_x - pj_x) + (pi_y - pj_y) * (pi_y - pj_y);
      double d_sq=this.distMatrix.getRow(i).get(j) * this.distMatrix.getRow(i).get(j);
      loss+=this.beta * (p_sq - d_sq) * (p_sq - d_sq);
    }
  }
  System.out.println("String_Node_Str" + loss);
  return loss;
}

Fixed version (ground truth):
public double getValue(){
  Double loss=0.0;
  int numData=this.updatedEmbeddingMatrix.getNumDataPoints();
  for (int i=0; i < numData; i++) {
    Vector q_i=this.updatedEmbeddingMatrix.getRow(i);
    Vector q_i_orig=this.embeddingMatrix.getRow(i);
    loss+=this.alpha * q_i.getDistanceSquared(q_i_orig);
    for (int j=0; j < numData; j++) {
      Vector q_j=this.updatedEmbeddingMatrix.getRow(j);
      double pi_x=this.projMatrix.getColumn(0).dot(q_i);
      double pi_y=this.projMatrix.getColumn(1).dot(q_i);
      double pj_x=this.projMatrix.getColumn(0).dot(q_j);
      double pj_y=this.projMatrix.getColumn(1).dot(q_j);
      double p_sq=(pi_x - pj_x) * (pi_x - pj_x) + (pi_y - pj_y) * (pi_y - pj_y);
      double d_sq=this.distMatrix.getRow(i).get(j) * this.distMatrix.getRow(i).get(j);
      loss+=this.beta * (p_sq - d_sq) * (p_sq - d_sq);
    }
  }
  return loss;
}
Program: 32929
Project: 32929
Buggy source:
private Vector penaltyGradient(){
  Vector weightsVector=augmentedLR.getAllWeights();
  Vector penalty=new DenseVector(weightsVector.size());
  if (regularizeAll) {
    for (int d=0; d < numFeatures + numComponents; d++) {
      penalty.set(d,weightsVector.get(d) / priorGaussianVariance);
    }
  }
 else {
    for (int d=0; d < numFeatures; d++) {
      penalty.set(d,weightsVector.get(d) / priorGaussianVariance);
    }
  }
  return penalty;
}

Fixed version (ground truth):
private Vector penaltyGradient(){
  Vector weightsVector=augmentedLR.getAllWeights();
  Vector penaltyGradient=new DenseVector(weightsVector.size());
  if (regularizeAll) {
    for (int d=0; d < numFeatures + numComponents; d++) {
      penaltyGradient.set(d,weightsVector.get(d) / priorGaussianVariance);
    }
  }
 else {
    for (int d=0; d < numFeatures; d++) {
      penaltyGradient.set(d,weightsVector.get(d) / priorGaussianVariance);
    }
  }
  return penaltyGradient;
}
Program: 32931
Project: 32931
Buggy source:
private BinaryTaskResult updateBinaryLogisticRegression(int componentIndex,int labelIndex,LogisticRegression logisticRegression,MultiLabelClfDataSet dataSet,double[] weights,double[][] targets,double variance){
  RidgeLogisticOptimizer ridgeLogisticOptimizer;
  ridgeLogisticOptimizer=new RidgeLogisticOptimizer(logisticRegression,dataSet,weights,targets,variance,false);
  ridgeLogisticOptimizer.getOptimizer().getTerminator().setMaxIteration(15);
  ridgeLogisticOptimizer.optimize();
  return new BinaryTaskResult(componentIndex,labelIndex,logisticRegression);
}

Fixed version (ground truth):
private static BinaryTaskResult updateBinaryLogisticRegression(int componentIndex,int labelIndex,LogisticRegression logisticRegression,MultiLabelClfDataSet dataSet,double[] weights,double[][] targets,double variance){
  RidgeLogisticOptimizer ridgeLogisticOptimizer;
  ridgeLogisticOptimizer=new RidgeLogisticOptimizer(logisticRegression,dataSet,weights,targets,variance,false);
  ridgeLogisticOptimizer.getOptimizer().getTerminator().setMaxIteration(15);
  ridgeLogisticOptimizer.optimize();
  return new BinaryTaskResult(componentIndex,labelIndex,logisticRegression);
}
Program: 32932
Project: 32932
Buggy source:
public BinaryTask(int componentIndex,int classIndex){
  this.componentIndex=componentIndex;
  this.classIndex=classIndex;
}

Fixed version (ground truth):
public BinaryTask(int componentIndex,int classIndex,LogisticRegression logisticRegression,double[] weights){
  this.componentIndex=componentIndex;
  this.classIndex=classIndex;
  this.logisticRegression=logisticRegression;
  this.weights=weights;
}
Program: 32933
Project: 32933
Buggy source:
private void updateBinaryClassifiers(){
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str");
  }
  List<BinaryTask> binaryTaskList=new ArrayList<>();
  for (int k=0; k < cbm.numComponents; k++) {
    for (int l=0; l < cbm.numLabels; l++) {
      binaryTaskList.add(new BinaryTask(k,l));
    }
  }
  Classifier.ProbabilityEstimator[][] localBinaryClassifiers=cbm.binaryClassifiers;
  double[][] localGammasT=gammasT;
  Broadcast<MultiLabelClfDataSet> localDataSetBroadcast=dataSetBroadCast;
  Broadcast<double[][][]> localTargetsBroadcast=targetDisBroadCast;
  double localVariance=priorVarianceBinary;
  JavaRDD<BinaryTask> binaryTaskRDD=sparkContext.parallelize(binaryTaskList,binaryTaskList.size());
  List<BinaryTaskResult> results=binaryTaskRDD.map(binaryTask -> {
    int componentIndex=binaryTask.componentIndex;
    int labelIndex=binaryTask.classIndex;
    LogisticRegression logisticRegression=(LogisticRegression)localBinaryClassifiers[componentIndex][labelIndex];
    double[] weights=localGammasT[componentIndex];
    return updateBinaryLogisticRegression(binaryTask.componentIndex,binaryTask.classIndex,logisticRegression,localDataSetBroadcast.value(),weights,localTargetsBroadcast.value()[labelIndex],localVariance);
  }
).collect();
  for (  BinaryTaskResult result : results) {
    cbm.binaryClassifiers[result.componentIndex][result.classIndex]=result.binaryClassifier;
  }
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str");
  }
}

Fixed version (ground truth):
private void updateBinaryClassifiers(){
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str");
  }
  Classifier.ProbabilityEstimator[][] localBinaryClassifiers=cbm.binaryClassifiers;
  double[][] localGammasT=gammasT;
  Broadcast<MultiLabelClfDataSet> localDataSetBroadcast=dataSetBroadCast;
  Broadcast<double[][][]> localTargetsBroadcast=targetDisBroadCast;
  double localVariance=priorVarianceBinary;
  List<BinaryTask> binaryTaskList=new ArrayList<>();
  for (int k=0; k < cbm.numComponents; k++) {
    for (int l=0; l < cbm.numLabels; l++) {
      LogisticRegression logisticRegression=(LogisticRegression)localBinaryClassifiers[k][l];
      double[] weights=localGammasT[k];
      binaryTaskList.add(new BinaryTask(k,l,logisticRegression,weights));
    }
  }
  JavaRDD<BinaryTask> binaryTaskRDD=sparkContext.parallelize(binaryTaskList,binaryTaskList.size());
  List<BinaryTaskResult> results=binaryTaskRDD.map(binaryTask -> {
    int labelIndex=binaryTask.classIndex;
    return updateBinaryLogisticRegression(binaryTask.componentIndex,binaryTask.classIndex,binaryTask.logisticRegression,localDataSetBroadcast.value(),binaryTask.weights,localTargetsBroadcast.value()[labelIndex],localVariance);
  }
).collect();
  for (  BinaryTaskResult result : results) {
    cbm.binaryClassifiers[result.componentIndex][result.classIndex]=result.binaryClassifier;
  }
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str");
  }
}
Program: 32934
Project: 32934
Buggy source:
public CBMNoiseOptimizerFixed(CBM cbm,MultiLabelClfDataSet dataSet,MultiLabelClfDataSet dataSetGroundTruth,MultiLabelClassifier.AssignmentProbEstimator classifier){
  this.cbm=cbm;
  this.dataSet=dataSet;
  this.combinations=DataSetUtil.gatherMultiLabels(dataSetGroundTruth);
  this.terminator=new Terminator();
  this.terminator.setGoal(Terminator.Goal.MINIMIZE);
  this.gammas=new double[dataSet.getNumDataPoints()][cbm.getNumComponents()];
  this.gammasT=new double[cbm.getNumComponents()][dataSet.getNumDataPoints()];
  this.binaryTargetsDistributions=new double[cbm.getNumClasses()][dataSet.getNumDataPoints()][2];
  this.scores=new double[dataSet.getNumDataPoints()][combinations.size()];
  for (int i=0; i < dataSet.getNumDataPoints(); i++) {
    for (int j=0; j < combinations.size(); j++) {
      MultiLabel truth=dataSet.getMultiLabels()[i];
      MultiLabel combination=combinations.get(j);
      double f=classifier.predictLogAssignmentProb(combination.toVector(dataSet.getNumFeatures()),truth);
      scores[i][j]=f;
    }
  }
  this.targets=new double[dataSet.getNumDataPoints()][combinations.size()];
  this.probabilities=new double[dataSet.getNumDataPoints()][combinations.size()];
  this.updateProbabilities();
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str");
  }
}

Fixed version (ground truth):
public CBMNoiseOptimizerFixed(CBM cbm,MultiLabelClfDataSet dataSet,MultiLabelClfDataSet dataSetGroundTruth,MultiLabelClassifier.AssignmentProbEstimator classifier){
  this.cbm=cbm;
  this.dataSet=dataSet;
  this.combinations=DataSetUtil.gatherMultiLabels(dataSetGroundTruth);
  this.terminator=new Terminator();
  this.terminator.setGoal(Terminator.Goal.MINIMIZE);
  this.gammas=new double[dataSet.getNumDataPoints()][cbm.getNumComponents()];
  this.gammasT=new double[cbm.getNumComponents()][dataSet.getNumDataPoints()];
  this.binaryTargetsDistributions=new double[cbm.getNumClasses()][dataSet.getNumDataPoints()][2];
  this.scores=new double[dataSet.getNumDataPoints()][combinations.size()];
  for (int i=0; i < dataSet.getNumDataPoints(); i++) {
    for (int j=0; j < combinations.size(); j++) {
      MultiLabel truth=dataSet.getMultiLabels()[i];
      MultiLabel combination=combinations.get(j);
      double f=classifier.predictAssignmentProb(combination.toVector(dataSet.getNumFeatures()),truth);
      scores[i][j]=f;
    }
  }
  this.targets=new double[dataSet.getNumDataPoints()][combinations.size()];
  this.probabilities=new double[dataSet.getNumDataPoints()][combinations.size()];
  this.updateProbabilities();
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str");
  }
}
Program: 32935
Project: 32935
Buggy source:
public static void main(String[] args){
  test1();
}

Fixed version (ground truth):
public static void main(String[] args) throws Exception {
  test3();
}