nus-yam/ex-repair huggingface dataset:
Program: 150710
Project: 150710
Buggy source:
@Test public void all(){
  int numRows=3, numCols=4;
  double space=3, r=1;
  Grid g=createGrid(numRows,numCols,space,r);
  KeyPointsCircleRegularGrid alg=new KeyPointsCircleRegularGrid();
  alg.process(g);
  int index=0;
  for (int row=0; row < numRows; row++) {
    for (int col=0; col < numCols; col++) {
      double cx=col * space;
      double cy=row * space;
      Point2D_F64 a=alg.getKeyPoints().get(index++);
      Point2D_F64 b=alg.getKeyPoints().get(index++);
      Point2D_F64 c=alg.getKeyPoints().get(index++);
      Point2D_F64 d=alg.getKeyPoints().get(index++);
      assertTrue(a.distance(cx,cy + r) <= BoofDefaults.TEST_DOUBLE_TOL);
      assertTrue(b.distance(cx + r,cy) <= BoofDefaults.TEST_DOUBLE_TOL);
      assertTrue(c.distance(cx,cy - r) <= BoofDefaults.TEST_DOUBLE_TOL);
      assertTrue(d.distance(cx - r,cy) <= BoofDefaults.TEST_DOUBLE_TOL);
    }
  }
}

Fixed version (ground truth):
public void all(Affine2D_F64 affine){
  int numRows=3, numCols=4;
  double space=3, r=1;
  Grid g=createGrid(numRows,numCols,space,r);
  transform(affine,g);
  KeyPointsCircleRegularGrid alg=new KeyPointsCircleRegularGrid();
  alg.process(g);
  Point2D_F64 p=new Point2D_F64();
  int index=0;
  for (int row=0; row < numRows; row++) {
    for (int col=0; col < numCols; col++) {
      double cx=col * space;
      double cy=row * space;
      Point2D_F64 a=alg.getKeyPoints().get(index++);
      Point2D_F64 b=alg.getKeyPoints().get(index++);
      Point2D_F64 c=alg.getKeyPoints().get(index++);
      Point2D_F64 d=alg.getKeyPoints().get(index++);
      AffinePointOps_F64.transform(affine,cx,cy + r,p);
      assertTrue(a.distance(p.x,p.y) <= BoofDefaults.TEST_DOUBLE_TOL);
      AffinePointOps_F64.transform(affine,cx + r,cy,p);
      assertTrue(b.distance(p.x,p.y) <= BoofDefaults.TEST_DOUBLE_TOL);
      AffinePointOps_F64.transform(affine,cx,cy - r,p);
      assertTrue(c.distance(p.x,p.y) <= BoofDefaults.TEST_DOUBLE_TOL);
      AffinePointOps_F64.transform(affine,cx - r,cy,p);
      assertTrue(d.distance(p.x,p.y) <= BoofDefaults.TEST_DOUBLE_TOL);
    }
  }
}
Program: 150711
Project: 150711
Buggy source:
@Override public void processImage(int sourceID,long frameID,final BufferedImage buffered,ImageBase input){
  if (buffered != null) {
    original=ConvertBufferedImage.checkCopy(buffered,original);
    work=ConvertBufferedImage.checkDeclare(buffered.getWidth(),buffered.getHeight(),work,buffered.getType());
    SwingUtilities.invokeLater(new Runnable(){
      @Override public void run(){
        Dimension d=guiImage.getPreferredSize();
        if (d.getWidth() < buffered.getWidth() || d.getHeight() < buffered.getHeight()) {
          guiImage.setPreferredSize(new Dimension(buffered.getWidth(),buffered.getHeight()));
        }
      }
    }
);
  }
  binary.reshape(input.width,input.height);
  labeled.reshape(input.width,input.height);
  inputToBinary.process((T)input,binary);
synchronized (this) {
    contourAlg.process(binary,labeled);
  }
  SwingUtilities.invokeLater(new Runnable(){
    @Override public void run(){
      viewUpdated();
    }
  }
);
}

Fixed version (ground truth):
@Override public void processImage(int sourceID,long frameID,final BufferedImage buffered,ImageBase input){
  if (buffered != null) {
    original=ConvertBufferedImage.checkCopy(buffered,original);
    work=ConvertBufferedImage.checkDeclare(buffered,work);
    SwingUtilities.invokeLater(new Runnable(){
      @Override public void run(){
        Dimension d=guiImage.getPreferredSize();
        if (d.getWidth() < buffered.getWidth() || d.getHeight() < buffered.getHeight()) {
          guiImage.setPreferredSize(new Dimension(buffered.getWidth(),buffered.getHeight()));
        }
      }
    }
);
  }
  binary.reshape(input.width,input.height);
  labeled.reshape(input.width,input.height);
  inputToBinary.process((T)input,binary);
synchronized (this) {
    contourAlg.process(binary,labeled);
  }
  SwingUtilities.invokeLater(new Runnable(){
    @Override public void run(){
      viewUpdated();
    }
  }
);
}
Program: 150712
Project: 150712
Buggy source:
@Override public synchronized void processImage(int sourceID,long frameID,final BufferedImage buffered,ImageBase input){
  if (buffered != null) {
    original=ConvertBufferedImage.checkCopy(buffered,original);
    work=ConvertBufferedImage.checkCopy(buffered,work);
    this.original.createGraphics().drawImage(buffered,0,0,null);
    binary.reshape(work.getWidth(),work.getHeight());
    inputPrev.setTo((T)input);
    SwingUtilities.invokeLater(new Runnable(){
      @Override public void run(){
        Dimension d=guiImage.getPreferredSize();
        if (d.getWidth() < buffered.getWidth() || d.getHeight() < buffered.getHeight()) {
          guiImage.setPreferredSize(new Dimension(buffered.getWidth(),buffered.getHeight()));
        }
      }
    }
);
  }
 else {
    input=inputPrev;
  }
  inputToBinary.process((T)input,binary);
  detector.process((T)input,binary);
  SwingUtilities.invokeLater(new Runnable(){
    @Override public void run(){
      viewUpdated();
    }
  }
);
}

