<commit_before>class PlateViewer {
  constructor(p_xSizeAndPos){
    this.sizeAndPosition = p_xSizeAndPos;
  }

  get x(){ return this.sizeAndPosition.x; }
  get y(){ return this.sizeAndPosition.y; }
  get width(){ return this.sizeAndPosition.width; }
  get height(){ return this.sizeAndPosition.height; }
  get aspectRatio(){ return this._aspectRatioOf(this.sizeAndPosition); }

  viewPlate(plate){
    this.shapeGroup = new paper.Group();
    this.plate = plate;
    this.viewParts(plate.parts);
    this.shapeGroup.fitBounds(this.sizeAndPosition);
  }

  viewParts(parts){
    parts.forEach(p => this.viewPart(p));
  }

  viewPart(part){
    let shape = this.buildShape(part);
    shape.fillColor = this.colorFrom(part.color);
    this.shapeGroup.addChild(shape);
  }

  buildShape(shapeData){
    switch (shapeData.shape){
      case "rect": return this.viewRect(shapeData);
      default: console.log(`Unrecognized shape: ${shapeData.shape}`);
    }
  }

  viewRect(shape){
    let rect = this.rectForShape(shape);
    let newRect = new paper.Shape.Rectangle(rect);
    return newRect;
  }

  rectForShape(shape){
    let point = this.pointForShape(shape.pos);
    let size = this.sizeForShape(shape.size);
    return new paper.Rectangle(point, size);
  }

  pointForShape(pos_csv){
    var pos = this.parseNumbersFromCsv(pos_csv);
    return new paper.Point( pos[0], pos[1] );
  }

  sizeForShape(size_csv){
    var size = this.parseNumbersFromCsv(size_csv);
    return new paper.Size( size[0], size[1] );
  }

  colorFrom(colorStr){
    var colorParts = this.parseNumbersFromCsv(colorStr);
    colorParts = colorParts.map(p => p / 255.0);
    return new paper.Color(colorParts[0], colorParts[1], colorParts[2]);
  }

  parseNumbersFromCsv(str){
    return str.split(',').map(p => Number(p));
  }
}<commit_msg>paperjs/int-of-color - Fix bug related to rendering unknown shapes<commit_after>class PlateViewer {
  constructor(p_xSizeAndPos){
    this.sizeAndPosition = p_xSizeAndPos;
  }

  get x(){ return this.sizeAndPosition.x; }
  get y(){ return this.sizeAndPosition.y; }
  get width(){ return this.sizeAndPosition.width; }
  get height(){ return this.sizeAndPosition.height; }
  get aspectRatio(){ return this._aspectRatioOf(this.sizeAndPosition); }

  viewPlate(plate){
    this.shapeGroup = new paper.Group();
    this.plate = plate;
    this.viewParts(plate.parts);
    this.shapeGroup.fitBounds(this.sizeAndPosition);
  }

  viewParts(parts){
    parts.forEach(p => this.viewPart(p));
  }

  viewPart(part){
    let shape = this.buildShape(part);
    if (shape) {
      shape.fillColor = this.colorFrom(part.color);
      this.shapeGroup.addChild(shape);
    }
  }

  buildShape(shapeData){
    switch (shapeData.shape){
      case "rect": return this.viewRect(shapeData);
      default: console.log(`Unrecognized shape: ${shapeData.shape}`);
    }
  }

  viewRect(shape){
    let rect = this.rectForShape(shape);
    let newRect = new paper.Shape.Rectangle(rect);
    return newRect;
  }

  rectForShape(shape){
    let point = this.pointForShape(shape.pos);
    let size = this.sizeForShape(shape.size);
    return new paper.Rectangle(point, size);
  }

  pointForShape(pos_csv){
    var pos = this.parseNumbersFromCsv(pos_csv);
    return new paper.Point( pos[0], pos[1] );
  }

  sizeForShape(size_csv){
    var size = this.parseNumbersFromCsv(size_csv);
    return new paper.Size( size[0], size[1] );
  }

  colorFrom(colorStr){
    var colorParts = this.parseNumbersFromCsv(colorStr);
    colorParts = colorParts.map(p => p / 255.0);
    return new paper.Color(colorParts[0], colorParts[1], colorParts[2]);
  }

  parseNumbersFromCsv(str){
    return str.split(',').map(p => Number(p));
  }
}
{'fraction_non_alphanumeric': 0.1400862068965517, 'fraction_numerical': 0.005926724137931034, 'mean_word_length': 3.7786357786357785, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '525407', 'n_tokens_mistral': 1286, 'n_tokens_neox': 1240, 'n_words': 229}