nus-yam/ex-repair huggingface dataset:
Program: 117162
Project: 117162
Buggy source:
public static void stopTimer(){
  if (!timerRunning) {
    LogHelper.error("String_Node_Str");
    return;
  }
  long ns=System.nanoTime() - startTime;
  String value;
  long ms=1000000;
  long s=ms * 1000;
  if (ns > s) {
    value=Utils.round(ns / (double)s,1000) + "String_Node_Str";
  }
 else   if (ns > 1000) {
    value=Utils.round(ns / (double)ms,10000) + "String_Node_Str";
  }
 else {
    value=ns + "String_Node_Str";
  }
  dev("String_Node_Str" + timerName + "String_Node_Str"+ value);
  timerRunning=false;
}

Fixed version (ground truth):
public static void stopTimer(){
  if (!timerRunning) {
    LogHelper.error("String_Node_Str");
    return;
  }
  long ns=System.nanoTime() - startTime;
  String value;
  long ms=1000000;
  long s=ms * 1000;
  if (ns > s) {
    value=Utils.round(ns / (double)s,1000) + "String_Node_Str";
  }
 else   if (ns > 1000) {
    value=Utils.round(ns / (double)ms,10000) + "String_Node_Str";
  }
 else {
    value=ns + "String_Node_Str";
  }
  info("String_Node_Str" + timerName + "String_Node_Str"+ value);
  timerRunning=false;
}
Program: 117164
Project: 117164
Buggy source:
@Override public Class<?> getTileEntityClass(){
  LogHelper.info("String_Node_Str");
  return IDEPeripheral.class;
}

Fixed version (ground truth):
@Override public Class<?> getTileEntityClass(){
  return IDEPeripheral.class;
}
Program: 117165
Project: 117165
Buggy source:
@Override public ManagedEnvironment createEnvironment(World world,BlockPos pos,EnumFacing side){
  LogHelper.info("String_Node_Str");
  return new DEManagedPeripheral((IDEPeripheral)world.getTileEntity(pos));
}

Fixed version (ground truth):
@Override public ManagedEnvironment createEnvironment(World world,BlockPos pos,EnumFacing side){
  return new DEManagedPeripheral((IDEPeripheral)world.getTileEntity(pos));
}
Program: 117166
Project: 117166
Buggy source:
@Optional.Method(modid="String_Node_Str") public static void initOC(){
  LogHelper.info("String_Node_Str");
  Driver.add(new OCAdapter());
}

Fixed version (ground truth):
@Optional.Method(modid="String_Node_Str") public static void initOC(){
  Driver.add(new OCAdapter());
}
Program: 117168
Project: 117168
Buggy source:
public static ItemStack changeMode(ItemStack stack,EntityPlayer player,boolean hasOblit,int maxSize){
  if (player.isSneaking()) {
    if (ItemNBTHelper.getShort(stack,"String_Node_Str",(short)0) < maxSize)     ItemNBTHelper.setShort(stack,"String_Node_Str",(short)(ItemNBTHelper.getShort(stack,"String_Node_Str",(short)0) + 1));
 else     ItemNBTHelper.setShort(stack,"String_Node_Str",(short)0);
    if (!player.worldObj.isRemote)     player.addChatMessage(new ChatComponentTranslation("String_Node_Str" + ItemNBTHelper.getShort(stack,"String_Node_Str",(short)0) + "String_Node_Str"));
  }
 else {
    if (hasOblit) {
      ItemNBTHelper.setBoolean(stack,"String_Node_Str",!ItemNBTHelper.getBoolean(stack,"String_Node_Str",false));
      if (player.worldObj.isRemote)       player.addChatMessage(new ChatComponentTranslation("String_Node_Str" + ItemNBTHelper.getBoolean(stack,"String_Node_Str",false) + "String_Node_Str"));
    }
  }
  return stack;
}

Fixed version (ground truth):
public static ItemStack changeMode(ItemStack stack,EntityPlayer player,boolean hasOblit,int maxSize){
  if (player.isSneaking()) {
    if (ItemNBTHelper.getShort(stack,"String_Node_Str",(short)0) < maxSize)     ItemNBTHelper.setShort(stack,"String_Node_Str",(short)(ItemNBTHelper.getShort(stack,"String_Node_Str",(short)0) + 1));
 else     ItemNBTHelper.setShort(stack,"String_Node_Str",(short)0);
    if (!player.worldObj.isRemote)     player.addChatMessage(new ChatComponentTranslation("String_Node_Str" + ItemNBTHelper.getShort(stack,"String_Node_Str",(short)0) + "String_Node_Str"));
  }
 else {
    updateGhostBlocks(player,player.worldObj);
    if (hasOblit) {
      ItemNBTHelper.setBoolean(stack,"String_Node_Str",!ItemNBTHelper.getBoolean(stack,"String_Node_Str",false));
      if (player.worldObj.isRemote)       player.addChatMessage(new ChatComponentTranslation("String_Node_Str" + ItemNBTHelper.getBoolean(stack,"String_Node_Str",false) + "String_Node_Str"));
    }
  }
  return stack;
}
Program: 117169
Project: 117169
Buggy source:
public static MovingObjectPosition raytraceFromEntity(World world,Entity player,boolean par3,double range){
  float f=1.0F;
  float f1=player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f;
  float f2=player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;
  double d0=player.prevPosX + (player.posX - player.prevPosX) * (double)f;
  double d1=player.prevPosY + (player.posY - player.prevPosY) * (double)f;
  if (!world.isRemote && player instanceof EntityPlayer)   d1+=1.62D;
  double d2=player.prevPosZ + (player.posZ - player.prevPosZ) * (double)f;
  Vec3 vec3=world.getWorldVec3Pool().getVecFromPool(d0,d1,d2);
  float f3=MathHelper.cos(-f2 * 0.017453292F - (float)Math.PI);
  float f4=MathHelper.sin(-f2 * 0.017453292F - (float)Math.PI);
  float f5=-MathHelper.cos(-f1 * 0.017453292F);
  float f6=MathHelper.sin(-f1 * 0.017453292F);
  float f7=f4 * f5;
  float f8=f3 * f5;
  double d3=range;
  if (player instanceof EntityPlayerMP) {
    d3=((EntityPlayerMP)player).theItemInWorldManager.getBlockReachDistance();
  }
  Vec3 vec31=vec3.addVector((double)f7 * d3,(double)f6 * d3,(double)f8 * d3);
  return world.func_147447_a(vec3,vec31,par3,!par3,par3);
}