Fixed version (ground truth):
@Override public synchronized void processImage(int sourceID,long frameID,final BufferedImage buffered,ImageBase input){
  if (buffered != null) {
    original=ConvertBufferedImage.checkCopy(buffered,original);
    work=ConvertBufferedImage.checkDeclare(buffered,work);
    binary.reshape(work.getWidth(),work.getHeight());
    inputPrev.setTo((T)input);
    SwingUtilities.invokeLater(new Runnable(){
      @Override public void run(){
        Dimension d=guiImage.getPreferredSize();
        if (d.getWidth() < buffered.getWidth() || d.getHeight() < buffered.getHeight()) {
          guiImage.setPreferredSize(new Dimension(buffered.getWidth(),buffered.getHeight()));
        }
      }
    }
);
  }
 else {
    input=inputPrev;
  }
  inputToBinary.process((T)input,binary);
  detector.process((T)input,binary);
  SwingUtilities.invokeLater(new Runnable(){
    @Override public void run(){
      viewUpdated();
    }
  }
);
}
Program: 150713
Project: 150713
Buggy source:
@Override public synchronized void processImage(int sourceID,long frameID,final BufferedImage buffered,ImageBase input){
  if (buffered != null) {
    original=ConvertBufferedImage.checkCopy(buffered,original);
    work=ConvertBufferedImage.checkDeclare(buffered.getWidth(),buffered.getHeight(),work,buffered.getType());
    binary.reshape(work.getWidth(),work.getHeight());
    inputPrev.setTo((T)input);
    SwingUtilities.invokeLater(new Runnable(){
      @Override public void run(){
        Dimension d=guiImage.getPreferredSize();
        if (d.getWidth() < buffered.getWidth() || d.getHeight() < buffered.getHeight()) {
          guiImage.setPreferredSize(new Dimension(buffered.getWidth(),buffered.getHeight()));
        }
      }
    }
);
  }
 else {
    input=inputPrev;
  }
  inputToBinary.process((T)input,binary);
  detector.process((T)input,binary);
  SwingUtilities.invokeLater(new Runnable(){
    @Override public void run(){
      viewUpdated();
    }
  }
);
}

Fixed version (ground truth):
@Override public synchronized void processImage(int sourceID,long frameID,final BufferedImage buffered,ImageBase input){
  if (buffered != null) {
    original=ConvertBufferedImage.checkCopy(buffered,original);
    work=ConvertBufferedImage.checkDeclare(buffered,work);
    binary.reshape(work.getWidth(),work.getHeight());
    inputPrev.setTo((T)input);
    SwingUtilities.invokeLater(new Runnable(){
      @Override public void run(){
        Dimension d=guiImage.getPreferredSize();
        if (d.getWidth() < buffered.getWidth() || d.getHeight() < buffered.getHeight()) {
          guiImage.setPreferredSize(new Dimension(buffered.getWidth(),buffered.getHeight()));
        }
      }
    }
);
  }
 else {
    input=inputPrev;
  }
  inputToBinary.process((T)input,binary);
  detector.process((T)input,binary);
  SwingUtilities.invokeLater(new Runnable(){
    @Override public void run(){
      viewUpdated();
    }
  }
);
}
Program: 150714
Project: 150714
Buggy source:
@Override public synchronized void processImage(int sourceID,long frameID,final BufferedImage buffered,ImageBase input){
  if (buffered != null) {
    original=ConvertBufferedImage.checkCopy(buffered,original);
    work=ConvertBufferedImage.checkDeclare(buffered.getWidth(),buffered.getHeight(),work,buffered.getType());
    binary.reshape(input.getWidth(),input.getHeight());
    filtered.reshape(input.getWidth(),input.getHeight());
    inputPrev.setTo((GrayU8)input);
    SwingUtilities.invokeLater(new Runnable(){
      @Override public void run(){
        Dimension d=gui.getPreferredSize();
        if (d.getWidth() < buffered.getWidth() || d.getHeight() < buffered.getHeight()) {
          gui.setPreferredSize(new Dimension(buffered.getWidth(),buffered.getHeight()));
        }
      }
    }
);
  }
 else {
    input=inputPrev;
  }
  process((GrayU8)input);
}

Fixed version (ground truth):
@Override public synchronized void processImage(int sourceID,long frameID,final BufferedImage buffered,ImageBase input){
  if (buffered != null) {
    original=ConvertBufferedImage.checkCopy(buffered,original);
    work=ConvertBufferedImage.checkDeclare(buffered,work);
    binary.reshape(input.getWidth(),input.getHeight());
    filtered.reshape(input.getWidth(),input.getHeight());
    inputPrev.setTo((GrayU8)input);
    SwingUtilities.invokeLater(new Runnable(){
      @Override public void run(){
        Dimension d=gui.getPreferredSize();
        if (d.getWidth() < buffered.getWidth() || d.getHeight() < buffered.getHeight()) {
          gui.setPreferredSize(new Dimension(buffered.getWidth(),buffered.getHeight()));
        }
      }
    }
);
  }
 else {
    input=inputPrev;
  }
  process((GrayU8)input);
}
Program: 150715
Project: 150715
Buggy source:
/** 
 * If the provided image does not have the same shape and same type a new one is declared and returned.
 */
public static BufferedImage checkDeclare(int width,int height,BufferedImage image,int type){
  if (image == null)   return new BufferedImage(width,height,type);
  if (image.getType() != type)   return new BufferedImage(width,height,type);
  if (image.getWidth() != width || image.getHeight() != height)   return new BufferedImage(width,height,type);
  return image;
}

Fixed version (ground truth):
public static BufferedImage checkDeclare(BufferedImage template,BufferedImage target){
  int width=template.getWidth();
  int height=template.getHeight();
  int type=template.getType();
  if (type == 0) {
    if (target != null)     type=target.getType();
 else     type=BufferedImage.TYPE_INT_RGB;
  }
  if (target == null)   return new BufferedImage(width,height,type);
  if (target.getType() != type)   return new BufferedImage(width,height,type);
  if (target.getWidth() != width || target.getHeight() != height)   return new BufferedImage(width,height,type);
  return target;
}
Program: 150716
Project: 150716
Buggy source:
/** 
 * Specifies the input image size and the size of the grid it will use to approximate the idea solution. All control points are discarded
 * @param width Image width
 * @param height Image height
 * @param gridRows grid rows
 * @param gridCols grid columns
 */
public void configure(int width,int height,int gridRows,int gridCols){
  int s=Math.max(width,height);
  scaleX=s / (float)(gridCols - 1);
  scaleY=s / (float)(gridRows - 1);
  if (gridRows > gridCols) {
    scaleY/=gridCols / (float)gridRows;
  }
 else {
    scaleX/=gridRows / (float)gridCols;
  }
  this.gridRows=gridRows;
  this.gridCols=gridCols;
  grid.resize(gridCols * gridRows);
  reset();
}

Fixed version (ground truth):
/** 
 * Specifies the input image size and the size of the grid it will use to approximate the idea solution. All control points are discarded
 * @param width Image width
 * @param height Image height
 * @param gridRows grid rows
 * @param gridCols grid columns
 */
public void configure(int width,int height,int gridRows,int gridCols){
  int s=Math.max(width,height);
  scaleX=s / (float)(gridCols - 1);
  scaleY=s / (float)(gridRows - 1);
  if (gridRows > gridCols) {
    scaleY/=(gridCols - 1) / (float)(gridRows - 1);
  }
 else {
    scaleX/=(gridRows - 1) / (float)(gridCols - 1);
  }
  this.gridRows=gridRows;
  this.gridCols=gridCols;
  grid.resize(gridCols * gridRows);
  reset();
}
Program: 150717
Project: 150717
Buggy source:
/** 
 * Makes sure modifying a single points is the same as modifying all the points at once
 */
