<commit_before>defmodule TestPolygon do
  use ExSpec, async: true

  doctest Collidex.Geometry.Polygon
  alias Collidex.Geometry.Polygon

  describe "make" do
    context "from a list of points" do
      poly = Polygon.make([{0,0}, {1,0}, {1,1}, {1.5,0.5}, {1,0}])
      assert is_map(poly) == true
      assert poly == %Polygon{ vertices: [{0,0}, {1,0}, {1,1}, {1.5,0.5}, {1,0}] }
    end
  end

  describe "center" do
    context "of a rectangle" do
      {x, y} = Polygon.center(Polygon.make([{1,1}, {1,-1}, {-1,-1}, {-1, 1}]))
      assert_in_delta(x, 0.0, 0.00001)
      assert_in_delta(y, 0.0, 0.00001)
    end
  end

end<commit_msg>add a pentagon test for polygon centroid<commit_after>defmodule TestPolygon do
  use ExSpec, async: true

  doctest Collidex.Geometry.Polygon
  alias Collidex.Geometry.Polygon

  describe "make" do
    context "from a list of points" do
      poly = Polygon.make([{0,0}, {1,0}, {1,1}, {1.5,0.5}, {1,0}])
      assert is_map(poly) == true
      assert poly == %Polygon{ vertices: [{0,0}, {1,0}, {1,1}, {1.5,0.5}, {1,0}] }
    end
  end

  describe "center" do
    context "of a rectangle" do
      {x, y} = Polygon.center(Polygon.make([{1,1}, {1,-1}, {-1,-1}, {-1, 1}]))
      assert_in_delta(x, 0.0, 0.00001)
      assert_in_delta(y, 0.0, 0.00001)
    end
    context "of a regular pentagon centered on 1,1" do
      {x,y} = Polygon.center(Polygon.make([{1.2150,1.0}, {1.0664, 0.7955}, {0.8261, 0.8736}, {0.8261, 1.1264}, {1.0664, 1.2045}]))
      assert_in_delta(x, 1.0, 0.00001)
      assert_in_delta(y, 1.0, 0.00001)
    end
  end

end
{'fraction_non_alphanumeric': 0.1876981610653139, 'fraction_numerical': 0.10209258084971465, 'mean_word_length': 3.0255102040816326, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3092162', 'n_tokens_mistral': 733, 'n_tokens_neox': 660, 'n_words': 161}