Fixed version (ground truth):
public static MovingObjectPosition raytraceFromEntity(World world,Entity player,double range){
  float f=1.0F;
  float f1=player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f;
  float f2=player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;
  double d0=player.prevPosX + (player.posX - player.prevPosX) * (double)f;
  double d1=player.prevPosY + (player.posY - player.prevPosY) * (double)f;
  if (!world.isRemote && player instanceof EntityPlayer)   d1+=1.62D;
  double d2=player.prevPosZ + (player.posZ - player.prevPosZ) * (double)f;
  Vec3 vec3=world.getWorldVec3Pool().getVecFromPool(d0,d1,d2);
  float f3=MathHelper.cos(-f2 * 0.017453292F - (float)Math.PI);
  float f4=MathHelper.sin(-f2 * 0.017453292F - (float)Math.PI);
  float f5=-MathHelper.cos(-f1 * 0.017453292F);
  float f6=MathHelper.sin(-f1 * 0.017453292F);
  float f7=f4 * f5;
  float f8=f3 * f5;
  double d3=range;
  if (player instanceof EntityPlayerMP) {
    d3=((EntityPlayerMP)player).theItemInWorldManager.getBlockReachDistance();
  }
  Vec3 vec31=vec3.addVector((double)f7 * d3,(double)f6 * d3,(double)f8 * d3);
  return world.rayTraceBlocks(vec3,vec31);
}
Program: 117170
Project: 117170
Buggy source:
public static boolean disSquare(int x,int y,int z,final EntityPlayer player,final World world,final boolean silk,final int fortune,Material[] materialsListing,ItemStack stack){
  int size=stack.getItem().equals(ModItems.draconicAxe) ? 2 : ItemNBTHelper.getShort(stack,"String_Node_Str",(short)0);
  MovingObjectPosition mop=raytraceFromEntity(world,player,false,4.5D);
  if (mop == null) {
    return false;
  }
  int sizeX=size;
  int sizeY=size;
  int sizeZ=size;
  int yOff=(size * -1);
  Block targetBlock=world.getBlock(x,y,z);
  if (size > 0)   yOff++;
  if (size == 0)   return false;
  int side=(stack == null || stack.getItem() == null || stack.getItem().equals(ModItems.draconicAxe)) ? 6 : mop.sideHit;
switch (side) {
case 0:
case 1:
    sizeY=0;
  yOff=0;
break;
case 2:
case 3:
sizeZ=0;
break;
case 4:
case 5:
sizeX=0;
break;
}
for (int x1=x - sizeX; x1 <= x + sizeX; x1++) {
for (int y1=y - (sizeY + yOff); y1 <= y + (sizeY - yOff); y1++) {
for (int z1=z - sizeZ; z1 <= z + sizeZ; z1++) {
mineBlock(x1,y1,z1,player,world,silk,fortune,materialsListing,stack);
}
}
}
world.playSoundEffect(x + 0.5F,y + 0.5F,z + 0.5F,targetBlock.stepSound.getStepResourcePath(),(targetBlock.stepSound.getVolume() + 1.0F) / 2.0F,targetBlock.stepSound.getPitch() * 0.8F);
return true;
}

Fixed version (ground truth):
public static boolean disSquare(int x,int y,int z,final EntityPlayer player,final World world,final boolean silk,final int fortune,Material[] materialsListing,ItemStack stack){
  int size=stack.getItem().equals(ModItems.draconicAxe) ? 2 : ItemNBTHelper.getShort(stack,"String_Node_Str",(short)0);
  MovingObjectPosition mop=raytraceFromEntity(world,player,4.5D);
  if (mop == null) {
    if (player instanceof EntityPlayer)     updateGhostBlocks(player,world);
    return false;
  }
  int sizeX=size;
  int sizeY=size;
  int sizeZ=size;
  int yOff=(size * -1);
  Block targetBlock=world.getBlock(x,y,z);
  if (size > 0)   yOff++;
  if (size == 0)   return false;
  int side=(stack.getItem().equals(ModItems.draconicAxe)) ? 6 : mop.sideHit;
switch (side) {
case 0:
case 1:
    sizeY=0;
  yOff=0;
break;
case 2:
case 3:
sizeZ=0;
break;
case 4:
case 5:
sizeX=0;
break;
}
for (int x1=x - sizeX; x1 <= x + sizeX; x1++) {
for (int y1=y - (sizeY + yOff); y1 <= y + (sizeY - yOff); y1++) {
for (int z1=z - sizeZ; z1 <= z + sizeZ; z1++) {
mineBlock(x1,y1,z1,player,world,silk,fortune,materialsListing,stack);
player.worldObj.scheduleBlockUpdate(x1,y1,z1,Blocks.stone,100);
}
}
}
world.playSoundEffect(x + 0.5F,y + 0.5F,z + 0.5F,targetBlock.stepSound.getStepResourcePath(),(targetBlock.stepSound.getVolume() + 1.0F) / 2.0F,targetBlock.stepSound.getPitch() * 0.8F);
return true;
}
Program: 117171
Project: 117171
Buggy source:
@Override public boolean canConnectRedstone(IBlockAccess world,int x,int y,int z,int side){
  return true;
}

Fixed version (ground truth):
@Override public boolean canConnectRedstone(IBlockAccess world,int x,int y,int z,int side){
  if (side == 0 || side == 1)   return false;
 else   return true;
}
Program: 117172
Project: 117172
Buggy source:
@Override public int isProvidingStrongPower(IBlockAccess world,int x,int y,int z,int meta){
  TileEntity te=world.getTileEntity(x,y,z);
  TilePlayerDetectorAdvanced detector=(te != null && te instanceof TilePlayerDetectorAdvanced) ? (TilePlayerDetectorAdvanced)te : null;
  if (detector != null)   return detector.output ? 15 : 0;
 else   return 0;
}

Fixed version (ground truth):
@Override public int isProvidingStrongPower(IBlockAccess world,int x,int y,int z,int meta){
  TileEntity te=world.getTileEntity(x,y,z);
  TilePlayerDetectorAdvanced detector=(te != null && te instanceof TilePlayerDetectorAdvanced) ? (TilePlayerDetectorAdvanced)te : null;
  if (detector != null)   if (!detector.outputInverted)   return detector.output ? 15 : 0;
 else   return detector.output ? 0 : 15;
 else   return 0;
}
Program: 117173
Project: 117173
Buggy source:
@Override public boolean canConnectRedstone(IBlockAccess world,int x,int y,int z,int side){
  return true;
}

Fixed version (ground truth):
@Override public boolean canConnectRedstone(IBlockAccess world,int x,int y,int z,int side){
  if (side == 0 || side == 1)   return false;
 else   return true;
}
Program: 117174
Project: 117174
Buggy source:
public void updateBlocks(){
  worldObj.notifyBlocksOfNeighborChange(xCoord,yCoord,zCoord,blockType);
}

Fixed version (ground truth):
public void updateBlocks(){
  worldObj.notifyBlocksOfNeighborChange(xCoord,yCoord,zCoord,blockType);
  worldObj.notifyBlocksOfNeighborChange(xCoord - 1,yCoord,zCoord,worldObj.getBlock(xCoord,yCoord,zCoord));
  worldObj.notifyBlocksOfNeighborChange(xCoord + 1,yCoord,zCoord,worldObj.getBlock(xCoord,yCoord,zCoord));
  worldObj.notifyBlocksOfNeighborChange(xCoord,yCoord - 1,zCoord,worldObj.getBlock(xCoord,yCoord,zCoord));
  worldObj.notifyBlocksOfNeighborChange(xCoord,yCoord + 1,zCoord,worldObj.getBlock(xCoord,yCoord,zCoord));
  worldObj.notifyBlocksOfNeighborChange(xCoord,yCoord,zCoord - 1,worldObj.getBlock(xCoord,yCoord,zCoord));
  worldObj.notifyBlocksOfNeighborChange(xCoord,yCoord,zCoord + 1,worldObj.getBlock(xCoord,yCoord,zCoord));
}
Program: 117175
Project: 117175
Buggy source:
public void updateBlocks(){
  worldObj.notifyBlocksOfNeighborChange(xCoord,yCoord,zCoord,blockType);
}

