nus-yam/ex-repair huggingface dataset:
Program: 76404
Project: 76404
Buggy source:
public Delay(TypedCompositeActor container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
  try {
    TypedIOPort input=(TypedIOPort)newPort("String_Node_Str");
    input.setInput(true);
    setTokenConsumptionRate(input,1);
    input.setTypeEquals(Token.class);
    TypedIOPort output=(TypedIOPort)newPort("String_Node_Str");
    output.setOutput(true);
    setTokenProductionRate(output,1);
    output.setTypeEquals(Token.class);
    setTokenInitProduction(output,1);
  }
 catch (  IllegalActionException e1) {
    System.out.println("String_Node_Str");
    e1.printStackTrace();
  }
}

Fixed version (ground truth):
public Delay(TypedCompositeActor container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
  try {
    input=(TypedIOPort)newPort("String_Node_Str");
    input.setInput(true);
    setTokenConsumptionRate(input,1);
    input.setTypeEquals(Token.class);
    output=(TypedIOPort)newPort("String_Node_Str");
    output.setOutput(true);
    setTokenProductionRate(output,1);
    output.setTypeEquals(Token.class);
    setTokenInitProduction(output,1);
  }
 catch (  IllegalActionException e1) {
    System.out.println("String_Node_Str");
    e1.printStackTrace();
    throw e1;
  }
}
Program: 76405
Project: 76405
Buggy source:
/** 
 * Construct the graph representing the PN topology. This is sort of bogus because it's totally hird-wired, but it will do for now...
 */
public GraphModel constructThreadGraph(){
  GraphModel model=new GraphModel();
  Node n1=model.createNode(a1);
  Node n2=model.createNode(a2);
  Node n3=model.createNode(a3);
  Node n4=model.createNode(a4);
  Node n5=model.createNode(a5);
  Node n6=model.createNode(a6);
  Node n7=model.createNode(a7);
  Node n8=model.createNode(a8);
  model.addNode(n1);
  model.addNode(n2);
  model.addNode(n3);
  model.addNode(n4);
  model.addNode(n5);
  model.addNode(n6);
  model.addNode(n7);
  model.addNode(n8);
  nodeMap.put(a1,n1);
  nodeMap.put(a2,n2);
  nodeMap.put(a3,n3);
  nodeMap.put(a4,n4);
  nodeMap.put(a5,n5);
  nodeMap.put(a6,n6);
  nodeMap.put(a7,n7);
  nodeMap.put(a8,n8);
  model.createEdge(n1,n2);
  model.createEdge(n2,n3);
  model.createEdge(n3,n4);
  model.createEdge(n4,n5);
  model.createEdge(n5,n6);
  model.createEdge(n1,n7);
  model.createEdge(n5,n8);
  return model;
}

Fixed version (ground truth):
/** 
 * Construct the graph representing the PN topology. This is sort of bogus because it's totally hird-wired, but it will do for now...
 */
public GraphModel constructThreadGraph(){
  GraphModel model=new GraphModel();
  Node n1=model.createNode(a1);
  Node n2=model.createNode(a2);
  Node n3=model.createNode(a3);
  Node n4=model.createNode(a4);
  Node n5=model.createNode(a5);
  Node n6=model.createNode(a6);
  Node n7=model.createNode(a7);
  Node n8=model.createNode(a8);
  model.addNode(n1);
  model.addNode(n2);
  model.addNode(n3);
  model.addNode(n4);
  model.addNode(n5);
  model.addNode(n6);
  model.addNode(n7);
  model.addNode(n8);
  _nodeMap.put(a1,n1);
  _nodeMap.put(a2,n2);
  _nodeMap.put(a3,n3);
  _nodeMap.put(a4,n4);
  _nodeMap.put(a5,n5);
  _nodeMap.put(a6,n6);
  _nodeMap.put(a7,n7);
  _nodeMap.put(a8,n8);
  model.createEdge(n1,n2);
  model.createEdge(n2,n3);
  model.createEdge(n3,n4);
  model.createEdge(n4,n5);
  model.createEdge(n5,n6);
  model.createEdge(n1,n7);
  model.createEdge(n5,n8);
  return model;
}
Program: 76406
Project: 76406
Buggy source:
/** 
 * Construct the trace display.
 */
public void displayTrace(TraceModel traceModel){
  traceWindow=new TutorialWindow("String_Node_Str");
  tracePane=new TracePane();
  JCanvas traceWidget=new JCanvas(tracePane);
  TraceView traceView=tracePane.getTraceView();
  traceView.setTimeScale(0.02);
  traceView.setLayout(10,10,500,30,5);
  traceView.setTraceModel(traceModel);
  traceWindow.getContentPane().add("String_Node_Str",traceWidget);
  traceWindow.setSize(800,300);
  traceWindow.setLocation(300,300);
  traceWindow.setVisible(true);
}

Fixed version (ground truth):
/** 
 * Construct the trace display.
 */
public void displayTrace(TraceModel traceModel){
  _traceWindow=new TutorialWindow("String_Node_Str");
  _tracePan=new TracePane();
  JCanvas traceWidget=new JCanvas(_tracePan);
  TraceView traceView=_tracePan.getTraceView();
  traceView.setTimeScale(0.02);
  traceView.setLayout(10,10,500,30,5);
  traceView.setTraceModel(traceModel);
  _traceWindow.getContentPane().add("String_Node_Str",traceWidget);
  _traceWindow.setSize(800,300);
  _traceWindow.setLocation(300,300);
  _traceWindow.setVisible(true);
}
Program: 76408
Project: 76408
Buggy source:
public StateListener(GraphPane pane){
  _graphPane=pane;
  _start=System.currentTimeMillis();
  TraceModel model=tracePane.getTraceModel();
  _currentElement=new TraceModel.Element[model.size()];
  for (int i=0; i < model.size(); i++) {
    TraceModel.Trace trace=model.getTrace(i);
    final TraceModel.Element element=new TraceModel.Element(0,1,3);
    element.closure=TraceModel.Element.OPEN_END;
    trace.add(element);
    _currentElement[i]=element;
    try {
      SwingUtilities.invokeAndWait(new Runnable(){
        public void run(){
          tracePane.getTraceView().drawTraceElement(element);
        }
      }
);
    }
 catch (    Exception e) {
      System.out.println(e);
    }
  }
}

