Program: 31608
Project: 31608
Buggy source:
private void doReBin(ColumnConfig columnConfig) throws IOException {
  int expectBinNum=getIntParam(this.params,EXPECTED_BIN_NUM);
  double ivKeepRatio=getDoubleParam(this.params,IV_KEEP_RATIO,1.0d);
  long minimumInstCnt=getLongParam(this.params,MINIMUM_BIN_INST_CNT);
  ColumnConfigDynamicBinning columnConfigDynamicBinning=new ColumnConfigDynamicBinning(columnConfig,expectBinNum,ivKeepRatio,minimumInstCnt);
  List<AbstractBinInfo> binInfos=columnConfigDynamicBinning.run();
  long[] binCountNeg=new long[binInfos.size() + 1];
  long[] binCountPos=new long[binInfos.size() + 1];
  for (int i=0; i < binInfos.size(); i++) {
    AbstractBinInfo binInfo=binInfos.get(i);
    binCountNeg[i]=binInfo.getNegativeCnt();
    binCountPos[i]=binInfo.getPositiveCnt();
  }
  binCountNeg[binCountNeg.length - 1]=columnConfig.getBinCountNeg().get(columnConfig.getBinCountNeg().size() - 1);
  binCountPos[binCountPos.length - 1]=columnConfig.getBinCountPos().get(columnConfig.getBinCountPos().size() - 1);
  double[] binWeightNeg=new double[binInfos.size() + 1];
  double[] binWeightPos=new double[binInfos.size() + 1];
  for (int i=0; i < binInfos.size(); i++) {
    AbstractBinInfo binInfo=binInfos.get(i);
    binWeightNeg[i]=binInfo.getWeightNeg();
    binWeightPos[i]=binInfo.getWeightPos();
  }
  binWeightNeg[binWeightNeg.length - 1]=columnConfig.getBinWeightedNeg().get(columnConfig.getBinWeightedNeg().size() - 1);
  binWeightPos[binWeightPos.length - 1]=columnConfig.getBinWeightedPos().get(columnConfig.getBinWeightedPos().size() - 1);
  ColumnStatsCalculator.ColumnMetrics columnCountMetrics=ColumnStatsCalculator.calculateColumnMetrics(binCountNeg,binCountPos);
  ColumnStatsCalculator.ColumnMetrics columnWeightMetrics=ColumnStatsCalculator.calculateColumnMetrics(binWeightNeg,binWeightPos);
  columnConfig.setBinLength(binInfos.size() + 1);
  if (columnConfig.isCategorical()) {
    List<String> values=new ArrayList<String>();
    for (    AbstractBinInfo binInfo : binInfos) {
      CategoricalBinInfo categoricalBinInfo=(CategoricalBinInfo)binInfo;
      values.add(StringUtils.join(categoricalBinInfo.getValues(),Constants.CATEGORICAL_GROUP_VAL_DELIMITER));
    }
    columnConfig.setBinCategory(values);
  }
 else {
    List<Double> values=new ArrayList<Double>();
    for (    AbstractBinInfo binInfo : binInfos) {
      NumericalBinInfo numericalBinInfo=(NumericalBinInfo)binInfo;
      values.add(numericalBinInfo.getLeftThreshold());
    }
    columnConfig.setBinBoundary(values);
  }
  columnConfig.setBinCountNeg(convertToIntList(binCountNeg));
  columnConfig.setBinCountPos(convertToIntList(binCountPos));
  List<Double> binPosRates=new ArrayList<Double>();
  for (  AbstractBinInfo binInfo : binInfos) {
    binPosRates.add(binInfo.getPositiveRate());
  }
  if (binPosRates.size() + 1 == binCountPos.length) {
    long missingSumCnt=binCountPos[binCountPos.length - 1] + binCountNeg[binCountNeg.length - 1];
    if (missingSumCnt > 0) {
      binPosRates.add(binCountPos[binCountPos.length - 1] * 1d / missingSumCnt);
    }
 else {
      binPosRates.add(Double.NaN);
    }
  }
  columnConfig.setBinPosCaseRate(binPosRates);
  columnConfig.setBinWeightedNeg(convertIntoDoubleList(binWeightNeg));
  columnConfig.setBinWeightedPos(convertIntoDoubleList(binWeightPos));
  columnConfig.setIv(columnCountMetrics.getIv());
  columnConfig.setKs(columnCountMetrics.getKs());
  columnConfig.getColumnStats().setWoe(columnCountMetrics.getWoe());
  columnConfig.getColumnBinning().setBinCountWoe(columnCountMetrics.getBinningWoe());
  columnConfig.getColumnStats().setWeightedIv(columnWeightMetrics.getIv());
  columnConfig.getColumnStats().setWeightedKs(columnWeightMetrics.getWoe());
  columnConfig.getColumnStats().setWeightedWoe(columnWeightMetrics.getWoe());
  columnConfig.getColumnBinning().setBinWeightedWoe(columnWeightMetrics.getBinningWoe());
}