Fixed version (ground truth):
public void updateBlocks(){
  worldObj.notifyBlocksOfNeighborChange(xCoord,yCoord,zCoord,blockType);
  worldObj.notifyBlocksOfNeighborChange(xCoord - 1,yCoord,zCoord,worldObj.getBlock(xCoord,yCoord,zCoord));
  worldObj.notifyBlocksOfNeighborChange(xCoord + 1,yCoord,zCoord,worldObj.getBlock(xCoord,yCoord,zCoord));
  worldObj.notifyBlocksOfNeighborChange(xCoord,yCoord - 1,zCoord,worldObj.getBlock(xCoord,yCoord,zCoord));
  worldObj.notifyBlocksOfNeighborChange(xCoord,yCoord + 1,zCoord,worldObj.getBlock(xCoord,yCoord,zCoord));
  worldObj.notifyBlocksOfNeighborChange(xCoord,yCoord,zCoord - 1,worldObj.getBlock(xCoord,yCoord,zCoord));
  worldObj.notifyBlocksOfNeighborChange(xCoord,yCoord,zCoord + 1,worldObj.getBlock(xCoord,yCoord,zCoord));
}
Program: 117181
Project: 117181
Buggy source:
protected static void findCuts(Table table,int[] v1,int v2){
  double bestEval=Double.POSITIVE_INFINITY;
  for (int i=0; i < table.resp.length - 1; i++) {
    double sum1=table.resp[i][v2][0];
    double sum2=table.resp[i][v2][2];
    double weight1=table.count[i][v2][0];
    double weight2=table.count[i][v2][2];
    double eval=-sum1 * sum1 / weight1 - sum2 * sum2 / weight2;
    if (eval < bestEval) {
      bestEval=eval;
      v1[0]=i;
    }
  }
  bestEval=Double.POSITIVE_INFINITY;
  for (int i=0; i < table.resp.length - 1; i++) {
    double sum1=table.resp[i][v2][1];
    double sum2=table.resp[i][v2][3];
    double weight1=table.count[i][v2][1];
    double weight2=table.count[i][v2][3];
    double eval=-sum1 * sum1 / weight1 - sum2 * sum2 / weight2;
    if (eval < bestEval) {
      bestEval=eval;
      v1[1]=i;
    }
  }
}

Fixed version (ground truth):
protected static void findCuts(Table table,int[] v1,int v2){
  double bestEval=Double.POSITIVE_INFINITY;
  for (int i=0; i < table.resp.length - 1; i++) {
    double sum1=table.resp[i][v2][0];
    double sum2=table.resp[i][v2][2];
    double weight1=table.count[i][v2][0];
    double weight2=table.count[i][v2][2];
    double eval1=OptimUtils.getGain(sum1,weight1);
    double eval2=OptimUtils.getGain(sum2,weight2);
    double eval=-(eval1 + eval2);
    if (eval < bestEval) {
      bestEval=eval;
      v1[0]=i;
    }
  }
  bestEval=Double.POSITIVE_INFINITY;
  for (int i=0; i < table.resp.length - 1; i++) {
    double sum1=table.resp[i][v2][1];
    double sum2=table.resp[i][v2][3];
    double weight1=table.count[i][v2][1];
    double weight2=table.count[i][v2][3];
    double eval1=OptimUtils.getGain(sum1,weight1);
    double eval2=OptimUtils.getGain(sum2,weight2);
    double eval=-(eval1 + eval2);
    if (eval < bestEval) {
      bestEval=eval;
      v1[1]=i;
    }
  }
}
Program: 117182
Project: 117182
Buggy source:
protected static void findCut(CHistogram cHist,IntDoublePair cut){
  cut.v2=Double.POSITIVE_INFINITY;
  for (int i=0; i < cHist.size() - 1; i++) {
    double sum1=cHist.sum[i];
    double sum2=cHist.sum[cHist.size() - 1] - sum1;
    double weight1=cHist.count[i];
    double weight2=cHist.count[cHist.size() - 1] - weight1;
    double eval=-sum1 * sum1 * weight1 - sum2 * sum2 * weight2;
    if (eval < cut.v2) {
      cut.v2=eval;
      cut.v1=i;
    }
  }
}

Fixed version (ground truth):
protected static void findCut(CHistogram cHist,IntDoublePair cut){
  cut.v2=Double.POSITIVE_INFINITY;
  for (int i=0; i < cHist.size() - 1; i++) {
    double sum1=cHist.sum[i];
    double sum2=cHist.sum[cHist.size() - 1] - sum1;
    double weight1=cHist.count[i];
    double weight2=cHist.count[cHist.size() - 1] - weight1;
    double eval1=OptimUtils.getGain(sum1,weight1);
    double eval2=OptimUtils.getGain(sum2,weight2);
    double eval=-(eval1 + eval2);
    if (eval < cut.v2) {
      cut.v2=eval;
      cut.v1=i;
    }
  }
}
Program: 117183
Project: 117183
Buggy source:
/** 
 * Returns the pseudo residual.
 * @param pred the prediction.
 * @param cls the class label.
 * @return the pseudo residual.
 */
public static double getPseudoResidual(double pred,double cls){
  if (cls == 1) {
    return 1 / (1 + Math.exp(pred));
  }
 else {
    return -1 / (1 + Math.exp(-pred));
  }
}

Fixed version (ground truth):
/** 
 * Returns the pseudo residual.
 * @param pred the prediction.
 * @param cls the class label.
 * @return the pseudo residual.
 */
public static double getPseudoResidual(double pred,double cls){
  return cls - getProbability(pred);
}
Program: 117184
Project: 117184
Buggy source:
@Test public void testGetPseudoResidual(){
  Assert.assertEquals(0.5,OptimUtils.getPseudoResidual(0,1),MathUtils.EPSILON);
  Assert.assertEquals(-0.5,OptimUtils.getPseudoResidual(0,-1),MathUtils.EPSILON);
}

Fixed version (ground truth):
@Test public void testGetPseudoResidual(){
  Assert.assertEquals(0.5,OptimUtils.getPseudoResidual(0,1),MathUtils.EPSILON);
  Assert.assertEquals(-0.5,OptimUtils.getPseudoResidual(0,0),MathUtils.EPSILON);
}
Program: 117188
Project: 117188
Buggy source:
/** 
 * Randomly permutes this permutation.
 * @return this permutation.
 */