@Test public void individualSrcSameAsAll(){
  fail("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Makes sure modifying a single points is the same as modifying all the points at once
 */
@Test public void individualSrcSameAsAll(){
  List<Point2D_F32> src=createTestPoints();
  List<Point2D_F32> dst=createTestPoints();
  PointDeformKeyPoints alg=createAlgorithm();
  alg.setImageShape(80,100);
  alg.setSource(src);
  alg.setSource(dst);
  alg.setSource(1,20,25);
  Point2D_F32 expected=new Point2D_F32();
  alg.compute(12,19.5f,expected);
  src.get(1).set(20,25);
  Point2D_F32 found=new Point2D_F32();
  alg.compute(12,19.5f,found);
  assertEquals(expected.x,found.x,GrlConstants.FLOAT_TEST_TOL);
  assertEquals(expected.y,found.y,GrlConstants.FLOAT_TEST_TOL);
}
Program: 150718
Project: 150718
Buggy source:
/** 
 * Sees if a local copy of inputs points is not made
 */
@Test public void checkPointsCopied(){
  fail("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Sees if a local copy of inputs points is not made
 */
@Test public void checkPointsCopied(){
  List<Point2D_F32> src=createTestPoints();
  List<Point2D_F32> dst=createTestPoints();
  PointDeformKeyPoints alg=createAlgorithm();
  alg.setImageShape(80,100);
  alg.setSource(src);
  alg.setSource(dst);
  Point2D_F32 expected=new Point2D_F32();
  alg.compute(12,19.5f,expected);
  for (int i=0; i < src.size(); i++) {
    src.get(i).x+=2.5;
    dst.get(i).x+=2.5;
  }
  Point2D_F32 found=new Point2D_F32();
  alg.compute(12,19.5f,found);
  assertEquals(expected.x,found.x,GrlConstants.FLOAT_TEST_TOL);
  assertEquals(expected.y,found.y,GrlConstants.FLOAT_TEST_TOL);
}
Program: 150719
Project: 150719
Buggy source:
/** 
 * Makes sure modifying a single points is the same as modifying all the points at once
 */
@Test public void individualDstSameAsAll(){
  fail("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Makes sure modifying a single points is the same as modifying all the points at once
 */
@Test public void individualDstSameAsAll(){
  List<Point2D_F32> src=createTestPoints();
  List<Point2D_F32> dst=createTestPoints();
  PointDeformKeyPoints alg=createAlgorithm();
  alg.setImageShape(80,100);
  alg.setSource(src);
  alg.setSource(dst);
  alg.setDestination(1,20,25);
  Point2D_F32 expected=new Point2D_F32();
  alg.compute(12,19.5f,expected);
  dst.get(1).set(20,25);
  Point2D_F32 found=new Point2D_F32();
  alg.compute(12,19.5f,found);
  assertEquals(expected.x,found.x,GrlConstants.FLOAT_TEST_TOL);
  assertEquals(expected.y,found.y,GrlConstants.FLOAT_TEST_TOL);
}
Program: 150720
Project: 150720
Buggy source:
@Override public void mouseDragged(MouseEvent e){
  if (active < 0)   return;
  float x=(float)(e.getX() / scale);
  float y=(float)(e.getY() / scale);
synchronized (pointsUndistorted) {
    Point2D_F32 u;
    if (selectedUndist) {
      u=pointsUndistorted.get(active);
    }
 else {
      u=pointsDistorted.get(active);
    }
    u.set(x,y);
  }
  controlPointsModified();
}

Fixed version (ground truth):
@Override public void mouseDragged(MouseEvent e){
  if (!SwingUtilities.isLeftMouseButton(e))   return;
  if (active < 0)   return;
  float x=(float)(e.getX() / scale);
  float y=(float)(e.getY() / scale);
synchronized (pointsUndistorted) {
    Point2D_F32 u;
    if (selectedUndist) {
      u=pointsUndistorted.get(active);
    }
 else {
      u=pointsDistorted.get(active);
    }
    u.set(x,y);
  }
  controlPointsModified();
}
Program: 150721
Project: 150721
Buggy source:
@Override public void mousePressed(MouseEvent e){
  float x=(float)(e.getX() / scale);
  float y=(float)(e.getY() / scale);
  active=-1;
synchronized (pointsUndistorted) {
    for (int i=0; i < pointsDistorted.size(); i++) {
      Point2D_F32 p=pointsDistorted.get(i);
      if (p.distance(x,y) <= clickTol) {
        active=i;
        selectedUndist=false;
      }
    }
    if (active < 0) {
      for (int i=0; i < pointsUndistorted.size(); i++) {
        Point2D_F32 p=pointsUndistorted.get(i);
        if (p.distance(x,y) <= clickTol) {
          active=i;
          selectedUndist=true;
        }
      }
    }
    if (active < 0) {
      active=pointsDistorted.size();
      selectedUndist=false;
      pointsUndistorted.add(new Point2D_F32(x,y));
      pointsDistorted.add(new Point2D_F32(x,y));
      controlPointsModified();
    }
  }
}

Fixed version (ground truth):
@Override public void mousePressed(MouseEvent e){
  if (!SwingUtilities.isLeftMouseButton(e))   return;
  float x=(float)(e.getX() / scale);
  float y=(float)(e.getY() / scale);
  active=-1;
synchronized (pointsUndistorted) {
    for (int i=0; i < pointsDistorted.size(); i++) {
      Point2D_F32 p=pointsDistorted.get(i);
      if (p.distance(x,y) <= clickTol) {
        active=i;
        selectedUndist=false;
      }
    }
    if (active < 0) {
      for (int i=0; i < pointsUndistorted.size(); i++) {
        Point2D_F32 p=pointsUndistorted.get(i);
        if (p.distance(x,y) <= clickTol) {
          active=i;
          selectedUndist=true;
        }
      }
    }
    if (active < 0) {
      active=pointsDistorted.size();
      selectedUndist=false;
      pointsUndistorted.add(new Point2D_F32(x,y));
      pointsDistorted.add(new Point2D_F32(x,y));
      controlPointsModified();
    }
  }
}
Program: 150722
Project: 150722
Buggy source:
@Override public void mouseReleased(MouseEvent e){
  if (active < 0)   return;
  active=-1;
  repaint();
}

Fixed version (ground truth):
@Override public void mouseReleased(MouseEvent e){
  if (!SwingUtilities.isLeftMouseButton(e))   return;
  if (active < 0)   return;
  active=-1;
  repaint();
}
Program: 150723
Project: 150723
Buggy source:
/** 
 * Specifies the input image size and the size of the grid it will use to approximate the idea solution. All control points are discarded
 * @param width Image width
 * @param height Image height
 * @param gridRows grid rows
 * @param gridCols grid columns
 */
public void configure(int width,int height,int gridRows,int gridCols){
  scaleX=width / (float)(gridCols - 1);
  scaleY=height / (float)(gridRows - 1);
  this.gridRows=gridRows;
  this.gridCols=gridCols;
  grid.resize(gridCols * gridRows);
  reset();
}

Fixed version (ground truth):
/** 
 * Specifies the input image size and the size of the grid it will use to approximate the idea solution. All control points are discarded
 * @param width Image width
 * @param height Image height
 * @param gridRows grid rows
 * @param gridCols grid columns
 */
public void configure(int width,int height,int gridRows,int gridCols){
  scaleX=width / (float)(gridCols - 1);
  scaleY=height / (float)(gridRows - 1);
  float ratioX, ratioY;
  if (gridRows > gridCols) {
    ratioX=1.0f;
    ratioY=gridCols / (float)gridRows;
  }
 else {
    ratioX=gridRows / (float)gridCols;
    ratioY=1.0f;
  }
  scaleX/=ratioX;
  scaleY/=ratioY;
  this.gridRows=gridRows;
  this.gridCols=gridCols;
  grid.resize(gridCols * gridRows);
  reset();
}
Program: 150724
Project: 150724
Buggy source:
/** 
 * When sampled exactly on a control point the distortion should be the distortion for that point
 */
@Test public void testAllAtOnce_OnControlPoints(){
  ImageDeformPointMLS_F32 alg=new ImageDeformPointMLS_F32(TypeDeformMLS.AFFINE);
  alg.configure(width,height,rows,cols);
  alg.addControl(5,5.45455f);
  alg.addControl(10,21.818182f);
  alg.addControl(30,49.090908f);
  alg.addControl(15,5.4545455f);
  alg.setDistorted(0,10,12);
  alg.setDistorted(1,14,30);
  alg.setDistorted(2,25,45);
  alg.setDistorted(3,20,8);
  alg.fixateUndistorted();
  alg.fixateDistorted();
  checkCompute(5,5.45455f,10,12,alg);
  checkCompute(10,21.818182f,14,30,alg);
  checkCompute(30,49.090908f,25,45,alg);
  checkCompute(15,5.4545455f,20,8,alg);
}

Fixed version (ground truth):
/** 
 * When sampled exactly on a control point the distortion should be the distortion for that point
 */
@Test public void testAllAtOnce_OnControlPoints(){
  ImageDeformPointMLS_F32 alg=new ImageDeformPointMLS_F32(TypeDeformMLS.AFFINE);
  alg.configure(width,height,rows,cols);
  alg.addControl(5,5.45455f);
  alg.addControl(10,21.818182f);
  alg.addControl(30,49.090908f);
  alg.addControl(15,5.4545455f);
  alg.setDistorted(0,10,12);
  alg.setDistorted(1,14,30);
  alg.setDistorted(2,25,45);
  alg.setDistorted(3,20,8);
  alg.fixateUndistorted();
  alg.fixateDistorted();
  checkCompute(5,5.45455f,10,12,alg);
  checkCompute(10,21.818182f,14,30,alg);
  checkCompute(30,49.090908f,25,45,alg);
  checkCompute(15,5.4545455f,20,8,alg);
  fail("String_Node_Str");
}
Program: 150725
Project: 150725
Buggy source:
/** 
 * The distorted control points are at the same location
 */
@Test public void testAllAtOnce_noChange(){
  ImageDeformPointMLS_F32 alg=new ImageDeformPointMLS_F32(TypeDeformMLS.AFFINE);
  alg.configure(width,height,rows,cols);
  alg.addControl(5,5);
  alg.addControl(10,20);
  alg.addControl(30,50);
  alg.addControl(16,0);
  checkNoTransform(alg);
}

Fixed version (ground truth):
/** 
 * The distorted control points are at the same location
 */
@Test public void testAllAtOnce_noChange(){
  ImageDeformPointMLS_F32 alg=new ImageDeformPointMLS_F32(TypeDeformMLS.AFFINE);
  alg.configure(width,height,rows,cols);
  alg.addControl(5,5);
  alg.addControl(10,20);
  alg.addControl(30,50);
  alg.addControl(16,0);
  checkNoTransform(alg);
  fail("String_Node_Str");
}
Program: 150726
Project: 150726
Buggy source:
/** 
 * See if the distorted point is closer to the closest control point
 */
@Test public void testAllAtOnce_CloserToCloser(){
  ImageDeformPointMLS_F32 alg=new ImageDeformPointMLS_F32(TypeDeformMLS.AFFINE);
  alg.configure(width,height,rows,cols);
  alg.addControl(5,5);
  alg.addControl(10,20);
  alg.addControl(30,50);
  alg.addControl(16,0);
  alg.setDistorted(0,10,12);
  alg.setDistorted(1,14,30);
  alg.setDistorted(2,25,45);
  alg.setDistorted(3,20,8);
  alg.fixateUndistorted();
  alg.fixateDistorted();
  Point2D_F32 a=new Point2D_F32();
  Point2D_F32 b=new Point2D_F32();
  alg.compute(4,4,a);
  alg.compute(1,4,b);
  float distA=a.distance(10,12);
  float distB=b.distance(10,12);
  assertTrue(distA < distB);
}

Fixed version (ground truth):
/** 
 * See if the distorted point is closer to the closest control point
 */
@Test public void testAllAtOnce_CloserToCloser(){
  ImageDeformPointMLS_F32 alg=new ImageDeformPointMLS_F32(TypeDeformMLS.AFFINE);
  alg.configure(width,height,rows,cols);
  alg.addControl(5,5);
  alg.addControl(10,20);
  alg.addControl(30,50);
  alg.addControl(16,0);
  alg.setDistorted(0,10,12);
  alg.setDistorted(1,14,30);
  alg.setDistorted(2,25,45);
  alg.setDistorted(3,20,8);
  alg.fixateUndistorted();
  alg.fixateDistorted();
  Point2D_F32 a=new Point2D_F32();
  Point2D_F32 b=new Point2D_F32();
  alg.compute(4,4,a);
  alg.compute(1,4,b);
  float distA=a.distance(10,12);
  float distB=b.distance(10,12);
  assertTrue(distA < distB);
  fail("String_Node_Str");
}
Program: 150728
Project: 150728
Buggy source:
private void controlPointsModified(boolean justDistorted){
synchronized (pointsUndistorted) {
    try {
      if (!justDistorted) {
        alg.setKeyPoints(pointsUndistorted);
        validTransform=true;
      }
      System.out.println("String_Node_Str");
      alg.setDistorted(pointsDistorted);
    }
 catch (    RuntimeException e) {
      System.out.println("String_Node_Str");
      validTransform=false;
    }
  }
  distortImage.setModel(p2p);
  if (inputMethod == InputMethod.IMAGE) {
    renderDistorted(distortedBuff,undistorted);
  }
  gui.repaint();
}

Fixed version (ground truth):
private void controlPointsModified(){
synchronized (pointsUndistorted) {
    try {
      alg.setSource(pointsDistorted);
      alg.setDestination(pointsUndistorted);
      validTransform=true;
    }
 catch (    RuntimeException e) {
      System.out.println("String_Node_Str" + e.getMessage());
      System.out.println("String_Node_Str" + pointsDistorted.size());
      validTransform=false;
    }
  }
  distortImage.setModel(p2p);
  if (inputMethod == InputMethod.IMAGE) {
    renderDistorted(distortedBuff,undistorted);
  }
  gui.repaint();
}
Program: 150729
Project: 150729
Buggy source:
@Override public void mouseDragged(MouseEvent e){
  if (active < 0)   return;
  float x=(float)(e.getX() / scale);
  float y=(float)(e.getY() / scale);
synchronized (pointsUndistorted) {
    Point2D_F32 u=pointsDistorted.get(active);
    u.set(x,y);
  }
  controlPointsModified(true);
}

Fixed version (ground truth):
@Override public void mouseDragged(MouseEvent e){
  if (active < 0)   return;
  float x=(float)(e.getX() / scale);
  float y=(float)(e.getY() / scale);
synchronized (pointsUndistorted) {
    Point2D_F32 u;
    if (selectedUndist) {
      u=pointsUndistorted.get(active);
    }
 else {
      u=pointsDistorted.get(active);
    }
    u.set(x,y);
  }
  controlPointsModified();
}
Program: 150730
Project: 150730
Buggy source:
@Override public void paintComponent(Graphics g){
  super.paintComponent(g);
  Graphics2D g2=(Graphics2D)g;
  g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,RenderingHints.VALUE_STROKE_PURE);
  g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
synchronized (pointsUndistorted) {
    g2.setStroke(strokeThin);
    g2.setColor(Color.GRAY);
    for (int i=0; i < pointsUndistorted.size(); i++) {
      Point2D_F32 u=pointsUndistorted.get(i);
      Point2D_F32 d=pointsDistorted.get(i);
      line.setLine(u.x * scale,u.y * scale,d.x * scale,d.y * scale);
      g2.draw(line);
    }
    double r=clickTol / 2.0;
    g2.setStroke(strokeThick);
    g2.setColor(Color.RED);
    for (int i=0; i < pointsUndistorted.size(); i++) {
      Point2D_F32 p=pointsUndistorted.get(i);
      c.setFrame(p.x * scale - r,p.y * scale - r,2 * r,2 * r);
      g2.draw(c);
    }
    g2.setColor(Color.BLUE);
    for (int i=0; i < pointsDistorted.size(); i++) {
      Point2D_F32 p=pointsDistorted.get(i);
      c.setFrame(p.x * scale - r,p.y * scale - r,2 * r,2 * r);
      g2.draw(c);
    }
  }
}

Fixed version (ground truth):
@Override public void paintComponent(Graphics g){
  super.paintComponent(g);
  Graphics2D g2=(Graphics2D)g;
  g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,RenderingHints.VALUE_STROKE_PURE);
  g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
synchronized (pointsUndistorted) {
    g2.setStroke(strokeThin);
    g2.setColor(Color.GRAY);
    for (int i=0; i < pointsUndistorted.size(); i++) {
      if (active != -1 && i != active)       continue;
      Point2D_F32 u=pointsUndistorted.get(i);
      Point2D_F32 d=pointsDistorted.get(i);
      line.setLine(u.x * scale,u.y * scale,d.x * scale,d.y * scale);
      g2.draw(line);
    }
    double r=clickTol / 2.0;
    g2.setStroke(strokeThick);
    g2.setColor(Color.RED);
    for (int i=0; i < pointsUndistorted.size(); i++) {
      if (active != -1 && i != active)       continue;
      Point2D_F32 p=pointsUndistorted.get(i);
      c.setFrame(p.x * scale - r,p.y * scale - r,2 * r,2 * r);
      g2.draw(c);
    }
    g2.setColor(Color.BLUE);
    for (int i=0; i < pointsDistorted.size(); i++) {
      if (active != -1 && i != active)       continue;
      Point2D_F32 p=pointsDistorted.get(i);
      c.setFrame(p.x * scale - r,p.y * scale - r,2 * r,2 * r);
      g2.draw(c);
    }
  }
}
Program: 150731
Project: 150731
Buggy source:
public static void main(String args[]){
  ImageType type=ImageType.pl(3,GrayU8.class);
  List<PathLabel> inputs=new ArrayList<>();
  inputs.add(new PathLabel("String_Node_Str",UtilIO.pathExample("String_Node_Str")));
  DeformImageKeyPointsApp app=new DeformImageKeyPointsApp(inputs,type);
  app.openFile(new File(inputs.get(0).getPath()));
  app.waitUntilDoneProcessing();
  ShowImages.showWindow(app,"String_Node_Str",true);
}

Fixed version (ground truth):
public static void main(String args[]){
  ImageType type=ImageType.pl(3,GrayU8.class);
  List<PathLabel> inputs=new ArrayList<>();
  inputs.add(new PathLabel("String_Node_Str",UtilIO.pathExample("String_Node_Str")));
  inputs.add(new PathLabel("String_Node_Str",UtilIO.pathExample("String_Node_Str")));
  DeformImageKeyPointsApp app=new DeformImageKeyPointsApp(inputs,type);
  app.openFile(new File(inputs.get(0).getPath()));
  app.waitUntilDoneProcessing();
  ShowImages.showWindow(app,"String_Node_Str",true);
}
Program: 150732
Project: 150732
Buggy source:
@Override public void handleAlgorithmChange(){
  alg=FactoryDistort.deformMls(control.getConfigMLS());
  p2p.setTransform(alg);
  controlPointsModified(false);
}

Fixed version (ground truth):
@Override public void handleAlgorithmChange(){
  System.out.println("String_Node_Str");
  alg=FactoryDistort.deformMls(control.getConfigMLS());
  p2p.setTransform(alg);
  alg.setImageShape(undistorted.width,undistorted.height);
  controlPointsModified();
}
Program: 150733
Project: 150733
Buggy source:
@Override public void mousePressed(MouseEvent e){
  float x=(float)(e.getX() / scale);
  float y=(float)(e.getY() / scale);
  active=-1;
synchronized (pointsUndistorted) {
    for (int i=0; i < pointsUndistorted.size(); i++) {
      Point2D_F32 p=pointsUndistorted.get(i);
      if (p.distance(x,y) <= clickTol) {
        active=i;
        selectedUndist=true;
      }
    }
    if (active < 0) {
      active=pointsDistorted.size();
      selectedUndist=false;
      pointsUndistorted.add(new Point2D_F32(x,y));
      pointsDistorted.add(new Point2D_F32(x,y));
      controlPointsModified(false);
    }
  }
}

Fixed version (ground truth):
@Override public void mousePressed(MouseEvent e){
  float x=(float)(e.getX() / scale);
  float y=(float)(e.getY() / scale);
  active=-1;
synchronized (pointsUndistorted) {
    for (int i=0; i < pointsDistorted.size(); i++) {
      Point2D_F32 p=pointsDistorted.get(i);
      if (p.distance(x,y) <= clickTol) {
        active=i;
        selectedUndist=false;
      }
    }
    if (active < 0) {
      for (int i=0; i < pointsUndistorted.size(); i++) {
        Point2D_F32 p=pointsUndistorted.get(i);
        if (p.distance(x,y) <= clickTol) {
          active=i;
          selectedUndist=true;
        }
      }
    }
    if (active < 0) {
      active=pointsDistorted.size();
      selectedUndist=false;
      pointsUndistorted.add(new Point2D_F32(x,y));
      pointsDistorted.add(new Point2D_F32(x,y));
      controlPointsModified();
    }
  }
}
Program: 150734
Project: 150734
Buggy source:
@Override public void mouseReleased(MouseEvent e){
  if (active < 0)   return;
  active=-1;
}

Fixed version (ground truth):
@Override public void mouseReleased(MouseEvent e){
  if (active < 0)   return;
  active=-1;
  repaint();
}
Program: 150735
Project: 150735
Buggy source:
@Override public void processImage(final BufferedImage buffered,final T undistorted){
  BufferedImage tmp=distortedBuff;
  distortedBuff=ConvertBufferedImage.checkDeclare(undistorted.width,undistorted.height,distortedBuff,BufferedImage.TYPE_INT_RGB);
  if (tmp != distortedBuff) {
    distorted.reshape(undistorted.width,undistorted.height);
    this.undistorted.reshape(undistorted.width,undistorted.height);
    gui.setPreferredSize(new Dimension(undistorted.width,undistorted.height));
    alg.setImageShape(undistorted.width,undistorted.height);
synchronized (pointsUndistorted) {
      validTransform=false;
      pointsUndistorted.clear();
      pointsDistorted.clear();
      alg.setKeyPoints(pointsUndistorted);
    }
  }
  if (inputMethod == InputMethod.IMAGE) {
    this.undistorted.setTo(undistorted);
  }
  renderDistorted(buffered,undistorted);
}

Fixed version (ground truth):
@Override public void processImage(final BufferedImage buffered,final T undistorted){
  BufferedImage tmp=distortedBuff;
  distortedBuff=ConvertBufferedImage.checkDeclare(undistorted.width,undistorted.height,distortedBuff,BufferedImage.TYPE_INT_RGB);
  if (tmp != distortedBuff) {
    distorted.reshape(undistorted.width,undistorted.height);
    this.undistorted.reshape(undistorted.width,undistorted.height);
    gui.setPreferredSize(new Dimension(undistorted.width,undistorted.height));
    alg.setImageShape(undistorted.width,undistorted.height);
synchronized (pointsUndistorted) {
      validTransform=false;
      pointsUndistorted.clear();
      pointsDistorted.clear();
      alg.setSource(pointsDistorted);
    }
  }
  if (inputMethod == InputMethod.IMAGE) {
    this.undistorted.setTo(undistorted);
  }
  renderDistorted(buffered,undistorted);
}
Program: 150736
Project: 150736
Buggy source:
@Override public void stateChanged(ChangeEvent e){
  if (e.getSource() == selectModel) {
    configMLS.type=(TypeDeformMLS)selectModel.getValue();
  }
 else   if (e.getSource() == selectGridRows) {
    configMLS.rows=((SpinnerNumberModel)selectGridRows.getModel()).getNumber().intValue();
  }
 else   if (e.getSource() == selectGridCols) {
    configMLS.cols=((SpinnerNumberModel)selectGridCols.getModel()).getNumber().intValue();
  }
 else   if (e.getSource() == selectAlpha) {
    configMLS.alpha=((SpinnerNumberModel)selectGridCols.getModel()).getNumber().floatValue();
  }
 else {
    return;
  }
  listener.handleAlgorithmChange();
}

Fixed version (ground truth):
@Override public void stateChanged(ChangeEvent e){
  if (e.getSource() == selectModel) {
    configMLS.type=(TypeDeformMLS)selectModel.getValue();
  }
 else   if (e.getSource() == selectGridRows) {
    configMLS.rows=((SpinnerNumberModel)selectGridRows.getModel()).getNumber().intValue();
  }
 else   if (e.getSource() == selectGridCols) {
    configMLS.cols=((SpinnerNumberModel)selectGridCols.getModel()).getNumber().intValue();
  }
 else   if (e.getSource() == selectAlpha) {
    configMLS.alpha=((SpinnerNumberModel)selectAlpha.getModel()).getNumber().floatValue();
  }
 else {
    return;
  }
  listener.handleAlgorithmChange();
}
Program: 150737
Project: 150737
Buggy source:
/** 
 * Sets the distorted location of a specific control point
 * @param which Which control point
 * @param x distorted coordinate x-axis in image pixels
 * @param y distorted coordinate y-axis in image pixels
 */
public void setDistorted(int which,float x,float y){
  if (controls.get(which).q.distance(x,y) > 0.0001) {
    System.out.println("String_Node_Str" + which);
  }
  controls.get(which).q.set(x,y);
}

Fixed version (ground truth):
/** 
 * Sets the distorted location of a specific control point
 * @param which Which control point
 * @param x distorted coordinate x-axis in image pixels
 * @param y distorted coordinate y-axis in image pixels
 */
public void setDistorted(int which,float x,float y){
  controls.get(which).q.set(x,y);
}
Program: 150738
Project: 150738
Buggy source:
/** 
 * Sets the location of a control point.  Initially the distorted and undistorted location will be set to be the same.
 * @param x coordinate x-axis in image pixels
 * @param y coordinate y-axis in image pixels
 * @return Index of control point
 */
public int addControl(float x,float y){
  if (scaleX <= 0 || scaleY <= 0)   throw new IllegalArgumentException("String_Node_Str");
  Control c=controls.grow();
  c.p.set(x / scaleX,y / scaleY);
  c.q.set(x,y);
  return controls.size() - 1;
}

Fixed version (ground truth):
/** 
 * Adds a new control point at the specified location.  Initially the distorted and undistorted location will be set to the same
 * @param x coordinate x-axis in image pixels
 * @param y coordinate y-axis in image pixels
 * @return Index of control point
 */
public int addControl(float x,float y){
  Control c=controls.grow();
  c.q.set(x,y);
  setUndistorted(controls.size() - 1,x,y);
  return controls.size() - 1;
}
Program: 150739
Project: 150739
Buggy source:
/** 
 * Recompute the deformation of each point in the internal grid now that the location of control points is not changing any more.  Must call   {@link #fixateUndistorted()} first.
 */
public void fixateDistorted(){
  for (int row=0; row < gridRows; row++) {
    for (int col=0; col < gridCols; col++) {
      AffineCache cache=getGrid(row,col);
      computeAverageQ(cache);
      computeAffineDeformed(cache);
      if (row == 0 && col == 1) {
        System.out.println("String_Node_Str" + cache.aveQ);
        System.out.println("String_Node_Str" + cache.deformed);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Recompute the deformation of each point in the internal grid now that the location of control points is not changing any more.  Must call   {@link #fixateUndistorted()} first.
 */
public void fixateDistorted(){
  for (int row=0; row < gridRows; row++) {
    for (int col=0; col < gridCols; col++) {
      AffineCache cache=getGrid(row,col);
      computeAverageQ(cache);
      computeAffineDeformed(cache);
    }
  }
}
Program: 150740
Project: 150740
Buggy source:
/** 
 * Blob detector which uses a 3x3 kernel to approximate the second order derivatives and compute a Laplacian blob.
 */
public static <I extends ImageGray<I>>GeneralFeatureIntensity<I,?> laplacian(){
  return new WrapperLaplacianBlobIntensity<>();
}

Fixed version (ground truth):
/** 
 * Blob detector which uses a 3x3 kernel to approximate the second order derivatives and compute a Laplacian blob.
 */
public static <I extends ImageGray<I>>GeneralFeatureIntensity<I,?> laplacian(){
  return new WrapperLaplacianBlobIntensity();
}
Program: 150741
Project: 150741
Buggy source:
@Override public void setCalibration(CameraPinholeRadial paramVisual,Point2Transform2_F32 visToDepth){
  CameraPinhole desired=new CameraPinhole(paramVisual);
  desired.skew=0;
  adjustImage=LensDistortionOps.changeCameraModel(AdjustmentType.EXPAND,BorderType.ZERO,paramVisual,desired,paramAdjusted,visType);
  Point2Transform2_F32 desiredToOriginal=LensDistortionOps.transformChangeModel_F32(AdjustmentType.EXPAND,paramVisual,desired,false,null);
  Point2Transform2_F32 adjustedToDepth=new SequencePoint2Transform2_F32(desiredToOriginal,visToDepth);
  PixelTransform2_F32 pixelAdjToDepth=new PixelTransformCached_F32(paramAdjusted.width,paramAdjusted.height,adjustedToDepth);
  Point2Transform2_F64 pixelAdjToNorm=LensDistortionOps.narrow(paramAdjusted).undistort_F64(true,false);
  sparse3D.configure(pixelAdjToNorm,pixelAdjToDepth);
  undistorted.reshape(paramAdjusted.width,paramAdjusted.height);
  alg.setCameraParameters((float)paramAdjusted.fx,(float)paramAdjusted.fy,(float)paramAdjusted.cy,(float)paramAdjusted.cy,paramAdjusted.width,paramAdjusted.height);
}

Fixed version (ground truth):
@Override public void setCalibration(CameraPinholeRadial paramVisual,Point2Transform2_F32 visToDepth){
  CameraPinhole desired=new CameraPinhole(paramVisual);
  desired.skew=0;
  adjustImage=LensDistortionOps.changeCameraModel(AdjustmentType.EXPAND,BorderType.ZERO,paramVisual,desired,paramAdjusted,visType);
  Point2Transform2_F32 desiredToOriginal=LensDistortionOps.transformChangeModel_F32(AdjustmentType.EXPAND,paramVisual,desired,false,null);
  Point2Transform2_F32 adjustedToDepth=new SequencePoint2Transform2_F32(desiredToOriginal,visToDepth);
  PixelTransform2_F32 pixelAdjToDepth=new PixelTransformCached_F32(paramAdjusted.width,paramAdjusted.height,adjustedToDepth);
  sparse3D.configure(LensDistortionOps.narrow(paramAdjusted),pixelAdjToDepth);
  undistorted.reshape(paramAdjusted.width,paramAdjusted.height);
  alg.setCameraParameters((float)paramAdjusted.fx,(float)paramAdjusted.fy,(float)paramAdjusted.cy,(float)paramAdjusted.cy,paramAdjusted.width,paramAdjusted.height);
}
Program: 150742
Project: 150742
Buggy source:
@Override public void setCalibration(CameraPinholeRadial paramVisual,Point2Transform2_F32 visToDepth){
  PointToPixelTransform_F32 visToDepth_pixel=new PointToPixelTransform_F32(visToDepth);
  sparse3D.configure(paramVisual,visToDepth_pixel);
  Point2Transform2_F64 leftPixelToNorm=narrow(paramVisual).undistort_F64(true,false);
  Point2Transform2_F64 leftNormToPixel=narrow(paramVisual).distort_F64(false,true);
  alg.setPixelToNorm(leftPixelToNorm);
  alg.setNormToPixel(leftNormToPixel);
  distance.setIntrinsic(paramVisual.fx,paramVisual.fy,paramVisual.skew);
}

Fixed version (ground truth):
@Override public void setCalibration(CameraPinholeRadial paramVisual,Point2Transform2_F32 visToDepth){
  PointToPixelTransform_F32 visToDepth_pixel=new PointToPixelTransform_F32(visToDepth);
  sparse3D.configure(LensDistortionOps.narrow(paramVisual),visToDepth_pixel);
  Point2Transform2_F64 leftPixelToNorm=narrow(paramVisual).undistort_F64(true,false);
  Point2Transform2_F64 leftNormToPixel=narrow(paramVisual).distort_F64(false,true);
  alg.setPixelToNorm(leftPixelToNorm);
  alg.setNormToPixel(leftNormToPixel);
  distance.setIntrinsic(paramVisual.fx,paramVisual.fy,paramVisual.skew);
}
Program: 150743
Project: 150743
Buggy source:
/** 
 * Configures intrinsic camera parameters
 * @param pixelToNorm Transform from pixel to undistorted normalized image coordinates
 * @param visualToDepth Transform from visual to depth camera pixel coordinate systems.
 */
public void configure(Point2Transform2_F64 pixelToNorm,PixelTransform2_F32 visualToDepth){
  this.visualToDepth=visualToDepth;
  this.p2n=pixelToNorm;
}

Fixed version (ground truth):
/** 
 * Configures intrinsic camera parameters
 * @param model Model for narrow FOV cameras
 * @param visualToDepth Transform from visual to depth camera pixel coordinate systems.
 */
public void configure(LensDistortionNarrowFOV model,PixelTransform2_F32 visualToDepth){
  this.visualToDepth=visualToDepth;
  this.p2n=model.undistort_F64(true,false);
}
Program: 150744
Project: 150744
Buggy source:
@Test public void basicTest(){
  GrayU16 depth=new GrayU16(w,h);
  depth.set(5,6,1000);
  CameraPinholeRadial param=new CameraPinholeRadial(1,1,0,5,10,w,h).fsetRadial(0,0);
  PixelTransform2_F32 v2d=new PixelTransform2_F32(){
    @Override public void compute(    int x,    int y){
      distX=x + 1;
      distY=y + 2;
    }
  }
;
  DepthSparse3D<GrayU16> alg=new DepthSparse3D.I<>(2.1);
  alg.configure(param,v2d);
  alg.setDepthImage(depth);
  assertTrue(alg.process(4,4));
  Point3D_F64 found=alg.getWorldPt();
  Point2D_F64 norm=new Point2D_F64();
  PerspectiveOps.convertPixelToNorm(param,new Point2D_F64(4,4),norm);
  double z=1000 * 2.1;
  assertEquals(z,found.z,1e-8);
  assertEquals(norm.x * z,found.x,1e-8);
  assertEquals(norm.y * z,found.y,1e-8);
}

Fixed version (ground truth):
@Test public void basicTest(){
  GrayU16 depth=new GrayU16(w,h);
  depth.set(5,6,1000);
  CameraPinholeRadial param=new CameraPinholeRadial(1,1,0,5,10,w,h).fsetRadial(0,0);
  PixelTransform2_F32 v2d=new PixelTransform2_F32(){
    @Override public void compute(    int x,    int y){
      distX=x + 1;
      distY=y + 2;
    }
  }
;
  DepthSparse3D<GrayU16> alg=new DepthSparse3D.I<>(2.1);
  alg.configure(LensDistortionOps.narrow(param),v2d);
  alg.setDepthImage(depth);
  assertTrue(alg.process(4,4));
  Point3D_F64 found=alg.getWorldPt();
  Point2D_F64 norm=new Point2D_F64();
  PerspectiveOps.convertPixelToNorm(param,new Point2D_F64(4,4),norm);
  double z=1000 * 2.1;
  assertEquals(z,found.z,1e-8);
  assertEquals(norm.x * z,found.x,1e-8);
  assertEquals(norm.y * z,found.y,1e-8);
}
Program: 150745
Project: 150745
Buggy source:
private void putGridIntoCanonical_vertical(int numRows,int numCols){
  DetectAsymmetricCircleGrid<?> alg=new DetectAsymmetricCircleGrid<>(numRows,numCols,null,null,null);
  Grid g=createGrid(numRows,numCols);
  List<EllipseRotated_F64> original=new ArrayList<>();
  original.addAll(g.ellipses);
  alg.putGridIntoCanonical(g);
  assertEquals(numRows,g.rows);
  assertEquals(numCols,g.columns);
  assertTrue(original.get(0) == g.get(0,0));
  checkCounterClockWise(g);
  alg.putGridIntoCanonical(flipVertical(g));
  assertEquals(numRows,g.rows);
  assertEquals(numCols,g.columns);
  assertTrue(original.get(0) == g.get(0,0));
  checkCounterClockWise(g);
}

Fixed version (ground truth):
private void putGridIntoCanonical_vertical(int numRows,int numCols){
  DetectAsymmetricCircleGrid<?> alg=new DetectAsymmetricCircleGrid(numRows,numCols,null,null,null);
  Grid g=createGrid(numRows,numCols);
  List<EllipseRotated_F64> original=new ArrayList<>();
  original.addAll(g.ellipses);
  alg.putGridIntoCanonical(g);
  assertEquals(numRows,g.rows);
  assertEquals(numCols,g.columns);
  assertTrue(original.get(0) == g.get(0,0));
  checkCounterClockWise(g);
  alg.putGridIntoCanonical(flipVertical(g));
  assertEquals(numRows,g.rows);
  assertEquals(numCols,g.columns);
  assertTrue(original.get(0) == g.get(0,0));
  checkCounterClockWise(g);
}
Program: 150746
Project: 150746
Buggy source:
public void putGridIntoCanonical_rotate(int numRows,int numCols){
  DetectAsymmetricCircleGrid<?> alg=new DetectAsymmetricCircleGrid<>(numRows,numCols,null,null,null);
  Grid g=createGrid(numRows,numCols);
  List<EllipseRotated_F64> original=new ArrayList<>();
  original.addAll(g.ellipses);
  alg.putGridIntoCanonical(g);
  assertEquals(numRows,g.rows);
  assertEquals(numCols,g.columns);
  assertTrue(original.get(0) == g.get(0,0));
  checkCounterClockWise(g);
  alg.rotateGridCCW(g);
  alg.putGridIntoCanonical(g);
  assertTrue(original.get(0) == g.get(0,0));
  checkCounterClockWise(g);
  alg.rotateGridCCW(g);
  alg.rotateGridCCW(g);
  alg.putGridIntoCanonical(g);
  assertTrue(original.get(0) == g.get(0,0));
  checkCounterClockWise(g);
  alg.rotateGridCCW(g);
  alg.rotateGridCCW(g);
  alg.rotateGridCCW(g);
  alg.putGridIntoCanonical(g);
  assertTrue(original.get(0) == g.get(0,0));
  checkCounterClockWise(g);
  alg.flipVertical(g);
  alg.putGridIntoCanonical(g);
  assertTrue(original.get(0) == g.get(0,0));
  checkCounterClockWise(g);
}

Fixed version (ground truth):
public void putGridIntoCanonical_rotate(int numRows,int numCols){
  DetectAsymmetricCircleGrid<?> alg=new DetectAsymmetricCircleGrid(numRows,numCols,null,null,null);
  Grid g=createGrid(numRows,numCols);
  List<EllipseRotated_F64> original=new ArrayList<>();
  original.addAll(g.ellipses);
  alg.putGridIntoCanonical(g);
  assertEquals(numRows,g.rows);
  assertEquals(numCols,g.columns);
  assertTrue(original.get(0) == g.get(0,0));
  checkCounterClockWise(g);
  alg.rotateGridCCW(g);
  alg.putGridIntoCanonical(g);
  assertTrue(original.get(0) == g.get(0,0));
  checkCounterClockWise(g);
  alg.rotateGridCCW(g);
  alg.rotateGridCCW(g);
  alg.putGridIntoCanonical(g);
  assertTrue(original.get(0) == g.get(0,0));
  checkCounterClockWise(g);
  alg.rotateGridCCW(g);
  alg.rotateGridCCW(g);
  alg.rotateGridCCW(g);
  alg.putGridIntoCanonical(g);
  assertTrue(original.get(0) == g.get(0,0));
  checkCounterClockWise(g);
  alg.flipVertical(g);
  alg.putGridIntoCanonical(g);
  assertTrue(original.get(0) == g.get(0,0));
  checkCounterClockWise(g);
}
Program: 150747
Project: 150747
Buggy source:
@Test public void rotateGridCCW(){
  Grid g=createGrid(3,3);
  List<EllipseRotated_F64> original=new ArrayList<>();
  original.addAll(g.ellipses);
  DetectAsymmetricCircleGrid<?> alg=new DetectAsymmetricCircleGrid<>(3,3,null,null,null);
  alg.rotateGridCCW(g);
  assertEquals(9,g.ellipses.size());
  assertTrue(original.get(6) == g.get(0,0));
  assertTrue(original.get(0) == g.get(0,2));
  assertTrue(original.get(2) == g.get(2,2));
  assertTrue(original.get(8) == g.get(2,0));
}

Fixed version (ground truth):
@Test public void rotateGridCCW(){
  Grid g=createGrid(3,3);
  List<EllipseRotated_F64> original=new ArrayList<>();
  original.addAll(g.ellipses);
  DetectAsymmetricCircleGrid<?> alg=new DetectAsymmetricCircleGrid(3,3,null,null,null);
  alg.rotateGridCCW(g);
  assertEquals(9,g.ellipses.size());
  assertTrue(original.get(6) == g.get(0,0));
  assertTrue(original.get(0) == g.get(0,2));
  assertTrue(original.get(2) == g.get(2,2));
  assertTrue(original.get(8) == g.get(2,0));
}