def test_run_until(self):
     if compare_version_numbers(libsemigroups_version(), "1.0.8"):
         ReportGuard(False)
         S = FroidurePin(Transformation([1, 0] + list(range(2, 10))))
         S.add_generator(Transformation(list(range(1, 10)) + [0]))
         S.run_until(lambda: S.current_size() > 10)
         self.assertFalse(S.finished())
         self.assertTrue(S.current_size() > 10)
         S.run_until(lambda: S.current_nr_rules() > 100)
         self.assertFalse(S.finished())
         self.assertTrue(S.current_nr_rules() > 100)
 def test_copy_constructor(self):
     S = FroidurePin(Transformation([1, 0, 1]), Transformation([0, 0, 0]))
     T = S
     self.assertTrue(T is S)
     self.assertTrue(S is T)
     T = FroidurePin(S)
     self.assertFalse(S is T)
     self.assertFalse(T is S)
     self.assertEqual(T.size(), 4)
     self.assertEqual(S.current_size(), 2)
    def test_attributes(self):
        ReportGuard(False)
        S = FroidurePin(Transformation(list(range(1, 10)) + [0]))
        self.assertEqual(S.current_nr_rules(), 0)
        self.assertEqual(S.current_size(), 1)
        self.assertEqual(S.degree(), 10)

        self.assertEqual(S.size(), 10)

        self.assertTrue(S.is_idempotent(9))
        for i in range(8):
            self.assertFalse(S.is_idempotent(i))

        with self.assertRaises(LibsemigroupsException):
            S.is_idempotent(10)

        self.assertTrue(S.is_monoid())
        self.assertEqual(S.nr_generators(), 1)
        self.assertEqual(S.nr_idempotents(), 1)
    def test_basic(self):
        ReportGuard(False)
        s1 = PythonElement(1)
        s2 = PythonElement(2)
        s3 = PythonElement(3)
        self.assertEqual(s3.get_value(), 3)
        self.assertTrue(not s1 < s1)
        self.assertTrue(s1 < s2)

        s = s2 * s3
        self.assertEqual(s.get_value(), 6)  # Fails with Sage Integers

        S = FroidurePin([s1])
        self.assertEqual(S.size(), 1)

        S = FroidurePin([s1, s2, s3])
        S.enumerate(100)
        self.assertEqual(S.current_size(), 8195)
        self.assertEqual(S.current_nr_rules(), 6)