public Permutation permute(){
  for (int i=0; i < a.length; i++) {
    int idx=Random.getInstance().nextInt(i + 1);
    int t=a[idx];
    a[idx]=a[i];
    a[i]=t;
  }
  return this;
}

Fixed version (ground truth):
/** 
 * Randomly permutes this permutation.
 * @return this permutation.
 */
public Permutation permute(){
  for (int i=a.length - 1; i > 0; i++) {
    int idx=Random.getInstance().nextInt(i + 1);
    int t=a[idx];
    a[idx]=a[i];
    a[i]=t;
  }
  return this;
}
Program: 117189
Project: 117189
Buggy source:
@Override public int compare(DoublePair o1,DoublePair o2){
  int cmp=Double.compare(o1.v1,o2.v1);
  if (cmp == 0) {
    cmp=Double.compare(o2.v2,o2.v2);
  }
  return cmp;
}

Fixed version (ground truth):
@Override public int compare(DoublePair o1,DoublePair o2){
  int cmp=Double.compare(o1.v1,o2.v1);
  if (cmp == 0) {
    cmp=Double.compare(o1.v2,o2.v2);
  }
  return cmp;
}
Program: 117190
Project: 117190
Buggy source:
protected void doOnePassBinomial(int[][] indices,double[][] values,double[] theta,double[] y,final double tl1,final double tl2,double[] w,double[] pTrain,double[] rTrain){
  for (int j=0; j < indices.length; j++) {
    if (Math.abs(theta[j]) <= MathUtils.EPSILON) {
      continue;
    }
    double eta=0;
    int[] index=indices[j];
    double[] value=values[j];
    for (int i=0; i < index.length; i++) {
      int idx=index[i];
      eta+=rTrain[idx] * value[i];
    }
    double newW=w[j] * theta[j] + eta;
    double t=tl1;
    if (newW > t) {
      newW-=t;
    }
 else     if (newW < -t) {
      newW+=t;
    }
 else {
      newW=0;
    }
    newW/=(theta[j] + tl2);
    double delta=newW - w[j];
    w[j]=newW;
    for (int i=0; i < index.length; i++) {
      int idx=index[i];
      pTrain[idx]+=delta * value[i];
      rTrain[idx]=OptimUtils.getPseudoResidual(pTrain[idx],y[idx]);
    }
  }
}

Fixed version (ground truth):
protected void doOnePassBinomial(int[][] indices,double[][] values,double[] theta,double[] y,final double tl1,final double tl2,double[] w,double[] pTrain,double[] rTrain){
  for (int j=0; j < indices.length; j++) {
    if (Math.abs(theta[j]) <= MathUtils.EPSILON) {
      continue;
    }
    double eta=0;
    int[] index=indices[j];
    double[] value=values[j];
    for (int i=0; i < index.length; i++) {
      int idx=index[i];
      eta+=rTrain[idx] * value[i];
    }
    double newW=w[j] * theta[j] + eta;
    if (newW > tl1) {
      newW-=tl1;
    }
 else     if (newW < -tl1) {
      newW+=tl1;
    }
 else {
      newW=0;
    }
    newW/=(theta[j] + tl2);
    double delta=newW - w[j];
    w[j]=newW;
    for (int i=0; i < index.length; i++) {
      int idx=index[i];
      pTrain[idx]+=delta * value[i];
      rTrain[idx]=OptimUtils.getPseudoResidual(pTrain[idx],y[idx]);
    }
  }
}
Program: 117191
Project: 117191
Buggy source:
/** 
 * Constructor.
 * @param obj the object.
 */
public CmdLineParser(Class<?> clazz,Object obj){
  this.name=clazz.getCanonicalName();
  this.obj=obj;
  argList=new ArrayList<>();
  fieldList=new ArrayList<>();
  processFields(obj.getClass().getFields());
  processFields(obj.getClass().getDeclaredFields());
}

Fixed version (ground truth):
/** 
 * Constructor.
 * @param clazz the class object.
 * @param obj the object.
 */
public CmdLineParser(Class<?> clazz,Object obj){
  this.name=clazz.getCanonicalName();
  this.obj=obj;
  argList=new ArrayList<>();
  fieldList=new ArrayList<>();
  processFields(obj.getClass().getFields());
  processFields(obj.getClass().getDeclaredFields());
}
Program: 117192
Project: 117192
Buggy source:
/** 
 * Returns a bootstrap sample with out-of-bag samples.
 * @param instances the data set.
 * @param bagIndices
 * @param oobIndices
 */
public static void createBootstrapSample(Instances instances,Map<Integer,Integer> bagIndices,List<Integer> oobIndices){
  Random rand=Random.getInstance();
  for (; ; ) {
    bagIndices.clear();
    oobIndices.clear();
    for (int i=0; i < instances.size(); i++) {
      int idx=rand.nextInt(instances.size());
      if (!bagIndices.containsKey(idx)) {
        bagIndices.put(idx,0);
      }
      bagIndices.put(idx,bagIndices.get(idx) + 1);
    }
    for (int i=0; i < instances.size(); i++) {
      if (!bagIndices.containsKey(i)) {
        oobIndices.add(i);
      }
    }
    if (oobIndices.size() > 0) {
      break;
    }
  }
}

Fixed version (ground truth):
/** 
 * Returns a bootstrap sample with out-of-bag samples.
 * @param instances the data set.
 * @param bagIndices the index of sampled instances with weights.
 * @param oobIndices the out-of-bag indexes.
 */
