nus-yam/ex-repair huggingface dataset:
Program: 149480
Project: 149480
Buggy source:
@Override public void tickEnd(EnumSet<TickType> type,Object... tickData){
  if (paused) {
    return;
  }
  World world=(World)tickData[0];
  boolean flag=delay == 1;
  if (world.getWorldTime() % delay == 0 || flag) {
    ArrayList<ChunkData> list=todoList.get(world.provider.dimensionId);
    if (list != null) {
      if (list.size() > 0) {
        ChunkData data=list.get(0);
        Chunk target=getChunk(world,data);
        if (target != null) {
          this.retrogenerateChunk(world,target);
          data.saveChunk(world,target);
        }
 else         if (!data.hasNextChunk()) {
          list.remove(0);
        }
      }
 else {
        todoList.remove(world.provider.dimensionId);
      }
    }
  }
  if (world.getWorldTime() % 200 == 0) {
    SpmodAPI.log.print("String_Node_Str" + world.provider.getDimensionName() + "String_Node_Str"+ (todoList.get(world.provider.dimensionId) != null ? todoList.get(world.provider.dimensionId).size() : "String_Node_Str")+ "String_Node_Str");
  }
  if (todoList.isEmpty() || todoList.size() <= 0) {
    if (this.totalShutdownDelay == 2000) {
      MinecraftServer.getServer().getConfigurationManager().func_110459_a(LangProxy.getText("String_Node_Str",EnumChatFormatting.DARK_RED),false);
    }
    this.totalShutdownDelay--;
    if (totalShutdownDelay <= 0) {
      MinecraftServer.getServer().initiateShutdown();
    }
  }
 else {
    this.totalShutdownDelay=2000;
  }
}

Fixed version (ground truth):
@Override public void tickEnd(EnumSet<TickType> type,Object... tickData){
  if (paused) {
    return;
  }
  World world=(World)tickData[0];
  boolean flag=delay == 1;
  if (world.getWorldTime() % delay == 0 || flag) {
    ArrayList<ChunkData> list=todoList.get(world.provider.dimensionId);
    if (list != null) {
      if (list.size() > 0) {
        ChunkData data=list.get(0);
        Chunk target=getChunk(world,data);
        if (target != null) {
          this.retrogenerateChunk(world,target);
          data.saveChunk(world,target);
        }
 else         if (!data.hasNextChunk()) {
          list.remove(0);
        }
      }
 else {
        todoList.remove(world.provider.dimensionId);
      }
    }
  }
  if (world.getWorldTime() % 200 == 0) {
    SpmodAPI.log.print("String_Node_Str" + world.provider.getDimensionName() + "String_Node_Str"+ (todoList.get(world.provider.dimensionId) != null ? getSizeFromList(todoList.get(world.provider.dimensionId)) : "String_Node_Str")+ "String_Node_Str");
  }
  if (todoList.isEmpty() || todoList.size() <= 0) {
    if (this.totalShutdownDelay == 2000) {
      MinecraftServer.getServer().getConfigurationManager().func_110459_a(LangProxy.getText("String_Node_Str",EnumChatFormatting.DARK_RED),false);
    }
    this.totalShutdownDelay--;
    if (totalShutdownDelay <= 0) {
      MinecraftServer.getServer().initiateShutdown();
    }
  }
 else {
    this.totalShutdownDelay=2000;
  }
}
Program: 149482
Project: 149482
Buggy source:
@Override public void loadPipe(ItemPipe par1,int id,Class<? extends Pipe> par2){
  try {
    Pipe pipe=(Pipe)par2.getConstructor(new Class[]{Integer.TYPE}).newInstance(new Object[]{Integer.valueOf(id)});
    MinecraftForgeClient.registerItemRenderer(par1.itemID,ItemRendererBCPipe.pipe);
    if (pipe != null) {
      par1.setPipesIcons(pipe.getIconProvider());
      par1.setPipeIconIndex(pipe.getIconIndex(ForgeDirection.UNKNOWN));
    }
  }
 catch (  Exception e) {
  }
}

