<commit_before>// Peity jQuery plugin version 0.6.1
// (c) 2012 <NAME>
//
// http://benpickles.github.com/peity
//
// Released under MIT license.
(function($, document) {
  var canvasSupported = document.createElement("canvas").getContext
  var devicePixelRatio = window.devicePixelRatio || 1

  var peity = $.fn.peity = function(type, options) {
    if (canvasSupported) {
      this.each(function() {
        var defaults = Peity.defaults[type]
        var opts = $.extend({}, defaults, options)
        var $this = $(this)

        $.each($this.data(), function(name, value) {
          if (name in defaults) opts[name] = value
        })

        var chart = new Peity($this, type, opts)
        chart.draw()

        $this.change(function() {
          chart.draw()
        })
      });
    }

    return this;
  };

  function createCanvas(width, height) {
    var canvas = $("<canvas>").attr({
      height: height * devicePixelRatio,
      width: width * devicePixelRatio
    })

    if (devicePixelRatio != 1) {
      canvas.css({
        height: height,
        width: width
      })
    }

    return canvas[0]
  }
  peity.createCanvas = createCanvas;

  var Peity = function($elem, type, opts) {
    this.$elem = $elem
    this.type = type
    this.opts = opts
  }

  Peity.prototype.draw = function() {
    Peity.graphers[this.type].call(this, this.opts)
  }

  Peity.prototype.prepareCanvas = function(width, height) {
    var canvas = this.canvas

    if (canvas) {
      this.context.clearRect(0, 0, canvas.width, canvas.height)
    } else {
      this.canvas = canvas = createCanvas(width, height)
      this.$elem.hide().before(canvas)
      this.context = canvas.getContext("2d")
    }

    return canvas
  }

  Peity.prototype.values = function() {
    return this.$elem.text().split(this.opts.delimiter)
  }

  Peity.graphers = {}
  Peity.defaults = {}

  Peity.register = function(type, defaults, grapher) {
    this.defaults[type] = defaults
    this.graphers[type] = grapher
  }

  Peity.register(
    'pie',
    {
      colours: ['#FFF4DD', '#FF9900'],
      delimiter: '/',
      diameter: 16
    },
    function(opts) {
      var values = this.values()
      var v1 = parseFloat(values[0]);
      var v2 = parseFloat(values[1]);
      var slice = (v1 / v2) * Math.PI * 2;

      var canvas = this.prepareCanvas(opts.diameter, opts.diameter)
      var context = this.context
      var half = canvas.width / 2

      context.translate(half, half)<commit_msg>Don't bother with parseFloat here as it's not being used elsewhere.<commit_after>// Peity jQuery plugin version 0.6.1
// (c) 2012 <NAME>
//
// http://benpickles.github.com/peity
//
// Released under MIT license.
(function($, document) {
  var canvasSupported = document.createElement("canvas").getContext
  var devicePixelRatio = window.devicePixelRatio || 1

  var peity = $.fn.peity = function(type, options) {
    if (canvasSupported) {
      this.each(function() {
        var defaults = Peity.defaults[type]
        var opts = $.extend({}, defaults, options)
        var $this = $(this)

        $.each($this.data(), function(name, value) {
          if (name in defaults) opts[name] = value
        })

        var chart = new Peity($this, type, opts)
        chart.draw()

        $this.change(function() {
          chart.draw()
        })
      });
    }

    return this;
  };

  function createCanvas(width, height) {
    var canvas = $("<canvas>").attr({
      height: height * devicePixelRatio,
      width: width * devicePixelRatio
    })

    if (devicePixelRatio != 1) {
      canvas.css({
        height: height,
        width: width
      })
    }

    return canvas[0]
  }
  peity.createCanvas = createCanvas;

  var Peity = function($elem, type, opts) {
    this.$elem = $elem
    this.type = type
    this.opts = opts
  }

  Peity.prototype.draw = function() {
    Peity.graphers[this.type].call(this, this.opts)
  }

  Peity.prototype.prepareCanvas = function(width, height) {
    var canvas = this.canvas

    if (canvas) {
      this.context.clearRect(0, 0, canvas.width, canvas.height)
    } else {
      this.canvas = canvas = createCanvas(width, height)
      this.$elem.hide().before(canvas)
      this.context = canvas.getContext("2d")
    }

    return canvas
  }

  Peity.prototype.values = function() {
    return this.$elem.text().split(this.opts.delimiter)
  }

  Peity.graphers = {}
  Peity.defaults = {}

  Peity.register = function(type, defaults, grapher) {
    this.defaults[type] = defaults
    this.graphers[type] = grapher
  }

  Peity.register(
    'pie',
    {
      colours: ['#FFF4DD', '#FF9900'],
      delimiter: '/',
      diameter: 16
    },
    function(opts) {
      var values = this.values()
      var v1 = values[0]
      var v2 = values[1]
      var slice = (v1 / v2) * Math.PI * 2;

      var canvas = this.prepareCanvas(opts.diameter, opts.diameter)
      var context = this.context
      var half = canvas.width / 2

      context.translate(half, half)
{'fraction_non_alphanumeric': 0.14156988386063277, 'fraction_numerical': 0.011213456147376852, 'mean_word_length': 2.4025885558583107, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '297311', 'n_tokens_mistral': 1632, 'n_tokens_neox': 1570, 'n_words': 357}