public static void createBootstrapSample(Instances instances,Map<Integer,Integer> bagIndices,List<Integer> oobIndices){
  Random rand=Random.getInstance();
  for (; ; ) {
    bagIndices.clear();
    oobIndices.clear();
    for (int i=0; i < instances.size(); i++) {
      int idx=rand.nextInt(instances.size());
      if (!bagIndices.containsKey(idx)) {
        bagIndices.put(idx,0);
      }
      bagIndices.put(idx,bagIndices.get(idx) + 1);
    }
    for (int i=0; i < instances.size(); i++) {
      if (!bagIndices.containsKey(i)) {
        oobIndices.add(i);
      }
    }
    if (oobIndices.size() > 0) {
      break;
    }
  }
}
Program: 117196
Project: 117196
Buggy source:
/** 
 * <p> <pre> Usage: Evaluator -d	data set path -m	model path [-r]	attribute file path [-e]	AUC (a), Error (c), RMSE (r) (default: r) </pre> </p>
 * @param args the command line arguments.
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
  Options opts=new Options();
  CmdLineParser parser=new CmdLineParser(Evaluator.class,opts);
  try {
    parser.parse(args);
  }
 catch (  IllegalArgumentException e) {
    parser.printUsage();
    System.exit(1);
  }
  Instances instances=InstancesReader.read(opts.attPath,opts.dataPath);
  mltk.predictor.Predictor predictor=PredictorReader.read(opts.modelPath);
switch (opts.task) {
case "String_Node_Str":
    ProbabilisticClassifier probClassifier=(ProbabilisticClassifier)predictor;
  double auc=Evaluator.evalAreaUnderROC(probClassifier,instances);
System.out.println("String_Node_Str" + auc);
break;
case "String_Node_Str":
Classifier classifier=(Classifier)predictor;
double error=Evaluator.evalError(classifier,instances);
System.out.println("String_Node_Str" + error);
break;
case "String_Node_Str":
Regressor regressor=(Regressor)predictor;
double rmse=Evaluator.evalRMSE(regressor,instances);
System.out.println("String_Node_Str" + rmse);
break;
default :
break;
}
}

Fixed version (ground truth):
/** 
 * Evaluates a predictor. <pre> Usage: Evaluator -d	data set path -m	model path [-r]	attribute file path [-e]	AUC (a), Error (c), RMSE (r) (default: r) </pre>
 * @param args the command line arguments.
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
  Options opts=new Options();
  CmdLineParser parser=new CmdLineParser(Evaluator.class,opts);
  try {
    parser.parse(args);
  }
 catch (  IllegalArgumentException e) {
    parser.printUsage();
    System.exit(1);
  }
  Instances instances=InstancesReader.read(opts.attPath,opts.dataPath);
  mltk.predictor.Predictor predictor=PredictorReader.read(opts.modelPath);
switch (opts.task) {
case "String_Node_Str":
    ProbabilisticClassifier probClassifier=(ProbabilisticClassifier)predictor;
  double auc=Evaluator.evalAreaUnderROC(probClassifier,instances);
System.out.println("String_Node_Str" + auc);
break;
case "String_Node_Str":
Classifier classifier=(Classifier)predictor;
double error=Evaluator.evalError(classifier,instances);
System.out.println("String_Node_Str" + error);
break;
case "String_Node_Str":
Regressor regressor=(Regressor)predictor;
double rmse=Evaluator.evalRMSE(regressor,instances);
System.out.println("String_Node_Str" + rmse);
break;
default :
break;
}
}
Program: 117200
Project: 117200
Buggy source:
/** 
 * Builds a classifier.
 * @param trainSet the training set.
 * @param maxNumIters the maximum number of iterations.
 * @param numKnots the number of knots.
 * @param lambda the lambda.
 * @param alpha the alpha.
 * @param fitIntercept whether the intercept is included.
 * @return a classifier.
 */
public GAM buildClassifier(Instances trainSet,int maxNumIters,int numKnots,double lambda,double alpha){
  return buildClassifier(trainSet,isSparse(trainSet),maxNumIters,numKnots,lambda,alpha);
}

Fixed version (ground truth):
/** 
 * Builds a classifier.
 * @param trainSet the training set.
 * @param maxNumIters the maximum number of iterations.
 * @param numKnots the number of knots.
 * @param lambda the lambda.
 * @param alpha the alpha.
 * @return a classifier.
 */