Fixed version (ground truth):
public StateListener(GraphPane pane){
  _graphPane=pane;
  _start=System.currentTimeMillis();
  TraceModel model=_tracePan.getTraceModel();
  _currentElement=new TraceModel.Element[model.size()];
  for (int i=0; i < model.size(); i++) {
    TraceModel.Trace trace=model.getTrace(i);
    final TraceModel.Element element=new TraceModel.Element(0,1,3);
    element.closure=TraceModel.Element.OPEN_END;
    trace.add(element);
    _currentElement[i]=element;
    try {
      SwingUtilities.invokeAndWait(new Runnable(){
        public void run(){
          _tracePan.getTraceView().drawTraceElement(element);
        }
      }
);
    }
 catch (    Exception e) {
      System.out.println(e);
    }
  }
}
Program: 76409
Project: 76409
Buggy source:
public void run(){
  TraceView v=tracePane.getTraceView();
  for (int i=0; i < msize; i++) {
    v.updateTraceElement(temp[i]);
  }
  v.drawTraceElement(element);
}

Fixed version (ground truth):
public void run(){
  TraceView v=_tracePan.getTraceView();
  for (int i=0; i < msize; i++) {
    v.updateTraceElement(temp[i]);
  }
  v.drawTraceElement(element);
}
Program: 76410
Project: 76410
Buggy source:
/** 
 * Construct the graph widget with the default constructor (giving it an empty graph), and then set the model once the window is showing.
 */
public void displayGraph(JGraph g,GraphModel model){
  window=new TutorialWindow("String_Node_Str");
  window.getContentPane().add("String_Node_Str",g);
  window.setSize(800,300);
  window.setLocation(20,20);
  window.setVisible(true);
  GraphPane gp=(GraphPane)g.getCanvasPane();
  GraphView gv=gp.getGraphView();
  gv.setNodeRenderer(new ThreadRenderer());
  g.setGraphModel(model);
  LevelLayout staticLayout=new LevelLayout();
  staticLayout.setOrientation(LevelLayout.HORIZONTAL);
  staticLayout.layout(gv,model.getGraph());
  gp.repaint();
}

Fixed version (ground truth):
/** 
 * Construct the graph widget with the default constructor (giving it an empty graph), and then set the model once the window is showing.
 */
public void displayGraph(JGraph g,GraphModel model){
  _window=new TutorialWindow("String_Node_Str");
  _window.getContentPane().add("String_Node_Str",g);
  _window.setSize(800,300);
  _window.setLocation(20,20);
  _window.setVisible(true);
  GraphPane gp=(GraphPane)g.getCanvasPane();
  GraphView gv=gp.getGraphView();
  gv.setNodeRenderer(new ThreadRenderer());
  g.setGraphModel(model);
  LevelLayout staticLayout=new LevelLayout();
  staticLayout.setOrientation(LevelLayout.HORIZONTAL);
  staticLayout.layout(gv,model.getGraph());
  gp.repaint();
}
Program: 76413
Project: 76413
Buggy source:
/** 
 * Given two array's of probabilities, calculate the relative entropy  aka Kullback Leibler distance, D(p || q), (in bits) between the  two probability mass functions. The result will be POSITIVE_INFINITY if q has a zero probabability for a symbol for which p has a non-zero probability. The function computed is : <p> D(p||q) = - sum (p[x] * log<sup>2</sup>(p[x]/q[x])) </p>  Throw an IllegalArgumentException if either array has length 0. If the two arrays do not have the same length, throw an  IllegalArgumentException.
 * @param p An array of doubles representing the first pmf, p.
 * @param q An array of doubles representing the second pmf, q.
 * @return A double representing the relative entropy of therandom variable.
 */
public static final double relativeEntropy(double[] p,double[] q){
  int length=_commonLength(p,q,"String_Node_Str");
  double d=0.0;
  for (int i=0; i < length; i++) {
    if ((p[i] < 0.0) || (q[i] < 0.0)) {
      throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
    }
 else     if (p[i] == 0.0) {
    }
 else     if (q[i] == 0.0) {
      return Double.POSITIVE_INFINITY;
    }
 else {
      d+=p[i] * ExtendedMath.log2(p[i] / q[i]);
    }
  }
  return d;
}

Fixed version (ground truth):
/** 
 * Given two array's of probabilities, calculate the relative entropy  aka Kullback Leibler distance, D(p || q), (in bits) between the  two probability mass functions. The result will be POSITIVE_INFINITY if q has a zero probabability for a symbol for which p has a non-zero probability. The function computed is : <p> D(p||q) = - sum (p[x] * log<sup>2</sup>(p[x]/q[x])) </p>  Throw an IllegalArgumentException if either array has length 0. If the two arrays do not have the same length, throw an  IllegalArgumentException.
 * @param p An array of doubles representing the first pmf, p.
 * @param q An array of doubles representing the second pmf, q.
 * @return A double representing the relative entropy of therandom variable.
 */
