<commit_before>(function() {
  var φ = 1.618033988749895,
      ρ = 180 / Math.PI;

  var vertices = [
    [1,φ,0], [-1,φ,0], [1,-φ,0], [-1,-φ,0],
    [0,1,φ], [0,-1,φ], [0,1,-φ], [0,-1,-φ],
    [φ,0,1], [-φ,0,1], [φ,0,-1], [-φ,0,-1]
  ];

  var triangles = [
    [0,1,4],  [1,9,4],  [4,9,5],  [5,9,3],  [2,3,7],
    [3,2,5],  [7,10,2], [0,8,10], [0,4,8],  [8,2,10],
    [8,4,5],  [8,5,2],  [1,0,6],  [11,1,6], [3,9,11],
    [6,10,7], [3,11,7], [11,6,7], [6,0,10], [9,1,11]
  ].map(function(triangle) {
    return triangle.map(function(i) {
      return vertices[i];
    });
  });

  d3.geodesic = function(s) {
    return {
      type: "MultiPolygon",
      coordinates: geodesic(Math.round(s)).map(function(triangle) {
        triangle = triangle.map(project);
        triangle.push(triangle[2]);
        return [triangle];
      })
    };
  };

  function geodesic(n) {
    return d3.merge(triangles.map(function(triangle) {
      var i01 = interpolate(triangle[0], triangle[1]),
          i02 = interpolate(triangle[0], triangle[2]),
          triangles = [];

      triangles.push([
        triangle[0],
        i01(1 / n),
        i02(1 / n)
      ]);

      for (var i = 1; i < n; ++i) {
        var i1 = interpolate(i01(i / n), i02(i / n)),
            i2 = interpolate(i01((i + 1) / n), i02((i + 1) / n));
        for (var j = 0; j <= i; ++j) {
          triangles.push([
            i1(j / i),
            i2(j / (i + 1)),
            i2((j + 1) / (i + 1))
          ]);
        }
      }

      return triangles;
    }));
  }

  function interpolate(p0, p1) {
    var x0 = p0[0],
        y0 = p0[1],
        z0 = p0[2],
        x1 = p1[0] - x0,
        y1 = p1[1] - y0,
        z1 = p1[2] - z0;
    return function(t) {
      return [
        x0 + t * x1,<commit_msg>Add d3.geodesic.polygons method.<commit_after>(function() {
  var φ = 1.618033988749895,
      ρ = 180 / Math.PI;

  var vertices = [
    [1,φ,0], [-1,φ,0], [1,-φ,0], [-1,-φ,0],
    [0,1,φ], [0,-1,φ], [0,1,-φ], [0,-1,-φ],
    [φ,0,1], [-φ,0,1], [φ,0,-1], [-φ,0,-1]
  ];

  var triangles = [
    [0,1,4],  [1,9,4],  [4,9,5],  [5,9,3],  [2,3,7],
    [3,2,5],  [7,10,2], [0,8,10], [0,4,8],  [8,2,10],
    [8,4,5],  [8,5,2],  [1,0,6],  [11,1,6], [3,9,11],
    [6,10,7], [3,11,7], [11,6,7], [6,0,10], [9,1,11]
  ].map(function(triangle) {
    return triangle.map(function(i) {
      return vertices[i];
    });
  });

  d3.geodesic = {
    multipolygon: function(n) {
      return {
        type: "MultiPolygon",
        coordinates: geodesic(~~n).map(function(triangle) {
          triangle = triangle.map(project);
          triangle.push(triangle[2]);
          return [triangle];
        })
      };
    },
    polygons: function(n) {
      return geodesic(~~n).map(function(triangle) {
        triangle = triangle.map(project);
        triangle.push(triangle[2]);
        return {type: "Polygon", coordinates: [triangle]};
      });
    }
  };

  function geodesic(n) {
    return d3.merge(triangles.map(function(triangle) {
      var i01 = interpolate(triangle[0], triangle[1]),
          i02 = interpolate(triangle[0], triangle[2]),
          triangles = [];

      triangles.push([
        triangle[0],
        i01(1 / n),
        i02(1 / n)
      ]);

      for (var i = 1; i < n; ++i) {
        var i1 = interpolate(i01(i / n), i02(i / n)),
            i2 = interpolate(i01((i + 1) / n), i02((i + 1) / n));
        for (var j = 0; j <= i; ++j) {
          triangles.push([
            i1(j / i),
            i2(j / (i + 1)),
            i2((j + 1) / (i + 1))
          ]);
        }
        for (var j = 0; j < i; ++j) {
          triangles.push([
            i1(j / i),
            i1((j + 1) / i),
            i2((j + 1) / (i + 1))
          ]);
        }
      }

      return triangles;
    }));
  }

  function interpolate(p0, p1) {
    var x0 = p0[0],
        y0 = p0[1],
        z0 = p0[2],
        x1 = p1[0] - x0,
        y1 = p1[1] - y0,
        z1 = p1[2] - z0;
    return function(t) {
      return [
        x0 + t * x1,
{'fraction_non_alphanumeric': 0.22808764940239043, 'fraction_numerical': 0.08989043824701196, 'mean_word_length': 1.7627235213204953, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 3, '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': '5962533', 'n_tokens_mistral': 1828, 'n_tokens_neox': 1693, 'n_words': 315}