public GAM buildClassifier(Instances trainSet,int maxNumIters,int numKnots,double lambda,double alpha){
  return buildClassifier(trainSet,isSparse(trainSet),maxNumIters,numKnots,lambda,alpha);
}
Program: 117201
Project: 117201
Buggy source:
/** 
 * <p> <pre> Usage: mltk.predictor.gam.SPLAMLearner -t	train set path [-g]	task between classification (c) and regression (r) (default: r) [-r]	attribute file path [-o]	output model path [-V]	verbose (default: true) [-d]	number of knots (default: 10) [-m]	maximum number of iterations (default: 0) [-l]	lambda (default: 0) [-a]	alpha (default: 1, i.e., SPAM model) </pre> </p>
 * @param args the command line arguments.
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
  Options opts=new Options();
  CmdLineParser parser=new CmdLineParser(SPLAMLearner.class,opts);
  Task task=null;
  try {
    parser.parse(args);
    task=Task.get(opts.task);
    if (opts.numKnots < 0) {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
 catch (  IllegalArgumentException e) {
    parser.printUsage();
    System.exit(1);
  }
  Instances trainSet=InstancesReader.read(opts.attPath,opts.trainPath);
  SPLAMLearner learner=new SPLAMLearner();
  learner.setNumKnots(opts.numKnots);
  learner.setMaxNumIters(opts.maxNumIters);
  learner.setLambda(opts.lambda);
  learner.setAlpha(opts.alpha);
  learner.setTask(task);
  learner.setVerbose(opts.verbose);
  long start=System.currentTimeMillis();
  GAM gam=learner.build(trainSet);
  long end=System.currentTimeMillis();
  System.out.println("String_Node_Str" + (end - start) / 1000.0);
  if (opts.outputModelPath != null) {
    PredictorWriter.write(gam,opts.outputModelPath);
  }
}

Fixed version (ground truth):
/** 
 * Trains a SPLAM. <pre> Usage: mltk.predictor.gam.SPLAMLearner -t	train set path [-g]	task between classification (c) and regression (r) (default: r) [-r]	attribute file path [-o]	output model path [-V]	verbose (default: true) [-d]	number of knots (default: 10) [-m]	maximum number of iterations (default: 0) [-l]	lambda (default: 0) [-a]	alpha (default: 1, i.e., SPAM model) </pre>
 * @param args the command line arguments.
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
  Options opts=new Options();
  CmdLineParser parser=new CmdLineParser(SPLAMLearner.class,opts);
  Task task=null;
  try {
    parser.parse(args);
    task=Task.get(opts.task);
    if (opts.numKnots < 0) {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
 catch (  IllegalArgumentException e) {
    parser.printUsage();
    System.exit(1);
  }
  Instances trainSet=InstancesReader.read(opts.attPath,opts.trainPath);
  SPLAMLearner learner=new SPLAMLearner();
  learner.setNumKnots(opts.numKnots);
  learner.setMaxNumIters(opts.maxNumIters);
  learner.setLambda(opts.lambda);
  learner.setAlpha(opts.alpha);
  learner.setTask(task);
  learner.setVerbose(opts.verbose);
  long start=System.currentTimeMillis();
  GAM gam=learner.build(trainSet);
  long end=System.currentTimeMillis();
  System.out.println("String_Node_Str" + (end - start) / 1000.0);
  if (opts.outputModelPath != null) {
    PredictorWriter.write(gam,opts.outputModelPath);
  }
}
Program: 117202
Project: 117202
Buggy source:
/** 
 * <p> <pre> Usage: mltk.predictor.gam.ScorecardModelLearner -t	train set path -m	maximum number of iterations [-g]	task between classification (c) and regression (r) (default: r) [-r]	attribute file path [-o]	output model path [-V]	verbose (default: true) [-l]	lambda (default: 0) </pre> </p>
 * @param args the command line arguments.
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
  Options opts=new Options();
  CmdLineParser parser=new CmdLineParser(ScorecardModelLearner.class,opts);
  Task task=null;
  try {
    parser.parse(args);
    task=Task.get(opts.task);
  }
 catch (  IllegalArgumentException e) {
    parser.printUsage();
    System.exit(1);
  }
  Instances trainSet=InstancesReader.read(opts.attPath,opts.trainPath);
  ScorecardModelLearner learner=new ScorecardModelLearner();
  learner.setMaxNumIters(opts.maxNumIters);
  learner.setLambda(opts.lambda);
  learner.setTask(task);
  learner.setVerbose(opts.verbose);
  long start=System.currentTimeMillis();
  GAM gam=learner.build(trainSet);
  long end=System.currentTimeMillis();
  System.out.println("String_Node_Str" + (end - start) / 1000.0);
  if (opts.outputModelPath != null) {
    PredictorWriter.write(gam,opts.outputModelPath);
  }
}

Fixed version (ground truth):
/** 
 * Trains a scorecard model. <pre> Usage: mltk.predictor.gam.ScorecardModelLearner -t	train set path -m	maximum number of iterations [-g]	task between classification (c) and regression (r) (default: r) [-r]	attribute file path [-o]	output model path [-V]	verbose (default: true) [-l]	lambda (default: 0) </pre>
 * @param args the command line arguments.
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
  Options opts=new Options();
  CmdLineParser parser=new CmdLineParser(ScorecardModelLearner.class,opts);
  Task task=null;
  try {
    parser.parse(args);
    task=Task.get(opts.task);
  }
 catch (  IllegalArgumentException e) {
    parser.printUsage();
    System.exit(1);
  }
  Instances trainSet=InstancesReader.read(opts.attPath,opts.trainPath);
  ScorecardModelLearner learner=new ScorecardModelLearner();
  learner.setMaxNumIters(opts.maxNumIters);
  learner.setLambda(opts.lambda);
  learner.setTask(task);
  learner.setVerbose(opts.verbose);
  long start=System.currentTimeMillis();
  GAM gam=learner.build(trainSet);
  long end=System.currentTimeMillis();
  System.out.println("String_Node_Str" + (end - start) / 1000.0);
  if (opts.outputModelPath != null) {
    PredictorWriter.write(gam,opts.outputModelPath);
  }
}
Program: 117204
Project: 117204
Buggy source:
/** 
 * <p> <pre> Usage: mltk.predictor.gam.tool.Diagnostics -d	dataset path -i	input model path -o	output path [-r]	attribute file path </pre> </p>
 * @param args the command line arguments.
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
  Options opts=new Options();
  CmdLineParser parser=new CmdLineParser(Diagnostics.class,opts);
  try {
    parser.parse(args);
  }
 catch (  IllegalArgumentException e) {
    parser.printUsage();
    System.exit(1);
  }
  Instances dataset=InstancesReader.read(opts.attPath,opts.datasetPath);
  GAM gam=PredictorReader.read(opts.inputModelPath,GAM.class);
  List<Element<int[]>> list=Diagnostics.diagnose(gam,dataset);
  Collections.sort(list);
  Collections.reverse(list);
  PrintWriter out=new PrintWriter(opts.outputPath);
  for (  Element<int[]> element : list) {
    int[] term=element.element;
    double weight=element.weight;
    out.println(Arrays.toString(term) + "String_Node_Str" + weight);
  }
  out.flush();
  out.close();
}

Fixed version (ground truth):
/** 
 * Generates term importance for GAMs. <pre> Usage: mltk.predictor.gam.tool.Diagnostics -d	dataset path -i	input model path -o	output path [-r]	attribute file path </pre>
 * @param args the command line arguments.
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
  Options opts=new Options();
  CmdLineParser parser=new CmdLineParser(Diagnostics.class,opts);
  try {
    parser.parse(args);
  }
 catch (  IllegalArgumentException e) {
    parser.printUsage();
    System.exit(1);
  }
  Instances dataset=InstancesReader.read(opts.attPath,opts.datasetPath);
  GAM gam=PredictorReader.read(opts.inputModelPath,GAM.class);
  List<Element<int[]>> list=Diagnostics.diagnose(gam,dataset);
  Collections.sort(list);
  Collections.reverse(list);
  PrintWriter out=new PrintWriter(opts.outputPath);
  for (  Element<int[]> element : list) {
    int[] term=element.element;
    double weight=element.weight;
    out.println(Arrays.toString(term) + "String_Node_Str" + weight);
  }
  out.flush();
  out.close();
}
Program: 117205
Project: 117205
Buggy source:
/** 
 * <p> <pre> Usage: mltk.predictor.gam.tool.Visualizer -r	attribute file path -d	dataset path -i	input model path -o	output directory path [-t]	output terminal (default: png) </pre> </p>
 * @param args the command line arguments.
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
  Options opts=new Options();
  CmdLineParser parser=new CmdLineParser(Visualizer.class,opts);
  try {
    parser.parse(args);
  }
 catch (  IllegalArgumentException e) {
    parser.printUsage();
    System.exit(1);
  }
  Instances dataset=InstancesReader.read(opts.attPath,opts.datasetPath);
  GAM gam=PredictorReader.read(opts.inputModelPath,GAM.class);
  Visualizer.generateGnuplotScripts(gam,dataset,opts.dirPath,Terminal.getEnum(opts.terminal));
}

Fixed version (ground truth):
/** 
 * Generates scripts for visualizing GAMs. <pre> Usage: mltk.predictor.gam.tool.Visualizer -r	attribute file path -d	dataset path -i	input model path -o	output directory path [-t]	output terminal (default: png) </pre>
 * @param args the command line arguments.
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
  Options opts=new Options();
  CmdLineParser parser=new CmdLineParser(Visualizer.class,opts);
  try {
    parser.parse(args);
  }
 catch (  IllegalArgumentException e) {
    parser.printUsage();
    System.exit(1);
  }
  Instances dataset=InstancesReader.read(opts.attPath,opts.datasetPath);
  GAM gam=PredictorReader.read(opts.inputModelPath,GAM.class);
  Visualizer.generateGnuplotScripts(gam,dataset,opts.dirPath,Terminal.getEnum(opts.terminal));
}
Program: 117206
Project: 117206
Buggy source:
@Override public void read(BufferedReader in) throws Exception {
  in.readLine();
  link=LinkFunction.get(in.readLine().split("String_Node_Str")[1]);
  intercept=ArrayUtils.parseDoubleArray(in.readLine());
  int p=Integer.parseInt(in.readLine().split("String_Node_Str")[1]);
  w=new double[intercept.length][p];
  for (int j=0; j < p; j++) {
    String[] data=in.readLine().split("String_Node_Str");
    for (int i=0; i < w.length; i++) {
      w[i][j]=Double.parseDouble(data[i]);
    }
  }
}

Fixed version (ground truth):
@Override public void read(BufferedReader in) throws Exception {
  link=LinkFunction.get(in.readLine().split("String_Node_Str")[1]);
  in.readLine();
  intercept=ArrayUtils.parseDoubleArray(in.readLine());
  int p=Integer.parseInt(in.readLine().split("String_Node_Str")[1]);
  w=new double[intercept.length][p];
  for (int j=0; j < p; j++) {
    String[] data=in.readLine().split("String_Node_Str");
    for (int i=0; i < w.length; i++) {
      w[i][j]=Double.parseDouble(data[i]);
    }
  }
}
Program: 117207
Project: 117207
Buggy source:
@Override public double[] predictProbabilities(Instance instance){
  if (w.length == 1) {
    double[] prob=new double[2];
    double pred=regress(intercept[0],w[0],instance);
    prob[0]=1 / (1 + Math.exp(-pred));
    prob[1]=1 - prob[0];
    return prob;
  }
 else {
    double[] prob=new double[w.length];
    double[] pred=new double[w.length];
    double sum=0;
    for (int i=0; i < w.length; i++) {
      pred[i]=regress(intercept[i],w[i],instance);
      prob[i]=1 / (1 + Math.exp(-pred[i]));
      sum+=prob[i];
    }
    for (int i=0; i < prob.length; i++) {
      prob[i]/=sum;
    }
    return prob;
  }
}

Fixed version (ground truth):
@Override public double[] predictProbabilities(Instance instance){
  if (w.length == 1) {
    double[] prob=new double[2];
    double pred=regress(intercept[0],w[0],instance);
    prob[0]=MathUtils.sigmoid(pred);
    prob[1]=1 - prob[0];
    return prob;
  }
 else {
    double[] prob=new double[w.length];
    double[] pred=new double[w.length];
    double sum=0;
    for (int i=0; i < w.length; i++) {
      pred[i]=regress(intercept[i],w[i],instance);
      prob[i]=MathUtils.sigmoid(pred[i]);
      sum+=prob[i];
    }
    for (int i=0; i < prob.length; i++) {
      prob[i]/=sum;
    }
    return prob;
  }
}
Program: 117208
Project: 117208
Buggy source:
@Override public void write(PrintWriter out) throws Exception {
  out.printf("String_Node_Str",this.getClass().getCanonicalName());
  out.printf("String_Node_Str" + link);
  out.println("String_Node_Str" + intercept.length);
  out.println(Arrays.toString(intercept));
  final int p=w[0].length;
  out.println("String_Node_Str" + p);
  for (int j=0; j < p; j++) {
    out.print(w[0][j]);
    for (int i=1; i < w.length; i++) {
      out.print("String_Node_Str" + w[i][j]);
    }
    out.println();
  }
}

Fixed version (ground truth):
@Override public void write(PrintWriter out) throws Exception {
  out.printf("String_Node_Str",this.getClass().getCanonicalName());
  out.println("String_Node_Str" + link);
  out.println("String_Node_Str" + intercept.length);
  out.println(Arrays.toString(intercept));
  final int p=w[0].length;
  out.println("String_Node_Str" + p);
  for (int j=0; j < p; j++) {
    out.print(w[0][j]);
    for (int i=1; i < w.length; i++) {
      out.print("String_Node_Str" + w[i][j]);
    }
    out.println();
  }
}
Program: 117209
Project: 117209
Buggy source:
/** 
 * Returns the response distribution family.
 */