public static final double relativeEntropy(double[] p,double[] q){
  _nonZeroLength(p,"String_Node_Str");
  int length=_commonLength(p,q,"String_Node_Str");
  double d=0.0;
  for (int i=0; i < length; i++) {
    if ((p[i] < 0.0) || (q[i] < 0.0)) {
      throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
    }
 else     if (p[i] == 0.0) {
    }
 else     if (q[i] == 0.0) {
      return Double.POSITIVE_INFINITY;
    }
 else {
      d+=p[i] * ExtendedMath.log2(p[i] / q[i]);
    }
  }
  return d;
}
Program: 76414
Project: 76414
Buggy source:
/** 
 * Return a new array of Gaussian distributed doubles with a given mean and standard deviation. The number of elements to allocate  is given by N. This algorithm is from [1]. Note this takes an random, unbounded amount of time!
 */
public static final double[] randomGaussian(double mean,double standardDeviation,int N){
  double t;
  double x, v1, v2, r;
  Random random=new Random();
  double[] retval=new double[N];
  for (int i=0; i < N; i+=2) {
    do {
      v1=2.0 * random.nextDouble() - 1.0;
      v2=2.0 * random.nextDouble() - 1.0;
      r=v1 * v1 + v2 * v2;
    }
 while ((r >= 1.0) && (r == 0.0));
    r=Math.sqrt((-2.0 * Math.log(r)) / r);
    retval[i]=mean + v1 * r * standardDeviation;
    if ((i + 1) < N) {
      retval[i + 1]=mean + v2 * r * standardDeviation;
    }
  }
  return retval;
}

Fixed version (ground truth):
/** 
 * Return a new array of Gaussian distributed doubles with a given mean and standard deviation. The number of elements to allocate  is given by N. This algorithm is from [1]. 
 */
public static final double[] randomGaussian(double mean,double standardDeviation,int N){
  double t;
  double x, v1, v2, r;
  Random random=new Random();
  double[] retval=new double[N];
  for (int i=0; i < N; i+=2) {
    do {
      v1=2.0 * random.nextDouble() - 1.0;
      v2=2.0 * random.nextDouble() - 1.0;
      r=v1 * v1 + v2 * v2;
    }
 while ((r >= 1.0) && (r == 0.0));
    r=Math.sqrt((-2.0 * Math.log(r)) / r);
    retval[i]=mean + v1 * r * standardDeviation;
    if ((i + 1) < N) {
      retval[i + 1]=mean + v2 * r * standardDeviation;
    }
  }
  return retval;
}
Program: 76415
Project: 76415
Buggy source:
/** 
 * Return the variance of the elements in the array. The variance is computed as follows : <p> <pre> variance = (sum(X<sup>2</sup>) - (sum(X) / N)<sup>2</sup>) / N </pre> <p> The sample variance is computed as follows : <p> <pre> variance<sub>sample</sub> = (sum(X<sup>2</sup>) - (sum(X) / N)<sup>2</sup>) / (N - 1) </pre> <p> Throw an exception if the array is of length 0, or if the sample variance is taken on an array of length less than 2.
 */
public static double variance(double[] array,boolean sample){
  if (array.length < 1) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
  if (sample && (array.length < 2)) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  }
  int length=array.length;
  double ex2=0.0;
  double sum=0.0;
  for (int i=0; i < length; i++) {
    ex2+=array[i] * array[i];
    sum+=array[i];
  }
  double norm=sample ? (length - 1) : length;
  double sumSquaredOverLength=sum * sum / length;
  return (ex2 - sumSquaredOverLength) / norm;
}

Fixed version (ground truth):
/** 
 * Return the variance of the elements in the array. The variance is computed as follows : <p> <pre> variance = (sum(X<sup>2</sup>) - (sum(X) / N)<sup>2</sup>) / N </pre> <p> The sample variance is computed as follows : <p> <pre> variance<sub>sample</sub> = (sum(X<sup>2</sup>) - (sum(X) / N)<sup>2</sup>) / (N - 1) </pre> <p> Throw an exception if the array is of length 0, or if the sample variance is taken on an array of length less than 2.
 */
public static double variance(double[] array,boolean sample){
  int length=_nonZeroLength(array,"String_Node_Str");
  if (sample && (array.length < 2)) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  }
  double ex2=0.0;
  double sum=0.0;
  for (int i=0; i < length; i++) {
    ex2+=array[i] * array[i];
    sum+=array[i];
  }
  double norm=sample ? (length - 1) : length;
  double sumSquaredOverLength=sum * sum / length;
  return (ex2 - sumSquaredOverLength) / norm;
}
Program: 76417
Project: 76417
Buggy source:
/** 
 * Construct an actor with the given container and name.
 * @param container The container.
 * @param name The name of this actor.
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public Expression(TypedCompositeActor container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  output=new TypedIOPort(this,"String_Node_Str",false,true);
  expression=new Parameter(this,"String_Node_Str");
  _time=new Variable(this,"String_Node_Str",new DoubleToken(0.0));
  _firing=new Variable(this,"String_Node_Str",new IntToken(1));
  _expression=new Variable(this,"String_Node_Str",new IntToken(1));
}

Fixed version (ground truth):
/** 
 * Construct an actor with the given container and name.
 * @param container The container.
 * @param name The name of this actor.
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public Expression(TypedCompositeActor container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  output=new TypedIOPort(this,"String_Node_Str",false,true);
  expression=new Parameter(this,"String_Node_Str");
  _time=new Variable(this,"String_Node_Str",new DoubleToken(0.0));
  _firing=new Variable(this,"String_Node_Str",new IntToken(1));
}
Program: 76418
Project: 76418
Buggy source:
/** 
 * Clone the actor into the specified workspace. This calls the base class and then creates new ports and parameters.
 * @param ws The workspace for the new object.
 * @return A new actor.
 */
