<commit_before>########################################################################
#                                                                      #
#   Test Script for lib/finite-group.rb                                #
#                                                                      #
########################################################################
require "rubyunit"
require "algebra/finite-group"
require "algebra/permutation-group"

include Algebra
PG = PermutationGroup
P = Permutation
S5 = PG.symmetric(5)
A5 = PG.alternate(5)
S4 = PG.symmetric(4)
A4 = PG.alternate(4)
S3 = PG.symmetric(3)
A3 = PG.alternate(3)
T3 = PG[PG.unity(3), P[0, 2, 1]]
S2 = PG.symmetric(2)
e = P.unity(4)
a = P[1, 0, 2, 3]
b = P[0, 1, 3, 2]
A = PG[e, a]
B = PG[e, b]
C = PG[e, a, b, a*b]

class Rational;def inspect; to_s; end;end

class TestFiniteGroup < Test::Unit::TestCase
  #Operator Domain
  def test__star #test for *
    ab = A * B
    assert_equal(ab.class, Set)
    assert_equal(ab, C)
  end

  def test__slash #test for /
    s = S3 / S2
    t = Set[
      Set[P[1, 2, 0], P[0, 2, 1]],
      Set[P[0, 1, 2], P[1, 0, 2]],
      Set[P[2, 1, 0], P[2, 0, 1]]
    ]
    assert_equal(s, t)
  end

  def test__parcent #test for %
    s = S3 % S2
    t6 = Set[P[0, 2, 1], P[2, 1, 0], P[0, 1, 2]]
    t7 = Set[P[2, 1, 0], P[1, 0, 2], P[1, 2, 0]]
    # assert(s == t6 || s == t7, "S3 = #{S3}, S2 = #{S2}, s = #{s}, t6 = #{t6}, t7 = #{t7}")
    assert(true)
  end

  def test_orbit! #test for orbit!
    e = P.unity(4)
    a = P[1, 0, 2, 3]
    b = P[0, 1, 3, 2]
    x = PG[e, a]
    y = PG[e, b]
    x.orbit!(y)
    assert_equal(x, PG[e, a, b, a*b])
  end

  def test_initialize #test for initialize
    e = P.unity(4)
    a = P[1, 0, 2, 3]
    assert_equal(PG[e, a].size, 2)
  end

  def test_set_unity #test for set_unity
    e = P.unity(4)<commit_msg>fix test__parcent for finite-group.<commit_after>########################################################################
#                                                                      #
#   Test Script for lib/finite-group.rb                                #
#                                                                      #
########################################################################
require "rubyunit"
require "algebra/finite-group"
require "algebra/permutation-group"

include Algebra
PG = PermutationGroup
P = Permutation
S5 = PG.symmetric(5)
A5 = PG.alternate(5)
S4 = PG.symmetric(4)
A4 = PG.alternate(4)
S3 = PG.symmetric(3)
A3 = PG.alternate(3)
T3 = PG[PG.unity(3), P[0, 2, 1]]
S2 = PG.symmetric(2)
e = P.unity(4)
a = P[1, 0, 2, 3]
b = P[0, 1, 3, 2]
A = PG[e, a]
B = PG[e, b]
C = PG[e, a, b, a*b]

class Rational;def inspect; to_s; end;end

class TestFiniteGroup < Test::Unit::TestCase
  #Operator Domain
  def test__star #test for *
    ab = A * B
    assert_equal(ab.class, Set)
    assert_equal(ab, C)
  end

  def test__slash #test for /
    s = S3 / S2
    t = Set[
      Set[P[1, 2, 0], P[0, 2, 1]],
      Set[P[0, 1, 2], P[1, 0, 2]],
      Set[P[2, 1, 0], P[2, 0, 1]]
    ]
    assert_equal(s, t)
  end

  def test__parcent #test for %
    s = S3 % S2
    t6 = Set[P[0, 2, 1], P[2, 1, 0], P[0, 1, 2]]
    t7 = Set[P[2, 1, 0], P[1, 0, 2], P[1, 2, 0]]
    # assert(s == t6 || s == t7, "S3 = #{S3}, S2 = #{S2}, s = #{s}, t6 = #{t6}, t7 = #{t7}")
    assert_not_equal(Set.phi, s & Set[P[2, 1, 0], P[2, 0 ,1]])
    assert(! s.superset?(Set[P[2, 1, 0], P[2, 0, 1]]))
    assert_not_equal(Set.phi, s & Set[P[1, 0, 2], P[0, 1, 2]])
    assert(! s.superset?(Set[P[1, 0, 2], P[0, 1, 2]]))
    assert_not_equal(Set.phi, s & Set[P[1, 2, 0], P[0, 2, 1]])
    assert(! s.superset?(Set[P[1, 2, 0], P[0, 2, 1]]))
  end

  def test_orbit! #test for orbit!
    e = P.unity(4)
    a = P[1, 0, 2, 3]
    b = P[0, 1, 3, 2]
    x = PG[e, a]
    y = PG[e, b]
    x.orbit!(y)
    assert_equal(x, PG[e, a, b, a*b])
  end

  def test_initialize #test for initialize
    e = P.unity(4)
    a = P[1, 0, 2, 3]
    assert_equal(PG[e, a].size, 2)
  end

  def test_set_unity #test for set_unity
    e = P.unity(4)
{'fraction_non_alphanumeric': 0.24150574431679295, 'fraction_numerical': 0.055732094842336835, 'mean_word_length': 2.2144540455616655, 'pattern_counts': {'":': 0, '<': 5, '<?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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5272391', 'n_tokens_mistral': 1804, 'n_tokens_neox': 1660, 'n_words': 460}