public Family getFamily(){
  return family;
}

Fixed version (ground truth):
/** 
 * Returns the response distribution family.
 * @return the response distribution family.
 */
public Family getFamily(){
  return family;
}
Program: 117210
Project: 117210
Buggy source:
/** 
 * <p> <pre> Usage: mltk.predictor.glm.LassoLearner -t	train set path [-g]	task between classification (c) and regression (r) (default: r) [-r]	attribute file path [-o]	output model path [-V]	verbose (default: true) [-m]	maximum num of iterations (default: 0) [-l]	lambda (default: 0) </pre> </p>
 * @param args
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
  Options opts=new Options();
  CmdLineParser parser=new CmdLineParser(LassoLearner.class,opts);
  Task task=null;
  try {
    parser.parse(args);
    task=Task.get(opts.task);
  }
 catch (  IllegalArgumentException e) {
    parser.printUsage();
    System.exit(1);
  }
  Instances trainSet=InstancesReader.read(opts.attPath,opts.trainPath);
  LassoLearner learner=new LassoLearner();
  learner.setVerbose(opts.verbose);
  learner.setTask(task);
  learner.setLambda(opts.lambda);
  learner.setMaxNumIters(opts.maxIter);
  long start=System.currentTimeMillis();
  GLM glm=learner.build(trainSet);
  long end=System.currentTimeMillis();
  System.out.println("String_Node_Str" + (end - start) / 1000.0);
  if (opts.outputModelPath != null) {
    PredictorWriter.write(glm,opts.outputModelPath);
  }
}

Fixed version (ground truth):
/** 
 * Trains L1-regularized GLMs. <pre> Usage: mltk.predictor.glm.LassoLearner -t	train set path [-g]	task between classification (c) and regression (r) (default: r) [-r]	attribute file path [-o]	output model path [-V]	verbose (default: true) [-m]	maximum num of iterations (default: 0) [-l]	lambda (default: 0) </pre>
 * @param args the command line arguments.
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
  Options opts=new Options();
  CmdLineParser parser=new CmdLineParser(LassoLearner.class,opts);
  Task task=null;
  try {
    parser.parse(args);
    task=Task.get(opts.task);
  }
 catch (  IllegalArgumentException e) {
    parser.printUsage();
    System.exit(1);
  }
  Instances trainSet=InstancesReader.read(opts.attPath,opts.trainPath);
  LassoLearner learner=new LassoLearner();
  learner.setVerbose(opts.verbose);
  learner.setTask(task);
  learner.setLambda(opts.lambda);
  learner.setMaxNumIters(opts.maxIter);
  long start=System.currentTimeMillis();
  GLM glm=learner.build(trainSet);
  long end=System.currentTimeMillis();
  System.out.println("String_Node_Str" + (end - start) / 1000.0);
  if (opts.outputModelPath != null) {
    PredictorWriter.write(glm,opts.outputModelPath);
  }
}
Program: 117212
Project: 117212
Buggy source:
/** 
 * <p> <pre> Usage: mltk.predictor.glm.RidgeLearner -t	train set path [-g]	task between classification (c) and regression (r) (default: r) [-r]	attribute file path [-o]	output model path [-V]	verbose (default: true) [-m]	maximum num of iterations (default: 0) [-l]	lambda (default: 0) </pre> </p>
 * @param args
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
  Options opts=new Options();
  CmdLineParser parser=new CmdLineParser(RidgeLearner.class,opts);
  Task task=null;
  try {
    parser.parse(args);
    task=Task.get(opts.task);
  }
 catch (  IllegalArgumentException e) {
    parser.printUsage();
    System.exit(1);
  }
  Instances trainSet=InstancesReader.read(opts.attPath,opts.trainPath);
  RidgeLearner learner=new RidgeLearner();
  learner.setVerbose(opts.verbose);
  learner.setTask(task);
  learner.setLambda(opts.lambda);
  learner.setMaxNumIters(opts.maxIter);
  long start=System.currentTimeMillis();
  GLM glm=learner.build(trainSet);
  long end=System.currentTimeMillis();
  System.out.println("String_Node_Str" + (end - start) / 1000.0);
  if (opts.outputModelPath != null) {
    PredictorWriter.write(glm,opts.outputModelPath);
  }
}

Fixed version (ground truth):
/** 
 * Trains L2-regularized GLMs. <pre> Usage: mltk.predictor.glm.RidgeLearner -t	train set path [-g]	task between classification (c) and regression (r) (default: r) [-r]	attribute file path [-o]	output model path [-V]	verbose (default: true) [-m]	maximum num of iterations (default: 0) [-l]	lambda (default: 0) </pre>
 * @param args the command line arguments.
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
  Options opts=new Options();
  CmdLineParser parser=new CmdLineParser(RidgeLearner.class,opts);
  Task task=null;
  try {
    parser.parse(args);
    task=Task.get(opts.task);
  }
 catch (  IllegalArgumentException e) {
    parser.printUsage();
    System.exit(1);
  }
  Instances trainSet=InstancesReader.read(opts.attPath,opts.trainPath);
  RidgeLearner learner=new RidgeLearner();
  learner.setVerbose(opts.verbose);
  learner.setTask(task);
  learner.setLambda(opts.lambda);
  learner.setMaxNumIters(opts.maxIter);
  long start=System.currentTimeMillis();
  GLM glm=learner.build(trainSet);
  long end=System.currentTimeMillis();
  System.out.println("String_Node_Str" + (end - start) / 1000.0);
  if (opts.outputModelPath != null) {
    PredictorWriter.write(glm,opts.outputModelPath);
  }
}
Program: 117213
Project: 117213
Buggy source:
@Override public int compare(DoublePair o1,DoublePair o2){
  if (o1.v1 < o2.v1) {
    return -1;
  }
 else   if (o1.v1 > o2.v1) {
    return 1;
  }
 else {
    if (o1.v2 < o2.v2) {
      return -1;
    }
 else     if (o1.v2 > o2.v2) {
      return 1;
    }
 else {
      return 0;
    }
  }
}

Fixed version (ground truth):
@Override public int compare(DoublePair o1,DoublePair o2){
  int cmp=Double.compare(o1.v1,o2.v1);
  if (cmp == 0) {
    cmp=Double.compare(o2.v2,o2.v2);
  }
  return cmp;
}
Program: 117214
Project: 117214
Buggy source:
@Override public int compare(IntDoublePair o1,IntDoublePair o2){
  int cmp=0;
  if (firstIsKey) {
    if (o1.v1 < o2.v1) {
      cmp=-1;
    }
 else     if (o1.v1 > o2.v1) {
      cmp=1;
    }
  }
 else {
    if (o1.v2 < o2.v2) {
      cmp=-1;
    }
 else     if (o1.v2 > o2.v2) {
      cmp=1;
    }
  }
  if (!ascending) {
    cmp=-cmp;
  }
  return cmp;
}

Fixed version (ground truth):
@Override public int compare(IntDoublePair o1,IntDoublePair o2){
  int cmp=0;
  if (firstIsKey) {
    cmp=Integer.compare(o1.v1,o2.v1);
  }
 else {
    cmp=Double.compare(o1.v2,o2.v2);
  }
  if (!ascending) {
    cmp=-cmp;
  }
  return cmp;
}
Program: 117215
Project: 117215
Buggy source:
/** 
 * Returns the dot product of two vectors.
 * @param a the 1st vector.
 * @param b the 2nd vector.
 * @return the dot product of two vectors.
 */