public Object clone(Workspace ws){
  try {
    Expression newobj=(Expression)super.clone(ws);
    newobj._firingCount=1;
    newobj.output=(TypedIOPort)newobj.getPort("String_Node_Str");
    expression=(Parameter)newobj.getAttribute("String_Node_Str");
    newobj._time=(Variable)newobj.getAttribute("String_Node_Str");
    newobj._firing=(Variable)newobj.getAttribute("String_Node_Str");
    newobj._expression=(Variable)newobj.getAttribute("String_Node_Str");
    return newobj;
  }
 catch (  CloneNotSupportedException ex) {
    throw new InternalErrorException("String_Node_Str" + ex.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Clone the actor into the specified workspace. This calls the base class and then creates new ports and parameters.
 * @param ws The workspace for the new object.
 * @return A new actor.
 */
public Object clone(Workspace ws){
  try {
    Expression newobj=(Expression)super.clone(ws);
    newobj._firingCount=1;
    newobj.output=(TypedIOPort)newobj.getPort("String_Node_Str");
    newobj.expression=(Parameter)newobj.getAttribute("String_Node_Str");
    newobj._time=(Variable)newobj.getAttribute("String_Node_Str");
    newobj._firing=(Variable)newobj.getAttribute("String_Node_Str");
    return newobj;
  }
 catch (  CloneNotSupportedException ex) {
    throw new InternalErrorException("String_Node_Str" + ex.getMessage());
  }
}
Program: 76419
Project: 76419
Buggy source:
/** 
 * Evaluate the expression and broadcast its result to the output.
 * @exception IllegalActionException If the evaluation of the expressiontriggers it, or the evaluation yields a null result, or the evaluation yields an incompatible type, or if there is no director.
 */
public void fire() throws IllegalActionException {
  String expr=expression.getExpression();
  _expression.setExpression(expr);
  Director dir=getDirector();
  if (dir == null) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  _time.setToken(new DoubleToken(dir.getCurrentTime()));
  Enumeration inputPorts=inputPorts();
  while (inputPorts.hasMoreElements()) {
    IOPort port=(IOPort)(inputPorts.nextElement());
    if (port.hasToken(0)) {
      Token inputToken=port.get(0);
      Variable var=(Variable)(getAttribute(port.getName()));
      var.setToken(inputToken);
    }
  }
  Token result=_expression.getToken();
  if (result == null) {
    throw new IllegalActionException(this,"String_Node_Str" + _expression.getExpression());
  }
  output.broadcast(result);
}

Fixed version (ground truth):
/** 
 * Evaluate the expression and broadcast its result to the output.
 * @exception IllegalActionException If the evaluation of the expressiontriggers it, or the evaluation yields a null result, or the evaluation yields an incompatible type, or if there is no director.
 */
public void fire() throws IllegalActionException {
  Director dir=getDirector();
  if (dir == null) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  _time.setToken(new DoubleToken(dir.getCurrentTime()));
  Enumeration inputPorts=inputPorts();
  while (inputPorts.hasMoreElements()) {
    IOPort port=(IOPort)(inputPorts.nextElement());
    if (port.hasToken(0)) {
      Token inputToken=port.get(0);
      Variable var=(Variable)(getAttribute(port.getName()));
      var.setToken(inputToken);
    }
  }
  Token result=expression.getToken();
  if (result == null) {
    throw new IllegalActionException(this,"String_Node_Str" + expression.getExpression());
  }
  output.broadcast(result);
}
Program: 76420
Project: 76420
Buggy source:
/** 
 * Initialize the firing count to 1.
 * @exception IllegalActionException If the parent class throws it.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  _firingCount=1;
}

Fixed version (ground truth):
/** 
 * Initialize the firing count to 1.
 * @exception IllegalActionException If the parent class throws it.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  _firingCount=1;
  _firing.setToken(new IntToken(_firingCount));
}
Program: 76421
Project: 76421
Buggy source:
/** 
 * Return true if this receiver has a NullToken at the front  of the queue; return false otherwise.
 * @return True if this receiver contains a NullToken in theoldest queue position; return false otherwise.
 */
synchronized boolean hasNullToken(){
  if (_queue.size() <= 0) {
    return false;
  }
  if (_queue.get(0) instanceof NullToken) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Return true if this receiver has a NullToken at the front  of the queue; return false otherwise.
 * @return True if this receiver contains a NullToken in theoldest queue position; return false otherwise.
 */
synchronized boolean hasNullToken(){
  String name=((Nameable)getContainer().getContainer()).getName();
  if (_queue.size() > 0) {
    Event event=(Event)_queue.get(0);
    if (event.getToken() instanceof NullToken) {
      return true;
    }
  }
  return false;
}
Program: 76422
Project: 76422
Buggy source:
/** 
 * Put a token on the queue with the specified time stamp and set the last time value to be equal to this time stamp. If the  queue is empty immediately prior to putting the token on the queue, then set the receiver time value to be equal to the last time value. If the queue is full, throw a NoRoomException.
 * @param token The token to put on the queue.
 * @param time The time stamp of the token.
 * @exception NoRoomException If the queue is full.
 */
public void put(Token token,double time) throws NoRoomException {
  if (time < _lastTime && time != INACTIVE && time != IGNORE) {
    IOPort port=(IOPort)getContainer();
    NamedObj actor=(NamedObj)port.getContainer();
    throw new IllegalArgumentException(actor.getName() + "String_Node_Str");
  }
  Event event;
synchronized (this) {
    _lastTime=time;
    event=new Event(token,_lastTime);
    if (_queue.size() == 0) {
      _rcvrTime=_lastTime;
    }
    if (!_queue.put(event)) {
      throw new NoRoomException(getContainer(),"String_Node_Str");
    }
  }
}

Fixed version (ground truth):
/** 
 * Put a token on the queue with the specified time stamp and set the last time value to be equal to this time stamp. If the  queue is empty immediately prior to putting the token on the queue, then set the receiver time value to be equal to the last time value. If the queue is full, throw a NoRoomException.
 * @param token The token to put on the queue.
 * @param time The time stamp of the token.
 * @exception NoRoomException If the queue is full.
 */
public void put(Token token,double time) throws NoRoomException {
  if (time < _lastTime && time != INACTIVE && time != IGNORE) {
    IOPort port=(IOPort)getContainer();
    NamedObj actor=(NamedObj)port.getContainer();
    throw new IllegalArgumentException(actor.getName() + "String_Node_Str");
  }
  Event event;
synchronized (this) {
    String name=((Nameable)getContainer().getContainer()).getName();
    if (token instanceof NullToken) {
      System.out.println(name + "String_Node_Str" + name+ "String_Node_Str"+ time);
    }
 else     if (token instanceof Token) {
      System.out.println(name + "String_Node_Str" + name+ "String_Node_Str"+ time);
    }
    _lastTime=time;
    event=new Event(token,_lastTime);
    if (_queue.size() == 0) {
      _rcvrTime=_lastTime;
    }
    if (!_queue.put(event)) {
      throw new NoRoomException(getContainer(),"String_Node_Str");
    }
  }
}
Program: 76424
Project: 76424
Buggy source:
/** 
 * Invoke one iteration of the model.  An iteration consists of first performing changes queued with requestChange() and type resolution, if necessary, and then invoking prefire(), fire(), and postfire(), in that order. If prefire() returns false, then fire() and postfire() are not invoked, and true is returned. Otherwise, fire() will be called once, followed by postfire(). The return value of postfire() is returned. Note that this method ignores finish and pause requests. If you wish to use finish() or pause() to control the execution, then you should execute the model using execute(), run(), or startRun(). This method is read synchronized on the workspace.
 * @return True if postfire() returns true.
 * @exception KernelException If the model throws it, or if thereis no container, or if one of the requested changes fails.
 */
public boolean iterate() throws KernelException {
  if (_container == null) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  boolean result=true;
  try {
    workspace().getReadAccess();
    _processChangeRequests();
    if (!_typesResolved) {
      resolveTypes();
      _typesResolved=true;
    }
    _iterationCount++;
    _setState(ITERATING);
    if (!_needWriteAccess()) {
      workspace().setReadOnly(true);
    }
    if (_container.prefire()) {
      _container.fire();
      result=_container.postfire();
    }
  }
  finally {
    workspace().doneReading();
    workspace().setReadOnly(false);
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Invoke one iteration of the model.  An iteration consists of first performing changes queued with requestChange() and type resolution, if necessary, and then invoking prefire(), fire(), and postfire(), in that order. If prefire() returns false, then fire() and postfire() are not invoked, and true is returned. Otherwise, fire() will be called once, followed by postfire(). The return value of postfire() is returned. Note that this method ignores finish and pause requests. If you wish to use finish() or pause() to control the execution, then you should execute the model using execute(), run(), or startRun(). This method is read synchronized on the workspace.
 * @return True if postfire() returns true.
 * @exception KernelException If the model throws it, or if thereis no container, or if one of the requested changes fails.
 */
public boolean iterate() throws KernelException {
  if (_container == null) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  boolean result=true;
  try {
    workspace().getReadAccess();
    _processChangeRequests();
    if (!_typesResolved) {
      resolveTypes();
      _typesResolved=true;
    }
    _iterationCount++;
    _setState(ITERATING);
    if (!_needWriteAccess()) {
      workspace().setReadOnly(true);
    }
    if (_container.prefire()) {
      _container.fire();
      result=_container.postfire();
    }
  }
  finally {
    workspace().setReadOnly(false);
    workspace().doneReading();
  }
  return result;
}
Program: 76425
Project: 76425
Buggy source:
/** 
 * Wrap up the model.
 * @exception KernelException If the model throws it.
 * @exception IllegalActionException If the model is idle or alreadywrapping up, or if there is no container.
 */
public synchronized void wrapup() throws KernelException, IllegalActionException {
  if (_state == IDLE || _state == WRAPPING_UP) {
    throw new IllegalActionException(this,"String_Node_Str" + _state.getDescription());
  }
  if (_container == null) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  _setState(WRAPPING_UP);
  _container.wrapup();
  _setState(IDLE);
}

Fixed version (ground truth):
/** 
 * Wrap up the model.
 * @exception KernelException If the model throws it.
 * @exception IllegalActionException If the model is idle or alreadywrapping up, or if there is no container.
 */
public synchronized void wrapup() throws KernelException, IllegalActionException {
  if (_state == IDLE || _state == WRAPPING_UP) {
    throw new IllegalActionException(this,"String_Node_Str" + _state.getDescription());
  }
  if (_container == null) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  _setState(WRAPPING_UP);
  _container.wrapup();
  _setState(IDLE);
  workspace().doneReading();
}
Program: 76426
Project: 76426
Buggy source:
/** 
 * Set the local director for execution of this CompositeActor. Calling this method with a non-null argument makes this entity opaque. Calling it with a null argument makes it transparent. The container of the specified director is set to this composite actor, and if there was previously a local director, its container is set to null. This method is write-synchronized on the workspace.
 * @param director The Director responsible for execution.
 * @exception IllegalActionException If the director is not inthe same workspace as this actor.  It may also be throw in derived classed if the director is not compatible.
 */
public void setDirector(Director director) throws IllegalActionException {
  if (director != null && workspace() != director.workspace()) {
    throw new IllegalActionException(this,director,"String_Node_Str");
  }
  try {
    workspace().getWriteAccess();
    if (_director != null)     _director._makeDirectorOf(null);
    if (director != null) {
      director._makeDirectorOf(this);
    }
    _director=director;
  }
  finally {
    workspace().doneWriting();
  }
}

Fixed version (ground truth):
/** 
 * Set the local director for execution of this CompositeActor. Calling this method with a non-null argument makes this entity opaque. Calling it with a null argument makes it transparent. The container of the specified director is set to this composite actor, and if there was previously a local director, its container is set to null. This method is write-synchronized on the workspace.
 * @param director The Director responsible for execution.
 * @exception IllegalActionException If the director is not inthe same workspace as this actor. It may also be thrown in derived classes if the director is not compatible.
 */
public void setDirector(Director director) throws IllegalActionException {
  if (director != null && workspace() != director.workspace()) {
    throw new IllegalActionException(this,director,"String_Node_Str");
  }
  try {
    workspace().getWriteAccess();
    if (_director != null)     _director._makeDirectorOf(null);
    if (director != null) {
      director._makeDirectorOf(this);
    }
    _director=director;
  }
  finally {
    workspace().doneWriting();
  }
}
Program: 76427
Project: 76427
Buggy source:
/** 
 * Add an actor to this container with minimal error checking. This overrides the base-class method to make sure the argument implements the Actor interface and to invalidate the schedule and type resolution. This method does not alter the actor in any way. It is <i>not</i> synchronized on the workspace, so the caller should be.
 * @param entity Actor to contain.
 * @exception IllegalActionException If the actor has no name, or theaction would result in a recursive containment structure, or the argument does not implement the Actor interface.
 * @exception NameDuplicationException If the name collides with a namealready on the actor contents list.
 */
protected void _addEntity(ComponentEntity entity) throws IllegalActionException, NameDuplicationException {
  if (!(entity instanceof Actor)) {
    throw new IllegalActionException(this,entity,"String_Node_Str" + "String_Node_Str");
  }
  super._addEntity(entity);
  _director.invalidateSchedule();
  _director.invalidateResolvedTypes();
}

Fixed version (ground truth):
/** 
 * Add an actor to this container with minimal error checking. This overrides the base-class method to make sure the argument implements the Actor interface and to invalidate the schedule and type resolution. This method does not alter the actor in any way. It is <i>not</i> synchronized on the workspace, so the caller should be.
 * @param entity Actor to contain.
 * @exception IllegalActionException If the actor has no name, or theaction would result in a recursive containment structure, or the argument does not implement the Actor interface.
 * @exception NameDuplicationException If the name collides with a namealready on the actor contents list.
 */
protected void _addEntity(ComponentEntity entity) throws IllegalActionException, NameDuplicationException {
  if (!(entity instanceof Actor)) {
    throw new IllegalActionException(this,entity,"String_Node_Str" + "String_Node_Str");
  }
  super._addEntity(entity);
  if (_director != null) {
    _director.invalidateSchedule();
    _director.invalidateResolvedTypes();
  }
}
Program: 76428
Project: 76428
Buggy source:
/** 
 * Return the maximum value in the array. Throw an exception if the length of the array is 0.
 * @param array An array of doubles.
 * @return A double.
 */
public static final double max(double[] array){
  int length=_nonZeroLength(array,"String_Node_Str");
  double maxElement=array[0];
  for (int i=1; i < length; i++) {
    maxElement=Math.max(array[i],maxElement);
  }
  return maxElement;
}

Fixed version (ground truth):
/** 
 * Return the maximum value in the array. Throw an exception if the length of the array is 0.
 */
public static final double max(double[] array){
  int length=_nonZeroLength(array,"String_Node_Str");
  double maxElement=array[0];
  for (int i=1; i < length; i++) {
    maxElement=Math.max(array[i],maxElement);
  }
  return maxElement;
}
Program: 76429
Project: 76429
Buggy source:
/** 
 * Return a new array of Poisson random variables (as doubles) with  a given mean. The number of elements to allocate is given by N. This algorithm is from [1].
 * @param mean A double.
 * @param N An int indicating how many elements to generate.
 * @return A new array of doubles.
 */
public static final double[] randomPoisson(double mean,int N){
  Random random=new Random();
  double[] retval=new double[N];
  for (int i=0; i < N; i++) {
    double j;
    double u, p, f;
    j=0.0;
    f=p=Math.exp(-mean);
    u=random.nextDouble();
    while (f <= u) {
      p*=(mean / (j + 1.0));
      f+=p;
      j+=1.0;
    }
    retval[i]=j;
  }
  return retval;
}

Fixed version (ground truth):
/** 
 * Return a new array of Poisson random variables (as doubles) with  a given mean. The number of elements to allocate is given by N. This algorithm is from [1].
 */
public static final double[] randomPoisson(double mean,int N){
  Random random=new Random();
  double[] retval=new double[N];
  for (int i=0; i < N; i++) {
    double j;
    double u, p, f;
    j=0.0;
    f=p=Math.exp(-mean);
    u=random.nextDouble();
    while (f <= u) {
      p*=(mean / (j + 1.0));
      f+=p;
      j+=1.0;
    }
    retval[i]=j;
  }
  return retval;
}
Program: 76430
Project: 76430
Buggy source:
/** 
 * Return the sum of all of the elements in the array. Return 0.0 of the length of the array is 0.
 * @param array An array of doubles.
 * @return A double.
 */
public static final double sumOfElements(double[] array){
  double sum=0.0;
  for (int i=0; i < array.length; i++) {
    sum+=array[i];
  }
  return sum;
}

Fixed version (ground truth):
/** 
 * Return the sum of all of the elements in the array. Return 0.0 of the length of the array is 0.
 */
public static final double sumOfElements(double[] array){
  double sum=0.0;
  for (int i=0; i < array.length; i++) {
    sum+=array[i];
  }
  return sum;
}
Program: 76431
Project: 76431
Buggy source:
/** 
 * Given two array's of probabilities, calculate the relative entropy  aka Kullback Leibler distance, D(p || q), (in bits) between the  two probability mass functions. The result will be POSITIVE_INFINITY if q has a zero probabability for a symbol for which p has a non-zero probability. The function computed is : <p> D(p||q) = - sum (p[x] * log<sup>2</sup>(p[x]/q[x])) </p>  Throw an IllegalArgumentException if either array has length 0. If the two arrays do not have the same length, throw an  IllegalArgumentException.
 * @param p An array of doubles representing the first pmf.
 * @param q An array of doubles representing the second pmf.
 * @return A double representing the relative entropy of therandom variable.
 */
public static final double relativeEntropy(double[] p,double[] q){
  int length=_commonLength(p,q,"String_Node_Str");
  double d=0.0;
  for (int i=0; i < length; i++) {
    if ((p[i] < 0.0) || (q[i] < 0.0)) {
      throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
    }
 else     if (p[i] == 0.0) {
    }
 else     if (q[i] == 0.0) {
      return Double.POSITIVE_INFINITY;
    }
 else {
      d+=p[i] * ExtendedMath.log2(p[i] / q[i]);
    }
  }
  return d;
}

Fixed version (ground truth):
/** 
 * Given two array's of probabilities, calculate the relative entropy  aka Kullback Leibler distance, D(p || q), (in bits) between the  two probability mass functions. The result will be POSITIVE_INFINITY if q has a zero probabability for a symbol for which p has a non-zero probability. The function computed is : <p> D(p||q) = - sum (p[x] * log<sup>2</sup>(p[x]/q[x])) </p>  Throw an IllegalArgumentException if either array has length 0. If the two arrays do not have the same length, throw an  IllegalArgumentException.
 * @param p An array of doubles representing the first pmf, p.
 * @param q An array of doubles representing the second pmf, q.
 * @return A double representing the relative entropy of therandom variable.
 */
public static final double relativeEntropy(double[] p,double[] q){
  int length=_commonLength(p,q,"String_Node_Str");
  double d=0.0;
  for (int i=0; i < length; i++) {
    if ((p[i] < 0.0) || (q[i] < 0.0)) {
      throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
    }
 else     if (p[i] == 0.0) {
    }
 else     if (q[i] == 0.0) {
      return Double.POSITIVE_INFINITY;
    }
 else {
      d+=p[i] * ExtendedMath.log2(p[i] / q[i]);
    }
  }
  return d;
}
Program: 76432
Project: 76432
Buggy source:
/** 
 * Return the sum of the squares of all of the elements in the array. Return 0.0 if the length of the array is 0.
 * @param array An array of doubles.
 * @return A double.
 */
public static final double sumOfSquares(double[] array){
  double sum=0.0;
  for (int i=0; i < array.length; i++) {
    sum+=(array[i] * array[i]);
  }
  return sum;
}

Fixed version (ground truth):
/** 
 * Return the sum of the squares of all of the elements in the array. Return 0.0 if the length of the array is 0.
 */
public static final double sumOfSquares(double[] array){
  double sum=0.0;
  for (int i=0; i < array.length; i++) {
    sum+=(array[i] * array[i]);
  }
  return sum;
}
Program: 76433
Project: 76433
Buggy source:
/** 
 * Return the minimum value in the array. Throw an exception if the length of the array is 0.
 * @param array An array of doubles.
 * @param array An array of doubles.
 * @return A double.
 */
public static final double min(double[] array){
  int length=_nonZeroLength(array,"String_Node_Str");
  double minElement=array[0];
  for (int i=1; i < length; i++) {
    minElement=Math.min(array[i],minElement);
  }
  return minElement;
}

Fixed version (ground truth):
/** 
 * Return the minimum value in the array. Throw an exception if the length of the array is 0.
 */
public static final double min(double[] array){
  int length=_nonZeroLength(array,"String_Node_Str");
  double minElement=array[0];
  for (int i=1; i < length; i++) {
    minElement=Math.min(array[i],minElement);
  }
  return minElement;
}
Program: 76434
Project: 76434
Buggy source:
/** 
 * Given an array of probabilities, treated as a probability mass  function (pmf), calculate the entropy (in bits). The pmf is a discrete function that gives the probability of each element. The sum of the elements in the pmf should be 1, and each element should be between 0 and 1. This method does not check to see if the pmf is valid, except for checking that each entry is non-negative. The function computed is : <p> H(p) = - sum (p[x] * log<sup>2</sup>(p[x])) </p>  The entropy is always non-negative. Throw an IllegalArgumentException if the length of the array is 0, or a negative probability is encountered.
 * @param p An array of doubles representing the pmf.
 * @return A double.
 */
public static final double entropy(double[] p){
  int length=_nonZeroLength(p,"String_Node_Str");
  double h=0.0;
  for (int i=0; i < length; i++) {
    if (p[i] < 0.0) {
      throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
    }
 else     if (p[i] == 0.0) {
    }
 else {
      h-=p[i] * ExtendedMath.log2(p[i]);
    }
  }
  return h;
}

Fixed version (ground truth):
/** 
 * Given an array of probabilities, treated as a probability mass  function (pmf), calculate the entropy (in bits). The pmf is a discrete function that gives the probability of each element. The sum of the elements in the pmf should be 1, and each element should be between 0 and 1. This method does not check to see if the pmf is valid, except for checking that each entry is non-negative. The function computed is : <p> H(p) = - sum (p[x] * log<sup>2</sup>(p[x])) </p>  The entropy is always non-negative. Throw an IllegalArgumentException if the length of the array is 0, or a negative probability is encountered.
 */
public static final double entropy(double[] p){
  int length=_nonZeroLength(p,"String_Node_Str");
  double h=0.0;
  for (int i=0; i < length; i++) {
    if (p[i] < 0.0) {
      throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
    }
 else     if (p[i] == 0.0) {
    }
 else {
      h-=p[i] * ExtendedMath.log2(p[i]);
    }
  }
  return h;
}
Program: 76435
Project: 76435
Buggy source:
/** 
 * Return the variance of the elements in the array. The variance is computed as follows : <p> <pre> variance = (sum(X<sup>2</sup>) - sum(X)<sup>2</sup>) / N </pre> <p> The sample variance is computed as follows : <p> <pre> variance<sub>sample</sub> = (sum(X<sup>2</sup>) - sum(X)<sup>2</sup>) / (N - 1) </pre> <p> where E[X] denotes the expectation of X : Return 0.0 if the length of the array is 0.
 * @param array An array of doubles.
 * @return A double.
 */
public static double variance(double[] array,boolean sample){
  int length=array.length;
  double ex2=0.0;
  double sum=0.0;
  for (int i=0; i < length; i++) {
    ex2+=array[i] * array[i];
    sum+=array[i];
  }
  double retval=ex2 - (sum * sum);
  double norm=sample ? (length - 1) : length;
  return retval / (double)norm;
}

Fixed version (ground truth):
/** 
 * Return the variance of the elements in the array. The variance is computed as follows : <p> <pre> variance = (sum(X<sup>2</sup>) - (sum(X) / N)<sup>2</sup>) / N </pre> <p> The sample variance is computed as follows : <p> <pre> variance<sub>sample</sub> = (sum(X<sup>2</sup>) - (sum(X) / N)<sup>2</sup>) / (N - 1) </pre> <p> Throw an exception if the array is of length 0, or if the sample variance is taken on an array of length less than 2.
 */
public static double variance(double[] array,boolean sample){
  if (array.length < 1) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
  if (sample && (array.length < 2)) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  }
  int length=array.length;
  double ex2=0.0;
  double sum=0.0;
  for (int i=0; i < length; i++) {
    ex2+=array[i] * array[i];
    sum+=array[i];
  }
  double norm=sample ? (length - 1) : length;
  double sumSquaredOverLength=sum * sum / length;
  return (ex2 - sumSquaredOverLength) / norm;
}
Program: 76436
Project: 76436
Buggy source:
/** 
 * Return the arithmetic mean of the elements in the array.
 * @param array An array of doubles.
 * @return A double.
 */
public static final double mean(double[] array){
  _nonZeroLength(array,"String_Node_Str");
  return sumOfElements(array) / (double)array.length;
}

Fixed version (ground truth):
/** 
 * Return the arithmetic mean of the elements in the array.
 */
public static final double mean(double[] array){
  _nonZeroLength(array,"String_Node_Str");
  return sumOfElements(array) / (double)array.length;
}
Program: 76437
Project: 76437
Buggy source:
/** 
 * Return the product of all of the elements in the array. Return 1.0 if the length of the array is 0.
 * @param array An array of doubles.
 * @return A double.
 */
public static final double productOfElements(double[] array){
  double product=1.0;
  for (int i=0; i < array.length; i++) {
    product*=array[i];
  }
  return product;
}

Fixed version (ground truth):
/** 
 * Return the product of all of the elements in the array. Return 1.0 if the length of the array is 0.
 */
public static final double productOfElements(double[] array){
  double product=1.0;
  for (int i=0; i < array.length; i++) {
    product*=array[i];
  }
  return product;
}
Program: 76438
Project: 76438
Buggy source:
/** 
 * Return the standard deviation of the elements in the array. The standard deviation is computed as follows : <p> <pre> stdDev = sqrt(variance) </pre> <p> The sample standard deviation is computed as follows <p> <pre> stdDev = sqrt(variance<sub>sample</sub>) </pre> <p> Return 0.0 if the length of the array is 0.
 * @param array An array of doubles.
 * @param sample
 * @return A double.
 */
public static double standardDeviation(double[] array,boolean sample){
  return Math.sqrt(variance(array,sample));
}

Fixed version (ground truth):
/** 
 * Return the standard deviation of the elements in the array. The standard deviation is computed as follows : <p> <pre> stdDev = sqrt(variance) </pre> <p> The sample standard deviation is computed as follows <p> <pre> stdDev = sqrt(variance<sub>sample</sub>) </pre> <p> Throw an exception if the array is of length 0, or if the sample standard deviation is taken on an array of length less than 2.
 * @param array An array of doubles.
 * @param sample True if the sample standard devation is desired.
 * @return A double.
 */
public static double standardDeviation(double[] array,boolean sample){
  return Math.sqrt(variance(array,sample));
}
Program: 76440
Project: 76440
Buggy source:
/** 
 * Return a new array of Complex's which is the forward FFT of a real input array of doubles. This method is half as expensive as computing the FFT of a Complex array.
 * @param x An array of doubles.
 * @param order The base-2 logarithm of the size of the transform.
 * @retval A new array of Complex's.
 */
public static Complex[] FFTComplexOut(double[] x,int order){
  double[] realPart=FFTRealOut(x,order);
  double[] imagPart=FFTImagOut(x,order);
  return ComplexArrayMath.formArray(realPart,imagPart);
}

Fixed version (ground truth):
/** 
 * Return a new array of Complex's which is the forward FFT of a real input array of doubles. This method is half as expensive as computing the FFT of a Complex array.
 * @param x An array of doubles.
 * @param order The base-2 logarithm of the size of the transform.
 * @retval A new array of Complex's.
 */
public static Complex[] FFTComplexOut(double[] x,int order){
  double[] realPart=FFTRealOut(x,order);
  double[] imagPart=FFTImagOut(x,order);
  return ComplexArrayMath.formComplexArray(realPart,imagPart);
}