Fixed version (ground truth):
@Override public void loadPipe(ItemPipe par1,int id,Class<? extends Pipe> par2){
  try {
    Pipe pipe=(Pipe)par2.getConstructor(new Class[]{Integer.TYPE}).newInstance(new Object[]{Integer.valueOf(id)});
    MinecraftForgeClient.registerItemRenderer(par1.itemID,ItemRenderSpmodCore.instance);
    if (pipe != null) {
      par1.setPipesIcons(pipe.getIconProvider());
      par1.setPipeIconIndex(pipe.getIconIndex(ForgeDirection.UNKNOWN));
    }
  }
 catch (  Exception e) {
  }
}
Program: 149483
Project: 149483
Buggy source:
@Override public void renderItem(ItemRenderType type,ItemStack item,Object... data){
  BlockStack stack=new BlockStack(item);
  IBlockRenderer render=stack.getCastedBlock(IBlockRenderer.class);
  if (render != null) {
    RenderBlocksSpmod renderer=new RenderBlocksSpmod((RenderBlocks)data[0]);
    if (render.renderItemBlockBasic(item.getItemDamage())) {
      renderBlock(render,stack,renderer,type);
    }
 else {
      float[] key=render.getXYZForItemRenderer(type,stack.getMeta());
      if (key == null || key.length != 3) {
        key=new float[]{0.5F,0.5F,0.5F};
      }
      int renderPasses=render.getItemRenderPasses(stack.getMeta());
      if (renderPasses <= 0) {
        renderPasses=1;
      }
      for (int i=0; i < renderPasses; i++) {
        if (type == type.INVENTORY) {
          render.onItemRendering(helper,type,stack,i,key[0],key[1],key[2],item,renderer);
        }
 else {
          render.onItemRendering(helper,type,stack,i,key[0],key[1],key[2],item,renderer,data[1]);
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override public void renderItem(ItemRenderType type,ItemStack item,Object... data){
  BlockStack stack=new BlockStack(item);
  IBlockRenderer render=stack.getCastedBlock(IBlockRenderer.class);
  if (render != null) {
    RenderBlocks renderer=(RenderBlocks)data[0];
    if (render.renderItemBlockBasic(item.getItemDamage())) {
      renderBlock(render,stack,renderer,type);
    }
 else {
      float[] key=render.getXYZForItemRenderer(type,stack.getMeta());
      if (key == null || key.length != 3) {
        key=new float[]{0.5F,0.5F,0.5F};
      }
      int renderPasses=render.getItemRenderPasses(stack.getMeta());
      if (renderPasses <= 0) {
        renderPasses=1;
      }
      for (int i=0; i < renderPasses; i++) {
        if (type == type.INVENTORY) {
          render.onItemRendering(helper,type,stack,i,key[0],key[1],key[2],item,renderer);
        }
 else {
          render.onItemRendering(helper,type,stack,i,key[0],key[1],key[2],item,renderer,data[1]);
        }
      }
    }
  }
}
Program: 149484
Project: 149484
Buggy source:
private void renderLamp(TileLamp Lamp,double x,double y,double z){
  try {
    GL11.glPushMatrix();
    float f=1.0F;
    GL11.glTranslatef((float)x + 0.5F,(float)y + 0.5F,(float)z + 0.5F);
    EnumLampType type=Lamp.getType();
    if (type == null) {
      GL11.glPopMatrix();
      return;
    }
    if (type.hasFacing()) {
      int facing=Lamp.getFacing();
switch (facing) {
case 0:
        break;
case 1:
      GL11.glRotatef(180,1,0,0);
    break;
case 2:
  GL11.glRotatef(90,1,0,0);
break;
case 3:
GL11.glRotatef(-90,1,0,0);
break;
case 4:
GL11.glRotatef(-90,0,0,1);
break;
case 5:
GL11.glRotatef(90,0,0,1);
}
GL11.glRotatef(180,1,0,0);
}
if (type.getTexture() != null) {
this.bindTexture(type.getTexture());
}
GL11.glTranslatef(0,-f,0);
SpmodColor color=Lamp.getColor();
if (color != null) {
GL11.glColor4d(color.red,color.green,color.blue,1.0D);
}
lamp.render(0.0625F,type.getRenderType());
GL11.glColor4f(1.0F,1.0F,1.0F,1.0F);
lamp.renderAfter(0.0625F,type.getRenderType());
GL11.glPopMatrix();
}
 catch (Exception e) {
}
}

Fixed version (ground truth):
private void renderLamp(TileLamp Lamp,double x,double y,double z){
  GL11.glPushMatrix();
  try {
    float f=1.0F;
    GL11.glTranslatef((float)x + 0.5F,(float)y + 0.5F,(float)z + 0.5F);
    EnumLampType type=Lamp.getType();
    if (type == null) {
      GL11.glPopMatrix();
      return;
    }
    if (type.hasFacing()) {
      int facing=Lamp.getFacing();
switch (facing) {
case 0:
        break;
case 1:
      GL11.glRotatef(180,1,0,0);
    break;
case 2:
  GL11.glRotatef(90,1,0,0);
break;
case 3:
GL11.glRotatef(-90,1,0,0);
break;
case 4:
GL11.glRotatef(-90,0,0,1);
break;
case 5:
GL11.glRotatef(90,0,0,1);
}
GL11.glRotatef(180,1,0,0);
}
if (type.getTexture() != null) {
this.bindTexture(type.getTexture());
}
GL11.glTranslatef(0,-f,0);
SpmodColor color=Lamp.getColor();
if (color != null) {
GL11.glColor4d(color.red,color.green,color.blue,1.0D);
}
lamp.render(0.0625F,type.getRenderType());
GL11.glColor4f(1.0F,1.0F,1.0F,1.0F);
lamp.renderAfter(0.0625F,type.getRenderType());
}
 catch (Exception e) {
}
GL11.glPopMatrix();
}
Program: 149485
Project: 149485
Buggy source:
@Override public void registerRenderer(){
  ClientRegistry.bindTileEntitySpecialRenderer(TinyChest.class,new RenderStorageBlock());
  ClientRegistry.bindTileEntitySpecialRenderer(TinyTank.class,new RenderStorageBlock());
  ClientRegistry.bindTileEntitySpecialRenderer(AdvTinyChest.class,new RenderStorageBlock());
  ClientRegistry.bindTileEntitySpecialRenderer(AdvTinyTank.class,new RenderStorageBlock());
  ClientRegistry.bindTileEntitySpecialRenderer(MachineWaterSpender.class,new RenderWaterSpender());
  ClientRegistry.bindTileEntitySpecialRenderer(TinyHopper.class,new renderTransportTile());
  RenderingRegistry.registerEntityRenderingHandler(TCarts.class,new RenderTCarts());
  MinecraftForgeClient.registerItemRenderer(TinyItems.cell.itemID,new RendererItemCell());
  if (Loader.isModLoaded("String_Node_Str")) {
    NeiRegistry.getInstance().init();
  }
  TinyChestCart.cart=new ModelMinecart();
  AdvTinyChestCart.cart=new ModelMinecart();
  if (Loader.isModLoaded("String_Node_Str")) {
    loadPipeToolTips();
  }
}

Fixed version (ground truth):
@Override public void registerRenderer(){
  ClientRegistry.bindTileEntitySpecialRenderer(TinyChest.class,new RenderStorageBlock());
  ClientRegistry.bindTileEntitySpecialRenderer(TinyTank.class,new RenderStorageBlock());
  ClientRegistry.bindTileEntitySpecialRenderer(AdvTinyChest.class,new RenderStorageBlock());
  ClientRegistry.bindTileEntitySpecialRenderer(AdvTinyTank.class,new RenderStorageBlock());
  ClientRegistry.bindTileEntitySpecialRenderer(MachineWaterSpender.class,new RenderWaterSpender());
  ClientRegistry.bindTileEntitySpecialRenderer(TinyHopper.class,new renderTransportTile());
  RenderingRegistry.registerBlockHandler(MultiID,new RenderTransport());
  RenderingRegistry.registerEntityRenderingHandler(TCarts.class,new RenderTCarts());
  MinecraftForgeClient.registerItemRenderer(TinyItems.cell.itemID,new RendererItemCell());
  if (Loader.isModLoaded("String_Node_Str")) {
    NeiRegistry.getInstance().init();
  }
  TinyChestCart.cart=new ModelMinecart();
  AdvTinyChestCart.cart=new ModelMinecart();
  if (Loader.isModLoaded("String_Node_Str")) {
    loadPipeToolTips();
  }
}
Program: 149486
Project: 149486
Buggy source:
@Override public void readFromNBT(NBTTagCompound nbt){
  super.readFromNBT(nbt);
  mode=nbt.getInteger("String_Node_Str");
  isFull=nbt.getBoolean("String_Node_Str");
  isEmpty=nbt.getBoolean("String_Node_Str");
  NBTTagList nbttaglist=nbt.getTagList("String_Node_Str");
  inventory=new ItemStack[getSizeInventory()];
  for (int i=0; i < nbttaglist.tagCount(); ++i) {
    NBTTagCompound nbttagcompound1=(NBTTagCompound)nbttaglist.tagAt(i);
    byte b0=nbttagcompound1.getByte("String_Node_Str");
    if (b0 >= 0 && b0 < inventory.length) {
      inventory[b0]=ItemStack.loadItemStackFromNBT(nbttagcompound1);
    }
  }
}

Fixed version (ground truth):
@Override public void readFromNBT(NBTTagCompound nbt){
  super.readFromNBT(nbt);
  mode=nbt.getInteger("String_Node_Str");
  isFull=nbt.getBoolean("String_Node_Str");
  isEmpty=nbt.getBoolean("String_Node_Str");
  NBTTagList nbttaglist=nbt.getTagList("String_Node_Str");
  inventory=new ItemStack[mode < 0 ? 0 : mode];
  for (int i=0; i < nbttaglist.tagCount(); ++i) {
    NBTTagCompound nbttagcompound1=(NBTTagCompound)nbttaglist.tagAt(i);
    byte b0=nbttagcompound1.getByte("String_Node_Str");
    if (b0 >= 0 && b0 < inventory.length) {
      inventory[b0]=ItemStack.loadItemStackFromNBT(nbttagcompound1);
    }
  }
}
Program: 149487
Project: 149487
Buggy source:
@Override public boolean renderItemBlockBasic(int meta){
switch (meta) {
case 0:
case 4:
    return true;
}
return false;
}

Fixed version (ground truth):
@Override public boolean renderItemBlockBasic(int meta){
  return true;
}
Program: 149488
Project: 149488
Buggy source:
@Override public boolean renderItemBlock(int meta){
switch (meta) {
case 0:
case 4:
    return true;
}
return false;
}

Fixed version (ground truth):
@Override public boolean renderItemBlock(int meta){
  return true;
}
Program: 149489
Project: 149489
Buggy source:
@Override public boolean requiresRenderPass(int meta){
switch (meta) {
case 1:
case 2:
case 3:
    return true;
}
return super.requiresRenderPass(meta);
}

Fixed version (ground truth):
@Override public boolean requiresRenderPass(int meta){
  return meta > 0 && meta < 3;
}
Program: 149490
Project: 149490
Buggy source:
@Override public void clientSide(){
  ForgeRegister.regsiterClient();
  ClientRegistry.bindTileEntitySpecialRenderer(TileLamp.class,new RenderLamp());
  ClientRegistry.bindTileEntitySpecialRenderer(MultiPlate.class,new RenderHanfSign());
  MinecraftForgeClient.registerItemRenderer(APIBlocks.hempLamp.blockID,new ItemRendererLamp());
  RenderingRegistry.registerBlockHandler(RenderUtilsBlock.renderID,new RenderUtilsBlock());
  MinecraftForgeClient.registerItemRenderer(APIBlocks.blockUtils.blockID,new ItemRendererUtilsBlock());
  MinecraftForgeClient.registerItemRenderer(APIBlocks.statues.blockID,new ItemRendererStatue());
  ClientRegistry.bindTileEntitySpecialRenderer(KyrokaTheFox.class,new RenderKyroka());
}

Fixed version (ground truth):
@Override public void clientSide(){
  ForgeRegister.regsiterClient();
  ClientRegistry.bindTileEntitySpecialRenderer(TileLamp.class,new RenderLamp());
  ClientRegistry.bindTileEntitySpecialRenderer(MultiPlate.class,new RenderHanfSign());
  MinecraftForgeClient.registerItemRenderer(APIBlocks.hempLamp.blockID,new ItemRendererLamp());
  RenderingRegistry.registerBlockHandler(RenderUtilsBlock.renderID,new RenderUtilsBlock());
  MinecraftForgeClient.registerItemRenderer(APIBlocks.blockUtils.blockID,new ItemRendererUtilsBlock());
  MinecraftForgeClient.registerItemRenderer(APIBlocks.statues.blockID,new ItemRendererStatue());
  ClientRegistry.bindTileEntitySpecialRenderer(KyrokaTheFox.class,new RenderKyroka());
  RenderingRegistry.registerBlockHandler(new BlockRendererSpmodCore());
}
Program: 149492
Project: 149492
Buggy source:
public void loadEntityCatcher(IBlockAccess world,int x,int y,int z,Block block,RenderBlocks blocks){
  Tessellator tes=Tessellator.instance;
  Minecraft mc=FMLClientHandler.instance().getClient();
  tes.draw();
  mc.renderEngine.bindTexture(TextureMap.locationItemsTexture);
  tes.startDrawingQuads();
  tes.setNormal(1F,1F,0F);
  blocks.setOverrideBlockTexture(Item.porkRaw.getIconFromDamage(0));
  blocks.renderCrossedSquares(block,x,y,z);
  blocks.clearOverrideBlockTexture();
  tes.draw();
  tes.startDrawingQuads();
  mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture);
  blocks.renderStandardBlock(block,x,y,z);
}

Fixed version (ground truth):
public void loadEntityCatcher(IBlockAccess world,int x,int y,int z,Block block,RenderBlocks render){
  Tessellator tes=Tessellator.instance;
  Minecraft mc=FMLClientHandler.instance().getClient();
  tes.draw();
  mc.renderEngine.bindTexture(TextureMap.locationItemsTexture);
  tes.startDrawingQuads();
  tes.setNormal(1F,1F,0F);
  render.setOverrideBlockTexture(Item.porkRaw.getIconFromDamage(0));
  render.renderCrossedSquares(block,x,y,z);
  render.clearOverrideBlockTexture();
  tes.draw();
  tes.startDrawingQuads();
  mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture);
  render.renderStandardBlock(block,x,y,z);
}
Program: 149493
Project: 149493
Buggy source:
public GuiCommands(InventoryPlayer par1){
  super(new AdvContainer(par1,24,143){
    @Override public boolean canInteractWith(    EntityPlayer entityplayer){
      return true;
    }
  }
);
  sender=par1.player;
  this.ySize=224;
  this.xSize=200;
}

Fixed version (ground truth):
public GuiCommands(InventoryPlayer par1){
  super(new AdvContainer(par1,24,143){
    @Override public boolean canInteractWith(    EntityPlayer entityplayer){
      return true;
    }
  }
);
  sender=par1.player;
  this.ySize=224;
  this.xSize=210;
}
Program: 149494
Project: 149494
Buggy source:
public void breakBlock(World par1World,int par2,int par3,int par4,int par5,int par6){
  super.breakBlock(par1World,par2,par3,par4,par5,par6);
  par1World.removeBlockTileEntity(par2,par3,par4);
}

Fixed version (ground truth):
public void breakBlock(World par1World,int par2,int par3,int par4,int par5,int par6){
  TileEntity tile=par1World.getBlockTileEntity(par2,par3,par4);
  if (tile != null && tile instanceof AdvTile) {
    ((AdvTile)tile).onBreaking();
  }
  super.breakBlock(par1World,par2,par3,par4,par5,par6);
  par1World.removeBlockTileEntity(par2,par3,par4);
}
Program: 149495
Project: 149495
Buggy source:
@Override public int addItem(ItemStack stack,boolean doAdd,ForgeDirection from){
  if (this.containesContainer(stack)) {
    ItemStack cu=inv[0].copy();
    if (cu.isItemEqual(stack)) {
      int left=64 - (stack.stackSize + cu.stackSize);
      if (left < 0) {
        if (doAdd) {
          cu.stackSize=64;
          inv[0]=cu;
        }
        return stack.stackSize - left;
      }
 else {
        if (doAdd) {
          cu.stackSize+=stack.stackSize;
          inv[0]=cu;
        }
        return stack.stackSize;
      }
    }
  }
  return 0;
}

Fixed version (ground truth):
@Override public int addItem(ItemStack stack,boolean doAdd,ForgeDirection from){
  if (this.containesContainer(stack)) {
    ItemStack cu=inv[0];
    if (cu != null) {
      if (cu.isItemEqual(stack)) {
        int left=stack.getMaxStackSize() - (stack.stackSize + cu.stackSize);
        if (left < 0) {
          if (doAdd) {
            cu.stackSize=64;
            inv[0]=cu;
          }
          return stack.stackSize - left;
        }
 else {
          if (doAdd) {
            cu.stackSize+=stack.stackSize;
            inv[0]=cu;
          }
          return stack.stackSize;
        }
      }
    }
 else {
      if (doAdd) {
        inv[0]=stack;
      }
      return stack.stackSize;
    }
  }
  return 0;
}
Program: 149496
Project: 149496
Buggy source:
@Override public LinkedList<ITrigger> getNeighborTriggers(Block block,TileEntity tile){
  LinkedList<ITrigger> triggers=new LinkedList<ITrigger>();
  if (tile != null) {
    if (tile instanceof TileEntityFurnace) {
      triggers.add(BCVariables.noWork);
      triggers.add(BCVariables.hasWork);
      triggers.add(BCVariables.needFuel);
    }
    try {
      if (tile instanceof IPowerReceptor) {
        triggers.add(BCVariables.requestPower);
      }
    }
 catch (    Exception e) {
    }
  }
  return triggers;
}

Fixed version (ground truth):
@Override public LinkedList<ITrigger> getNeighborTriggers(Block block,TileEntity tile){
  LinkedList<ITrigger> triggers=new LinkedList<ITrigger>();
  if (tile != null) {
    if (tile instanceof TileEntityFurnace) {
      triggers.add(BCVariables.noWork);
      triggers.add(BCVariables.hasWork);
      triggers.add(BCVariables.needFuel);
    }
    if (tile instanceof TileEntityBrewingStand) {
      triggers.add(BCVariables.hasWork);
      triggers.add(BCVariables.noWork);
    }
    try {
      if (tile instanceof IPowerReceptor) {
        triggers.add(BCVariables.requestPower);
      }
    }
 catch (    Exception e) {
    }
  }
  return triggers;
}
Program: 149497
Project: 149497
Buggy source:
@Override public boolean isTriggerActive(ForgeDirection side,TileEntity tile,ITriggerParameter parameter){
  if (tile != null) {
    if (tile instanceof PressureFurnace) {
      if (Active) {
        return ((PressureFurnace)tile).currentRecipe != null;
      }
 else {
        return ((PressureFurnace)tile).currentRecipe == null;
      }
    }
 else     if (tile instanceof TileEntityFurnace) {
      if (Active) {
        return canSmelt((TileEntityFurnace)tile);
      }
      return !canSmelt((TileEntityFurnace)tile);
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean isTriggerActive(ForgeDirection side,TileEntity tile,ITriggerParameter parameter){
  if (tile != null) {
    if (tile instanceof PressureFurnace) {
      if (Active) {
        return ((PressureFurnace)tile).currentRecipe != null;
      }
 else {
        return ((PressureFurnace)tile).currentRecipe == null;
      }
    }
    if (tile instanceof TileEntityFurnace) {
      if (Active) {
        return canSmelt((TileEntityFurnace)tile);
      }
      return !canSmelt((TileEntityFurnace)tile);
    }
    if (tile instanceof TileEntityBrewingStand) {
      TileEntityBrewingStand brew=(TileEntityBrewingStand)tile;
      if (Active) {
        return this.canBrew(brew);
      }
      return !this.canBrew(brew);
    }
  }
  return false;
}
Program: 149498
Project: 149498
Buggy source:
@Override public void onTick(){
  super.onTick();
  updateBlock();
  if (!worldObj.isRemote) {
    if (worldObj.getWorldTime() % 80 == 0) {
      PacketDispatcher.sendPacketToAllAround(xCoord,yCoord,zCoord,20,worldObj.provider.dimensionId,getDescriptionPacket());
    }
    if (worldObj.getWorldTime() % 15 == 0) {
      renderTank=WorldReading.isBlockBlocked(worldObj,xCoord,yCoord,zCoord,true);
    }
    if (this.tank.getFluid() != null) {
      if (canFillBelow()) {
        fillBelow();
      }
 else {
        fillToSide();
      }
    }
    if (this.BCTank) {
      TileEntity tile=worldObj.getBlockTileEntity(xCoord,yCoord + 1,zCoord);
      if (tile != null && tile instanceof TileTank) {
        TileTank tanks=(TileTank)tile;
        tanks.drain(ForgeDirection.DOWN,this.tank.fill(tanks.tank.getFluid(),true),true);
      }
    }
  }
}

Fixed version (ground truth):
@Override public void onTick(){
  super.onTick();
  updateBlock();
  if (!worldObj.isRemote) {
    if (worldObj.getWorldTime() % 80 == 0) {
      PacketDispatcher.sendPacketToAllAround(xCoord,yCoord,zCoord,20,worldObj.provider.dimensionId,getDescriptionPacket());
    }
    if (worldObj.getWorldTime() % 15 == 0) {
      renderTank=WorldReading.isBlockBlocked(worldObj,xCoord,yCoord,zCoord,true);
    }
    if (this.tank.getFluid() != null) {
      fillBelow();
      fillToSide();
    }
    if (this.BCTank) {
      TileEntity tile=worldObj.getBlockTileEntity(xCoord,yCoord + 1,zCoord);
      if (tile != null && tile instanceof TileTank) {
        TileTank tanks=(TileTank)tile;
        tanks.drain(ForgeDirection.DOWN,this.tank.fill(tanks.tank.getFluid(),true),true);
      }
    }
  }
}
Program: 149499
Project: 149499
Buggy source:
@Override public void loadPipe(ItemPipe par1,int id,Class<? extends Pipe> par2){
  try {
    Pipe pipe=(Pipe)par2.getConstructor(new Class[]{Integer.TYPE}).newInstance(new Object[]{Integer.valueOf(id)});
    if (pipe != null) {
      par1.setPipesIcons(pipe.getIconProvider());
      par1.setPipeIconIndex(pipe.getIconIndex(ForgeDirection.VALID_DIRECTIONS[0]));
    }
  }
 catch (  Exception e) {
  }
}

Fixed version (ground truth):
@Override public void loadPipe(ItemPipe par1,int id,Class<? extends Pipe> par2){
  try {
    Pipe pipe=(Pipe)par2.getConstructor(new Class[]{Integer.TYPE}).newInstance(new Object[]{Integer.valueOf(id)});
    MinecraftForgeClient.registerItemRenderer(par1.itemID,ItemRendererBCPipe.pipe);
    if (pipe != null) {
      par1.setPipesIcons(pipe.getIconProvider());
      par1.setPipeIconIndex(pipe.getIconIndex(ForgeDirection.VALID_DIRECTIONS[0]));
    }
  }
 catch (  Exception e) {
  }
}
Program: 149500
Project: 149500
Buggy source:
public void updateRedstone(){
  int fullSlot=0;
  for (int i=0; i < mode; i++) {
    ItemStack stack=getStackInSlot(i);
    if (stack != null && stack.stackSize >= stack.getMaxStackSize()) {
      fullSlot++;
    }
  }
  if (fullSlot == mode) {
    isFull=true;
  }
 else {
    isFull=false;
  }
  if (fullSlot == 0) {
    isEmpty=true;
  }
 else {
    isEmpty=false;
  }
  update=true;
}

Fixed version (ground truth):
public void updateRedstone(){
  int fullSlot=0;
  for (int i=0; i < this.getSizeInventory(); i++) {
    ItemStack stack=getStackInSlot(i);
    if (stack != null && stack.stackSize >= stack.getMaxStackSize()) {
      fullSlot++;
    }
  }
  if (fullSlot == this.getSizeInventory()) {
    isFull=true;
  }
 else {
    isFull=false;
  }
  if (fullSlot == 0) {
    isEmpty=true;
  }
 else {
    isEmpty=false;
  }
  update=true;
}
Program: 149501
Project: 149501
Buggy source:
public static void read(MinecraftServer server){
  if (server == null) {
    return;
  }
  String path="String_Node_Str";
  if (!server.isDedicatedServer()) {
    path+="String_Node_Str";
  }
  path+=server.getFolderName() + "String_Node_Str";
  FMLLog.getLogger().info("String_Node_Str");
  try {
    SpmodMod[] mods=nbtStorage.keySet().toArray(new SpmodMod[nbtStorage.keySet().size()]);
    for (int i=0; i < mods.length; i++) {
      SpmodMod mod=mods[i];
      File file=new File(path,mod.getName() + "String_Node_Str");
      if (file.exists() && file.isFile()) {
        DataInputStream stream=new DataInputStream(new BufferedInputStream(new FileInputStream(file)));
        NBTTagCompound nbt=(NBTTagCompound)NBTBase.readNamedTag(stream);
        SpmodMod fileMod=SpmodModRegistry.getModFromName(nbt.getString("String_Node_Str"));
        if (SpmodModRegistry.areModsEqual(mod,fileMod) && SpmodModRegistry.isModRegistered(mod)) {
          NBTTagList list=nbt.getTagList("String_Node_Str");
          for (int z=0; z < list.tagCount(); z++) {
            NBTTagCompound cu=(NBTTagCompound)list.tagAt(z);
            INBTReciver re=getReciverFromModAndID(mod,cu.getString("String_Node_Str"));
            if (re != null) {
              re.loadFromNBT(cu);
            }
          }
        }
        stream.close();
      }
    }
  }
 catch (  Exception e) {
  }
  FMLLog.getLogger().info("String_Node_Str");
}

Fixed version (ground truth):
public static void read(MinecraftServer server){
  if (server == null) {
    return;
  }
  String path="String_Node_Str";
  if (!server.isDedicatedServer()) {
    path+="String_Node_Str";
  }
  path+=server.getFolderName() + "String_Node_Str";
  FMLLog.getLogger().info("String_Node_Str");
  try {
    SpmodMod[] mods=nbtStorage.keySet().toArray(new SpmodMod[nbtStorage.keySet().size()]);
    for (int i=0; i < mods.length; i++) {
      SpmodMod mod=mods[i];
      File file=new File(path,mod.getName() + "String_Node_Str");
      if (file.exists() && file.isFile()) {
        DataInputStream stream=new DataInputStream(new BufferedInputStream(new FileInputStream(file)));
        NBTTagCompound nbt=(NBTTagCompound)NBTBase.readNamedTag(stream);
        SpmodMod fileMod=SpmodModRegistry.getModFromName(nbt.getString("String_Node_Str"));
        if (SpmodModRegistry.areModsEqual(mod,fileMod) && SpmodModRegistry.isModRegistered(mod)) {
          NBTTagList list=nbt.getTagList("String_Node_Str");
          for (int z=0; z < list.tagCount(); z++) {
            NBTTagCompound cu=(NBTTagCompound)list.tagAt(z);
            INBTReciver re=getReciverFromModAndID(mod,cu.getString("String_Node_Str"));
            if (re != null) {
              re.loadFromNBT(cu);
            }
          }
        }
        stream.close();
      }
    }
    for (    SpmodMod mod : mods) {
      ArrayList<INBTReciver> data=nbtStorage.get(mod);
      if (data != null) {
        for (int i=0; i < data.size(); i++) {
          INBTReciver nbt=data.get(i);
          nbt.finishLoading();
        }
      }
    }
  }
 catch (  Exception e) {
  }
  FMLLog.getLogger().info("String_Node_Str");
}
Program: 149502
Project: 149502
Buggy source:
public void PreCharge(ItemStack par1,World world,EntityPlayer player){
  if (!world.isRemote) {
    if (world.provider.dimensionId == -1) {
      if (par1.getItemDamage() == 1) {
        chargeCrystal(par1,world,player);
      }
      if (par1.getItemDamage() == 2) {
        cleanUpArea(par1,world);
      }
      if (par1.getItemDamage() == 4) {
        recharge(par1);
      }
    }
  }
}

Fixed version (ground truth):
public void PreCharge(ItemStack par1,World world,EntityPlayer player){
  if (!world.isRemote) {
    if (world.provider.dimensionId == -1) {
      if (dataLoaded == DataType.Loaded && hasWork(par1)) {
        if (par1.getItemDamage() == 1) {
          chargeCrystal(par1,world,player);
        }
        if (par1.getItemDamage() == 2) {
          cleanUpArea(par1,world);
        }
      }
      if (par1.getItemDamage() == 4) {
        recharge(par1);
      }
    }
  }
}
Program: 149503
Project: 149503
Buggy source:
@Override public void loadFromNBT(NBTTagCompound par1){
  dataLoaded=false;
  NBTTagList first=par1.getTagList("String_Node_Str");
  todo.clear();
  for (int i=0; i < first.tagCount(); i++) {
    NBTTagCompound nbt=(NBTTagCompound)first.tagAt(i);
    todo.put(nbt.getString("String_Node_Str"),new BlockPositionList(nbt));
  }
  NBTTagList second=par1.getTagList("String_Node_Str");
  replace.clear();
  for (int i=0; i < second.tagCount(); i++) {
    NBTTagCompound nbt=(NBTTagCompound)second.tagAt(i);
    replace.put(nbt.getString("String_Node_Str"),new BlockPositionList(nbt));
  }
  dataLoaded=true;
}

Fixed version (ground truth):
@Override public void loadFromNBT(NBTTagCompound par1){
  dataLoaded=DataType.Loading;
  NBTTagList first=par1.getTagList("String_Node_Str");
  todo.clear();
  for (int i=0; i < first.tagCount(); i++) {
    NBTTagCompound nbt=(NBTTagCompound)first.tagAt(i);
    todo.put(nbt.getString("String_Node_Str"),new BlockPositionList(nbt));
  }
  NBTTagList second=par1.getTagList("String_Node_Str");
  replace.clear();
  for (int i=0; i < second.tagCount(); i++) {
    NBTTagCompound nbt=(NBTTagCompound)second.tagAt(i);
    replace.put(nbt.getString("String_Node_Str"),new BlockPositionList(nbt));
  }
  dataLoaded=DataType.Loaded;
}
Program: 149504
Project: 149504
Buggy source:
public static void initRecipes(){
  GameRegistry.addShapelessRecipe(new ItemStack(Item.skull,1,1),new Object[]{Item.diamond,Item.diamond,Block.coalBlock,Item.arrow,Item.arrow,Item.bone,Item.bone});
  GameRegistry.addRecipe(new ItemStack(TinyItems.interfaceBlock,4,0),new Object[]{"String_Node_Str","String_Node_Str","String_Node_Str",'B',TinyBlocks.normalPipe,'Y',Block.hopperBlock,'C',ItemGear.getGearFromType(GearType.Redstone),'V',Block.chest,'X',new ItemStack(TinyItems.ingots,1,EnumIngots.Aluminum.getIngotMeta())});
  GameRegistry.addRecipe(ItemNetherCrystal.createEmptyNetherCrystal(TinyItems.netherCrystal.itemID),new Object[]{"String_Node_Str","String_Node_Str","String_Node_Str"},'X',Item.netherStar,'C',Item.diamond,'Y',Item.enderPearl);
  GameRegistry.addShapelessRecipe(ItemNetherCrystal.createEmptyNetherCrystal(TinyItems.netherCrystal.itemID),new Object[]{new ItemStack(TinyItems.netherCrystal,1,5),Item.diamond,Item.enderPearl});
}

Fixed version (ground truth):
public static void initRecipes(){
  GameRegistry.addShapelessRecipe(new ItemStack(Item.skull,1,1),new Object[]{Item.diamond,Item.diamond,Block.coalBlock,Item.arrow,Item.arrow,Item.bone,Item.bone});
  GameRegistry.addRecipe(new ItemStack(TinyItems.interfaceBlock,4,0),new Object[]{"String_Node_Str","String_Node_Str","String_Node_Str",'B',TinyBlocks.normalPipe,'Y',Block.hopperBlock,'C',ItemGear.getGearFromType(GearType.Redstone),'V',Block.chest,'X',new ItemStack(TinyItems.ingots,1,EnumIngots.Aluminum.getIngotMeta())});
  GameRegistry.addRecipe(ItemNetherCrystal.createEmptyNetherCrystal(TinyItems.netherCrystal.itemID),new Object[]{"String_Node_Str","String_Node_Str","String_Node_Str",'X',Item.netherStar,'C',Item.diamond,'Y',Item.enderPearl});
  GameRegistry.addShapelessRecipe(ItemNetherCrystal.createEmptyNetherCrystal(TinyItems.netherCrystal.itemID),new Object[]{new ItemStack(TinyItems.netherCrystal,1,5),Item.diamond,Item.enderPearl});
}
Program: 149505
Project: 149505
Buggy source:
private void login(final WifiManager wm,final boolean isFirst){
  final String ssid=WakefulIntentService.stripQuotes(wm.getConnectionInfo().getSSID());
  final LoginResult lr=LoginManager.login(ssid,getUsername(),getPassword());
switch (lr.getResponseCode()) {
case Constants.WISPR_RESPONSE_CODE_LOGIN_SUCCEEDED:
case Constants.CUST_ALREADY_CONNECTED:
    handleSuccess(ssid,lr,isFirst);
  break;
case Constants.WISPR_RESPONSE_CODE_RADIUS_ERROR:
case Constants.WISPR_RESPONSE_CODE_NETWORK_ADMIN_ERROR:
case Constants.FON_SESSION_LIMIT_EXCEEDED:
case Constants.FON_SPOT_LIMIT_EXCEEDED:
case Constants.FON_UNKNOWN_ERROR:
case Constants.CUST_WISPR_NOT_PRESENT:
handleError(wm,lr);
break;
case Constants.FON_NOT_ENOUGH_CREDIT:
case Constants.FON_USER_IN_BLACK_LIST:
case Constants.FON_NOT_AUTHORIZED:
case Constants.FON_CUSTOMIZED_ERROR:
case Constants.FON_INTERNAL_ERROR:
case Constants.FON_INVALID_TEMPORARY_CREDENTIAL:
case Constants.FON_AUTHORIZATION_CONNECTION_ERROR:
notifyFonError(lr);
break;
case Constants.FON_INVALID_CREDENTIALS_ALT:
case Constants.FON_INVALID_CREDENTIALS:
case Constants.CUST_CREDENTIALS_ERROR:
notifyCredentialsError();
break;
default :
break;
}
}

Fixed version (ground truth):
private void login(final WifiManager wm,final boolean isFirst){
  final String ssid=WakefulIntentService.stripQuotes(wm.getConnectionInfo().getSSID());
  final LoginResult lr=LoginManager.login(ssid,getUsername(),getPassword());
switch (lr.getResponseCode()) {
case Constants.WISPR_RESPONSE_CODE_LOGIN_SUCCEEDED:
case Constants.CUST_ALREADY_CONNECTED:
    handleSuccess(ssid,lr,isFirst);
  break;
case Constants.WISPR_RESPONSE_CODE_RADIUS_ERROR:
case Constants.WISPR_RESPONSE_CODE_NETWORK_ADMIN_ERROR:
case Constants.FON_SESSION_LIMIT_EXCEEDED:
case Constants.FON_SPOT_LIMIT_EXCEEDED:
case Constants.FON_UNKNOWN_ERROR:
case Constants.CUST_WISPR_NOT_PRESENT:
handleError(wm,lr);
break;
case Constants.FON_INVALID_CREDENTIALS_ALT:
case Constants.FON_NOT_ENOUGH_CREDIT:
case Constants.FON_INVALID_CREDENTIALS:
case Constants.FON_USER_IN_BLACK_LIST:
case Constants.FON_NOT_AUTHORIZED:
case Constants.FON_CUSTOMIZED_ERROR:
case Constants.FON_INTERNAL_ERROR:
case Constants.FON_INVALID_TEMPORARY_CREDENTIAL:
case Constants.FON_AUTHORIZATION_CONNECTION_ERROR:
notifyFonError(lr);
break;
case Constants.WISPR_RESPONSE_CODE_ACCESS_GATEWAY_INTERNAL_ERROR:
wm.removeNetwork(wm.getConnectionInfo().getNetworkId());
break;
case Constants.CUST_CREDENTIALS_ERROR:
notifyCredentialsError();
break;
default :
break;
}
}
Program: 149507
Project: 149507
Buggy source:
/** 
 * Updates the weighted normaliser for the Gaussian.
 * @param sigmaX The Gaussian standard deviation in X
 * @param sigmaY The Gaussian standard deviation in Y
 */
private void updateWeightedNormaliser(final double sigmaX,final double sigmaY){
  if (normaliser == null || sx != sigmaX || sy != sigmaY) {
    float[] normalisation=weights.clone();
    sx=sigmaX;
    sy=sigmaY;
    DPGaussianFilter gf=new DPGaussianFilter(accuracy);
    gf.convolve(normalisation,weightHeight,weightWidth,sigmaX,sigmaY);
    normaliser=new PerPixelNormaliser(normalisation);
  }
}

Fixed version (ground truth):
/** 
 * Updates the weighted normaliser for the Gaussian.
 * @param sigmaX The Gaussian standard deviation in X
 * @param sigmaY The Gaussian standard deviation in Y
 */
private void updateWeightedNormaliser(final double sigmaX,final double sigmaY){
  if (normaliser == null || sx != sigmaX || sy != sigmaY) {
    float[] normalisation=weights.clone();
    sx=sigmaX;
    sy=sigmaY;
    DPGaussianFilter gf=new DPGaussianFilter(accuracy);
    gf.convolve(normalisation,weightWidth,weightHeight,sigmaX,sigmaY);
    normaliser=new PerPixelNormaliser(normalisation);
  }
}
Program: 149508
Project: 149508
Buggy source:
/** 
 * Updates the weighted normaliser for the Gaussian.
 * @param sigmaX The Gaussian standard deviation in X
 * @param sigmaY The Gaussian standard deviation in Y
 */
private void updateWeightedNormaliser(final double sigmaX,final double sigmaY){
  if (normaliser == null || sx != sigmaX || sy != sigmaY) {
    float[] normalisation=weights.clone();
    sx=sigmaX;
    sy=sigmaY;
    DoubleGaussianFilter gf=new DoubleGaussianFilter(accuracy);
    gf.convolve(normalisation,weightHeight,weightWidth,sigmaX,sigmaY);
    normaliser=new PerPixelNormaliser(normalisation);
  }
}

Fixed version (ground truth):
/** 
 * Updates the weighted normaliser for the Gaussian.
 * @param sigmaX The Gaussian standard deviation in X
 * @param sigmaY The Gaussian standard deviation in Y
 */
private void updateWeightedNormaliser(final double sigmaX,final double sigmaY){
  if (normaliser == null || sx != sigmaX || sy != sigmaY) {
    float[] normalisation=weights.clone();
    sx=sigmaX;
    sy=sigmaY;
    DoubleGaussianFilter gf=new DoubleGaussianFilter(accuracy);
    gf.convolve(normalisation,weightWidth,weightHeight,sigmaX,sigmaY);
    normaliser=new PerPixelNormaliser(normalisation);
  }
}
Program: 149510
Project: 149510
Buggy source:
/** 
 * Create a kernel for upscaling. The kernel function is a convolution of four unit squares, i.e., four uniform kernels with value +1 from -0.5 to +0.5 (in downscaled coordinates). The second derivative of this kernel is smooth, the third is not. Its standard deviation is 1/sqrt(3) in downscaled cordinates. The kernel runs from [-2 to +2[, corresponding to array index 0 ... 4*unitLength (whereby the last point is not in the array any more).
 */
final static private float[] makeUpscaleKernel(final int unitLength){
  final float[] kernel=new float[4 * unitLength];
  final int mid=2 * unitLength;
  kernel[0]=0;
  for (int i=0; i < unitLength; i++) {
    final double x=i / (double)unitLength;
    final float v=(float)((2. / 3. - x * x * (1 - 0.5 * x)));
    kernel[mid + i]=v;
    kernel[mid - i]=v;
  }
  for (int i=unitLength; i < 2 * unitLength; i++) {
    final double x=i / (double)unitLength;
    final float v=(float)((2. - x) * (2. - x) * (2. - x) / 6.);
    kernel[mid + i]=v;
    kernel[mid - i]=v;
  }
  return kernel;
}

Fixed version (ground truth):
/** 
 * Create a kernel for upscaling. The kernel function is a convolution of four unit squares, i.e., four uniform kernels with value +1 from -0.5 to +0.5 (in downscaled coordinates). The second derivative of this kernel is smooth, the third is not. Its standard deviation is 1/sqrt(3) in downscaled coordinates. The kernel runs from [-2 to +2[, corresponding to array index 0 ... 4*unitLength (whereby the last point is not in the array any more).
 */
final static private float[] makeUpscaleKernel(final int unitLength){
  final float[] kernel=new float[4 * unitLength];
  final int mid=2 * unitLength;
  kernel[0]=0;
  for (int i=0; i < unitLength; i++) {
    final double x=i / (double)unitLength;
    final float v=(float)((2. / 3. - x * x * (1 - 0.5 * x)));
    kernel[mid + i]=v;
    kernel[mid - i]=v;
  }
  for (int i=unitLength; i < 2 * unitLength; i++) {
    final double x=i / (double)unitLength;
    final float v=(float)((2. - x) * (2. - x) * (2. - x) / 6.);
    kernel[mid + i]=v;
    kernel[mid - i]=v;
  }
  return kernel;
}
Program: 149511
Project: 149511
Buggy source:
/** 
 * Updates the weighted normaliser for the Gaussian.
 * @param sigmaX The Gaussian standard deviation in X
 * @param sigmaY The Gaussian standard deviation in Y
 */
private void updateWeightedNormaliser(final double sigmaX,final double sigmaY){
  if (normaliser == null || sx != sigmaX || sy != sigmaY) {
    float[] normalisation=weights.clone();
    sx=sigmaX;
    sy=sigmaY;
    GaussianFilter gf=new GaussianFilter(accuracy);
    gf.convolve(normalisation,weightHeight,weightWidth,sigmaX,sigmaY);
    normaliser=new PerPixelNormaliser(normalisation);
  }
}

Fixed version (ground truth):
/** 
 * Updates the weighted normaliser for the Gaussian.
 * @param sigmaX The Gaussian standard deviation in X
 * @param sigmaY The Gaussian standard deviation in Y
 */
private void updateWeightedNormaliser(final double sigmaX,final double sigmaY){
  if (normaliser == null || sx != sigmaX || sy != sigmaY) {
    float[] normalisation=weights.clone();
    sx=sigmaX;
    sy=sigmaY;
    GaussianFilter gf=new GaussianFilter(accuracy);
    gf.convolve(normalisation,weightWidth,weightHeight,sigmaX,sigmaY);
    normaliser=new PerPixelNormaliser(normalisation);
  }
}
Program: 149512
Project: 149512
Buggy source:
/** 
 * Instantiates a new kernel filter.
 * @param kernel the kernel
 * @param kw the kernel width (must be odd)
 * @param kh the kernel height (must be odd)
 */
public KernelFilter(float[] kernel,int kw,int kh){
  if (kw < 1 || kh < 1)   throw new IllegalArgumentException("String_Node_Str");
  if (kw * kh != kernel.length)   throw new IllegalArgumentException("String_Node_Str");
  if ((kw & 1) != 1 || (kh & 1) != 1)   throw new IllegalArgumentException("String_Node_Str" + kw + "String_Node_Str"+ kh+ "String_Node_Str");
  this.kernel=kernel.clone();
  this.kw=kw;
  this.kh=kh;
  this.scale=getScale(kernel);
}

Fixed version (ground truth):
/** 
 * Instantiates a new kernel filter with no normaliser.
 * @param kernel the kernel
 * @param kw the kernel width (must be odd)
 * @param kh the kernel height (must be odd)
 * @param scale the scale
 */
private KernelFilter(float[] kernel,int kw,int kh,double scale){
  this.kernel=kernel.clone();
  this.kw=kw;
  this.kh=kh;
  this.scale=scale;
}
Program: 149513
Project: 149513
Buggy source:
/** 
 * Updates the weighted normaliser for the convolution
 */
private void updateWeightedNormaliser(){
  if (normaliser == null) {
    float[] normalisation=weights.clone();
    KernelFilter kf=new KernelFilter(kernel,kw,kh);
    kf.convolve(normalisation,weightHeight,weightWidth);
    normaliser=new PerPixelNormaliser(normalisation);
  }
}

Fixed version (ground truth):
/** 
 * Updates the weighted normaliser for the convolution
 */
private void updateWeightedNormaliser(){
  if (normaliser == null) {
    float[] normalisation=weights.clone();
    KernelFilter kf=new KernelFilter(kernel,kw,kh,scale);
    kf.convolve(normalisation,weightWidth,weightHeight);
    normaliser=new PerPixelNormaliser(normalisation);
  }
}
Program: 149514
Project: 149514
Buggy source:
private void cannotSubtractConstantBackgroundAndComputeLogLikelihoodRatio(BaseNonLinearFunction nlf1,BaseNonLinearFunction nlf2,BaseNonLinearFunction nlf3){
  int n=maxx * maxx;
  double[] a=new double[]{1};
  nlf1.initialise(a);
  nlf2.initialise(a);
  nlf3.initialise(a);
  RandomDataGenerator rdg=new RandomDataGenerator(TestSettings.getRandomGenerator());
  double[] x=SimpleArrayUtils.newArray(n,0,1.0);
  double[] u=new double[x.length];
  double[] b1=new double[x.length];
  double[] b2=new double[x.length];
  double[] b3=new double[x.length];
  for (int i=0; i < n; i++) {
    b1[i]=nlf1.eval(i);
    b2[i]=nlf2.eval(i);
    b3[i]=nlf3.eval(i);
    u[i]=b1[i] + b2[i] + b3[i];
    if (u[i] > 0)     x[i]=rdg.nextPoisson(u[i]);
  }
  double[] b12=add(b1,b2);
  double ll1a=PoissonCalculator.logLikelihood(b12,x);
  double ll2a=PoissonCalculator.logLikelihood(add(b12,b3),x);
  double llra=-2 * (ll1a - ll2a);
  x=subtract(x,b1);
  double ll1b=PoissonCalculator.logLikelihood(b2,x);
  double ll2b=PoissonCalculator.logLikelihood(add(b2,b3),x);
  double llrb=-2 * (ll1b - ll2b);
  Assert.assertNotEquals("String_Node_Str",llra,llrb,llra * 1e-10);
}

Fixed version (ground truth):
private void cannotSubtractConstantBackgroundAndComputeLogLikelihoodRatio(BaseNonLinearFunction nlf1,BaseNonLinearFunction nlf2,BaseNonLinearFunction nlf3){
  int n=maxx * maxx;
  double[] a=new double[]{1};
  nlf1.initialise(a);
  nlf2.initialise(a);
  nlf3.initialise(a);
  RandomDataGenerator rdg=new RandomDataGenerator(TestSettings.getRandomGenerator());
  double[] x=SimpleArrayUtils.newArray(n,0,1.0);
  double[] u=new double[x.length];
  double[] b1=new double[x.length];
  double[] b2=new double[x.length];
  double[] b3=new double[x.length];
  for (int i=0; i < n; i++) {
    b1[i]=nlf1.eval(i);
    b2[i]=nlf2.eval(i);
    b3[i]=nlf3.eval(i);
    u[i]=b1[i] + b2[i] + b3[i];
    if (u[i] > 0)     x[i]=rdg.nextPoisson(u[i]);
  }
  double[] b12=add(b1,b2);
  double ll1a=PoissonCalculator.logLikelihood(b12,x);
  double ll2a=PoissonCalculator.logLikelihood(add(b12,b3),x);
  double llra=-2 * (ll1a - ll2a);
  x=subtract(x,b1);
  double ll1b=PoissonCalculator.logLikelihood(b2,x);
  double ll2b=PoissonCalculator.logLikelihood(add(b2,b3),x);
  double llrb=-2 * (ll1b - ll2b);
  TestAssert.assertNotEqualsRelative("String_Node_Str",llra,llrb,1e-10);
}
Program: 149515
Project: 149515
Buggy source:
@Test public void canComputeLikelihoodForIntegerData(){
  for (  double u : photons) {
    PoissonDistribution pd=new PoissonDistribution(u);
    for (int x=0; x < 100; x++) {
      double e=pd.probability(x);
      double o=PoissonCalculator.likelihood(u,x);
      if (e > 1e-100)       Assert.assertEquals(e,o,e * 1e-10);
      e=pd.logProbability(x);
      o=PoissonCalculator.logLikelihood(u,x);
      Assert.assertEquals(e,o,Math.abs(e) * 1e-10);
    }
  }
}

Fixed version (ground truth):
@Test public void canComputeLikelihoodForIntegerData(){
  for (  double u : photons) {
    PoissonDistribution pd=new PoissonDistribution(u);
    for (int x=0; x < 100; x++) {
      double e=pd.probability(x);
      double o=PoissonCalculator.likelihood(u,x);
      if (e > 1e-100)       TestAssert.assertEqualsRelative(e,o,1e-10);
      e=pd.logProbability(x);
      o=PoissonCalculator.logLikelihood(u,x);
      TestAssert.assertEqualsRelative(e,o,1e-10);
    }
  }
}
Program: 149516
Project: 149516
Buggy source:
@Test public void canComputeFastLog_FastLikelihoodForIntegerData(){
  FastLog fastLog=FastLogFactory.getFastLog();
  for (  double u : photons) {
    PoissonDistribution pd=new PoissonDistribution(u);
    for (int x=0; x < 100; x++) {
      double e=pd.probability(x);
      double o=PoissonCalculator.fastLikelihood(u,x,fastLog);
      if (e > 1e-100)       Assert.assertEquals(e,o,e * 1e-4);
      e=pd.logProbability(x);
      o=PoissonCalculator.fastLogLikelihood(u,x,fastLog);
      Assert.assertEquals(e,o,Math.abs(e) * 1e-4);
    }
  }
}

Fixed version (ground truth):
@Test public void canComputeFastLog_FastLikelihoodForIntegerData(){
  FastLog fastLog=FastLogFactory.getFastLog();
  for (  double u : photons) {
    PoissonDistribution pd=new PoissonDistribution(u);
    for (int x=0; x < 100; x++) {
      double e=pd.probability(x);
      double o=PoissonCalculator.fastLikelihood(u,x,fastLog);
      if (e > 1e-100)       TestAssert.assertEqualsRelative(e,o,1e-4);
      e=pd.logProbability(x);
      o=PoissonCalculator.fastLogLikelihood(u,x,fastLog);
      TestAssert.assertEqualsRelative(e,o,1e-4);
    }
  }
}
Program: 149518
Project: 149518
Buggy source:
@Test public void canComputeFastLikelihoodForIntegerData(){
  for (  double u : photons) {
    PoissonDistribution pd=new PoissonDistribution(u);
    for (int x=0; x < 100; x++) {
      double e=pd.probability(x);
      double o=PoissonCalculator.fastLikelihood(u,x);
      if (e > 1e-100)       Assert.assertEquals(e,o,e * 1e-4);
      e=pd.logProbability(x);
      o=PoissonCalculator.fastLogLikelihood(u,x);
      Assert.assertEquals(e,o,Math.abs(e) * 1e-4);
    }
  }
}

Fixed version (ground truth):
@Test public void canComputeFastLikelihoodForIntegerData(){
  for (  double u : photons) {
    PoissonDistribution pd=new PoissonDistribution(u);
    for (int x=0; x < 100; x++) {
      double e=pd.probability(x);
      double o=PoissonCalculator.fastLikelihood(u,x);
      if (e > 1e-100)       TestAssert.assertEqualsRelative(e,o,1e-4);
      e=pd.logProbability(x);
      o=PoissonCalculator.fastLogLikelihood(u,x);
      TestAssert.assertEqualsRelative(e,o,1e-4);
    }
  }
}
Program: 149519
Project: 149519
Buggy source:
private void canComputeFastLog_LogLikelihoodRatio(BaseNonLinearFunction nlf){
  TestSettings.infoln(nlf.name);
  int n=maxx * maxx;
  double[] a=new double[]{1};
  nlf.initialise(a);
  RandomDataGenerator rdg=new RandomDataGenerator(TestSettings.getRandomGenerator());
  double[] x=new double[n];
  double[] u=new double[n];
  for (int i=0; i < n; i++) {
    u[i]=nlf.eval(i);
    if (u[i] > 0)     x[i]=rdg.nextPoisson(u[i]);
  }
  double llr=PoissonCalculator.logLikelihoodRatio(u,x);
  double llr2=PoissonCalculator.logLikelihoodRatio(u,x,FastLogFactory.getFastLog());
  TestSettings.info("String_Node_Str",llr,llr2);
  Assert.assertEquals("String_Node_Str",llr,llr2,llr * 1e-3);
}

Fixed version (ground truth):
private void canComputeFastLog_LogLikelihoodRatio(BaseNonLinearFunction nlf){
  TestSettings.infoln(nlf.name);
  int n=maxx * maxx;
  double[] a=new double[]{1};
  nlf.initialise(a);
  RandomDataGenerator rdg=new RandomDataGenerator(TestSettings.getRandomGenerator());
  double[] x=new double[n];
  double[] u=new double[n];
  for (int i=0; i < n; i++) {
    u[i]=nlf.eval(i);
    if (u[i] > 0)     x[i]=rdg.nextPoisson(u[i]);
  }
  double llr=PoissonCalculator.logLikelihoodRatio(u,x);
  double llr2=PoissonCalculator.logLikelihoodRatio(u,x,FastLogFactory.getFastLog());
  TestSettings.info("String_Node_Str",llr,llr2);
  TestAssert.assertEqualsRelative("String_Node_Str",llr,llr2,5e-3);
}