public static double dotProduct(SparseVector a,SparseVector b){
  int[] indices1=a.getIndices();
  double[] values1=a.getValues();
  int[] indices2=b.getIndices();
  double[] values2=b.getValues();
  double s=0;
  int i=0;
  int j=0;
  while (i < indices1.length && j < indices2.length) {
    if (indices1[i] < indices2[j]) {
      i++;
    }
 else     if (indices1[i] > indices2[j]) {
      j++;
    }
 else {
      s+=values1[i] * values2[j];
    }
  }
  return s;
}

Fixed version (ground truth):
/** 
 * Returns the dot product of two vectors.
 * @param a the 1st vector.
 * @param b the 2nd vector.
 * @return the dot product of two vectors.
 */
public static double dotProduct(SparseVector a,SparseVector b){
  int[] indices1=a.getIndices();
  double[] values1=a.getValues();
  int[] indices2=b.getIndices();
  double[] values2=b.getValues();
  double s=0;
  int i=0;
  int j=0;
  while (i < indices1.length && j < indices2.length) {
    if (indices1[i] < indices2[j]) {
      i++;
    }
 else     if (indices1[i] > indices2[j]) {
      j++;
    }
 else {
      s+=values1[i] * values2[j];
      i++;
      j++;
    }
  }
  return s;
}
Program: 117216
Project: 117216
Buggy source:
/** 
 * <p> <pre> Usage: LassoLearner -t	train set path [-r]	attribute file path [-o]	output model path [-g]	task between classification (c) and regression (r) (default: r) [-m]	maximum num of iterations (default: 0) [-l]	lambda (default: 0)
 * @param args
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
  Options opts=new Options();
  CmdLineParser parser=new CmdLineParser(LassoLearner.class,opts);
  Task task=null;
  try {
    parser.parse(args);
    task=Task.getEnum(opts.task);
  }
 catch (  IllegalArgumentException e) {
    parser.printUsage();
    System.exit(1);
  }
  Instances trainSet=InstancesReader.read(opts.attPath,opts.trainPath);
  LassoLearner learner=new LassoLearner();
  learner.setVerbose(true);
  learner.setTask(task);
  learner.setLambda(opts.lambda);
  learner.setMaxNumIters(opts.maxIter);
  long start=System.currentTimeMillis();
  GLM glm=learner.build(trainSet);
  long end=System.currentTimeMillis();
  System.out.println("String_Node_Str" + (end - start) / 1000.0);
  if (opts.outputModelPath != null) {
    PredictorWriter.write(glm,opts.outputModelPath);
  }
}

Fixed version (ground truth):
/** 
 * <p> <pre> Usage: LassoLearner -t	train set path [-r]	attribute file path [-o]	output model path [-g]	task between classification (c) and regression (r) (default: r) [-m]	maximum num of iterations (default: 0) [-l]	lambda (default: 0) </pre> </p>
 * @param args
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
  Options opts=new Options();
  CmdLineParser parser=new CmdLineParser(LassoLearner.class,opts);
  Task task=null;
  try {
    parser.parse(args);
    task=Task.getEnum(opts.task);
  }
 catch (  IllegalArgumentException e) {
    parser.printUsage();
    System.exit(1);
  }
  Instances trainSet=InstancesReader.read(opts.attPath,opts.trainPath);
  LassoLearner learner=new LassoLearner();
  learner.setVerbose(true);
  learner.setTask(task);
  learner.setLambda(opts.lambda);
  learner.setMaxNumIters(opts.maxIter);
  long start=System.currentTimeMillis();
  GLM glm=learner.build(trainSet);
  long end=System.currentTimeMillis();
  System.out.println("String_Node_Str" + (end - start) / 1000.0);
  if (opts.outputModelPath != null) {
    PredictorWriter.write(glm,opts.outputModelPath);
  }
}