Program: 26263
Project: 26263
Buggy source:
/** 
 * Sets up the axis values. Computes the desired number of labels between the two given extremes.
 * @return
 */
protected void computeAxisValues(float min,float max){
  float yMin=min;
  float yMax=max;
  int labelCount=mAxis.getLabelCount();
  double range=Math.abs(yMax - yMin);
  if (labelCount == 0 || range <= 0) {
    mAxis.mEntries=new float[]{};
    mAxis.mEntryCount=0;
    return;
  }
  double rawInterval=range / labelCount;
  if (Double.isInfinite(rawInterval)) {
    rawInterval=range > 0.0 && !Double.isInfinite(range) ? range : 1.0;
  }
  double interval=Utils.roundToNextSignificant(rawInterval);
  if (mAxis.isGranularityEnabled())   interval=interval < mAxis.getGranularity() ? mAxis.getGranularity() : interval;
  double intervalMagnitude=Utils.roundToNextSignificant(Math.pow(10,(int)Math.log10(interval)));
  int intervalSigDigit=(int)(interval / intervalMagnitude);
  if (intervalSigDigit > 5) {
    interval=Math.floor(10 * intervalMagnitude);
  }
  boolean centeringEnabled=mAxis.isCenterAxisLabelsEnabled();
  int n=centeringEnabled ? 1 : 0;
  if (mAxis.isForceLabelsEnabled()) {
    float step=(float)range / (float)(labelCount - 1);
    mAxis.mEntryCount=labelCount;
    if (mAxis.mEntries.length < labelCount) {
      mAxis.mEntries=new float[labelCount];
    }
    float v=min;
    for (int i=0; i < labelCount; i++) {
      mAxis.mEntries[i]=v;
      v+=step;
    }
    n=labelCount;
  }
 else {
    double first=interval == 0.0 ? 0.0 : Math.ceil(yMin / interval) * interval;
    if (centeringEnabled) {
      first-=interval;
    }
    double last=interval == 0.0 ? 0.0 : Utils.nextUp(Math.floor(yMax / interval) * interval);
    double f;
    int i;
    if (interval != 0.0) {
      for (f=first; f <= last; f+=interval) {
        ++n;
      }
    }
    mAxis.mEntryCount=n;
    if (mAxis.mEntries.length < n) {
      mAxis.mEntries=new float[n];
    }
    for (f=first, i=0; i < n; f+=interval, ++i) {
      if (f == 0.0)       f=0.0;
      mAxis.mEntries[i]=(float)f;
    }
  }
  if (interval < 1) {
    mAxis.mDecimals=(int)Math.ceil(-Math.log10(interval));
  }
 else {
    mAxis.mDecimals=0;
  }
  if (centeringEnabled) {
    if (mAxis.mCenteredEntries.length < n) {
      mAxis.mCenteredEntries=new float[n];
    }
    float offset=(mAxis.mEntries[1] - mAxis.mEntries[0]) / 2f;
    for (int i=0; i < n; i++) {
      mAxis.mCenteredEntries[i]=mAxis.mEntries[i] + offset;
    }
  }
}

Fixed version (ground truth):
/** 
 * Sets up the axis values. Computes the desired number of labels between the two given extremes.
 * @return
 */
protected void computeAxisValues(float min,float max){
  float yMin=min;
  float yMax=max;
  int labelCount=mAxis.getLabelCount();
  double range=Math.abs(yMax - yMin);
  if (labelCount == 0 || range <= 0 || Double.isInfinite(range)) {
    mAxis.mEntries=new float[]{};
    mAxis.mCenteredEntries=new float[]{};
    mAxis.mEntryCount=0;
    return;
  }
  double rawInterval=range / labelCount;
  double interval=Utils.roundToNextSignificant(rawInterval);
  if (mAxis.isGranularityEnabled())   interval=interval < mAxis.getGranularity() ? mAxis.getGranularity() : interval;
  double intervalMagnitude=Utils.roundToNextSignificant(Math.pow(10,(int)Math.log10(interval)));
  int intervalSigDigit=(int)(interval / intervalMagnitude);
  if (intervalSigDigit > 5) {
    interval=Math.floor(10 * intervalMagnitude);
  }
  boolean centeringEnabled=mAxis.isCenterAxisLabelsEnabled();
  int n=centeringEnabled ? 1 : 0;
  if (mAxis.isForceLabelsEnabled()) {
    float step=(float)range / (float)(labelCount - 1);
    mAxis.mEntryCount=labelCount;
    if (mAxis.mEntries.length < labelCount) {
      mAxis.mEntries=new float[labelCount];
    }
    float v=min;
    for (int i=0; i < labelCount; i++) {
      mAxis.mEntries[i]=v;
      v+=step;
    }
    n=labelCount;
  }
 else {
    double first=interval == 0.0 ? 0.0 : Math.ceil(yMin / interval) * interval;
    if (centeringEnabled) {
      first-=interval;
    }
    double last=interval == 0.0 ? 0.0 : Utils.nextUp(Math.floor(yMax / interval) * interval);
    double f;
    int i;
    if (interval != 0.0) {
      for (f=first; f <= last; f+=interval) {
        ++n;
      }
    }
    mAxis.mEntryCount=n;
    if (mAxis.mEntries.length < n) {
      mAxis.mEntries=new float[n];
    }
    for (f=first, i=0; i < n; f+=interval, ++i) {
      if (f == 0.0)       f=0.0;
      mAxis.mEntries[i]=(float)f;
    }
  }
  if (interval < 1) {
    mAxis.mDecimals=(int)Math.ceil(-Math.log10(interval));
  }
 else {
    mAxis.mDecimals=0;
  }
  if (centeringEnabled) {
    if (mAxis.mCenteredEntries.length < n) {
      mAxis.mCenteredEntries=new float[n];
    }
    float offset=(mAxis.mEntries[1] - mAxis.mEntries[0]) / 2f;
    for (int i=0; i < n; i++) {
      mAxis.mCenteredEntries[i]=mAxis.mEntries[i] + offset;
    }
  }
}