Fixed version (ground truth):
private void doReBin(ColumnConfig columnConfig) throws IOException {
  int expectBinNum=getIntParam(this.params,Constants.EXPECTED_BIN_NUM);
  double ivKeepRatio=getDoubleParam(this.params,Constants.IV_KEEP_RATIO,1.0d);
  long minimumInstCnt=getLongParam(this.params,Constants.MINIMUM_BIN_INST_CNT);
  ColumnConfigDynamicBinning columnConfigDynamicBinning=new ColumnConfigDynamicBinning(columnConfig,expectBinNum,ivKeepRatio,minimumInstCnt);
  List<AbstractBinInfo> binInfos=columnConfigDynamicBinning.run();
  long[] binCountNeg=new long[binInfos.size() + 1];
  long[] binCountPos=new long[binInfos.size() + 1];
  for (int i=0; i < binInfos.size(); i++) {
    AbstractBinInfo binInfo=binInfos.get(i);
    binCountNeg[i]=binInfo.getNegativeCnt();
    binCountPos[i]=binInfo.getPositiveCnt();
  }
  binCountNeg[binCountNeg.length - 1]=columnConfig.getBinCountNeg().get(columnConfig.getBinCountNeg().size() - 1);
  binCountPos[binCountPos.length - 1]=columnConfig.getBinCountPos().get(columnConfig.getBinCountPos().size() - 1);
  double[] binWeightNeg=new double[binInfos.size() + 1];
  double[] binWeightPos=new double[binInfos.size() + 1];
  for (int i=0; i < binInfos.size(); i++) {
    AbstractBinInfo binInfo=binInfos.get(i);
    binWeightNeg[i]=binInfo.getWeightNeg();
    binWeightPos[i]=binInfo.getWeightPos();
  }
  binWeightNeg[binWeightNeg.length - 1]=columnConfig.getBinWeightedNeg().get(columnConfig.getBinWeightedNeg().size() - 1);
  binWeightPos[binWeightPos.length - 1]=columnConfig.getBinWeightedPos().get(columnConfig.getBinWeightedPos().size() - 1);
  ColumnStatsCalculator.ColumnMetrics columnCountMetrics=ColumnStatsCalculator.calculateColumnMetrics(binCountNeg,binCountPos);
  ColumnStatsCalculator.ColumnMetrics columnWeightMetrics=ColumnStatsCalculator.calculateColumnMetrics(binWeightNeg,binWeightPos);
  columnConfig.setBinLength(binInfos.size() + 1);
  if (columnConfig.isCategorical()) {
    List<String> values=new ArrayList<String>();
    for (    AbstractBinInfo binInfo : binInfos) {
      CategoricalBinInfo categoricalBinInfo=(CategoricalBinInfo)binInfo;
      values.add(StringUtils.join(categoricalBinInfo.getValues(),Constants.CATEGORICAL_GROUP_VAL_DELIMITER));
    }
    columnConfig.setBinCategory(values);
  }
 else {
    List<Double> values=new ArrayList<Double>();
    for (    AbstractBinInfo binInfo : binInfos) {
      NumericalBinInfo numericalBinInfo=(NumericalBinInfo)binInfo;
      values.add(numericalBinInfo.getLeftThreshold());
    }
    columnConfig.setBinBoundary(values);
  }
  columnConfig.setBinCountNeg(convertToIntList(binCountNeg));
  columnConfig.setBinCountPos(convertToIntList(binCountPos));
  List<Double> binPosRates=new ArrayList<Double>();
  for (  AbstractBinInfo binInfo : binInfos) {
    binPosRates.add(binInfo.getPositiveRate());
  }
  if (binPosRates.size() + 1 == binCountPos.length) {
    long missingSumCnt=binCountPos[binCountPos.length - 1] + binCountNeg[binCountNeg.length - 1];
    if (missingSumCnt > 0) {
      binPosRates.add(binCountPos[binCountPos.length - 1] * 1d / missingSumCnt);
    }
 else {
      binPosRates.add(Double.NaN);
    }
  }
  columnConfig.setBinPosCaseRate(binPosRates);
  columnConfig.setBinWeightedNeg(convertIntoDoubleList(binWeightNeg));
  columnConfig.setBinWeightedPos(convertIntoDoubleList(binWeightPos));
  columnConfig.setIv(columnCountMetrics.getIv());
  columnConfig.setKs(columnCountMetrics.getKs());
  columnConfig.getColumnStats().setWoe(columnCountMetrics.getWoe());
  columnConfig.getColumnBinning().setBinCountWoe(columnCountMetrics.getBinningWoe());
  columnConfig.getColumnStats().setWeightedIv(columnWeightMetrics.getIv());
  columnConfig.getColumnStats().setWeightedKs(columnWeightMetrics.getWoe());
  columnConfig.getColumnStats().setWeightedWoe(columnWeightMetrics.getWoe());
  columnConfig.getColumnBinning().setBinWeightedWoe(columnWeightMetrics.getBinningWoe());
}