def test_factorisation(self): S = FroidurePin(Transformation([1, 0, 1]), Transformation([0, 0, 0])) self.assertEqual(S.size(), 4) self.assertEqual(std.distance(S.cbegin(), S.cend()), S.size()) self.assertEqual( [S.factorisation(x) for x in range(S.size())], [[0], [1], [0, 0], [1, 0]] ) with self.assertRaises(LibsemigroupsCppyyException): S.factorisation(4) # check again because of some bug in an early version of # unwrap(_return_value) self.assertEqual( [S.factorisation(x) for x in range(S.size())], [[0], [1], [0, 0], [1, 0]] ) with self.assertRaises(LibsemigroupsCppyyException): S.factorisation(Transformation([1, 1, 2])) self.assertEqual(std.distance(S.cbegin(), S.cend()), S.size()) self.assertEqual([S.factorisation(x) for x in S], [[0], [1], [0, 0], [1, 0]])
def test10_vector_std_distance(self): """Use of std::distance with vector""" import cppyy from cppyy.gbl import std v = std.vector[int]([1, 2, 3]) assert v.size() == 3 assert std.distance(v.begin(), v.end()) == v.size() assert std.distance[type(v).iterator](v.begin(), v.end()) == v.size()
def test_aaa_bug(self): ReportGuard(False) S = FroidurePin(Transformation([1, 0, 1]), Transformation([0, 0, 0])) S.run() self.assertEqual(std.distance(S.cbegin(), S.cend()), 4) self.assertEqual( list(S), [ Transformation([1, 0, 1]), Transformation([0, 0, 0]), Transformation([0, 1, 0]), Transformation([1, 1, 1]), ], )
def test_bug1_works_zno(self): S = FpSemigroup() S.set_alphabet("01") S.add_rule("000", "0") S.add_rule("1111", "1") S.add_rule("01110", "00") S.add_rule("1001", "11") S.add_rule("001010101010", "00") S.run() S.rules() S = FroidurePin(Transformation([1, 0, 1]), Transformation([0, 0, 0])) self.assertEqual(S.size(), 4) self.assertEqual(std.distance(S.cbegin(), S.cend()), S.size())
def test_idempotents(self): S = FroidurePin(Transformation([1, 0, 1]), Transformation([0, 0, 0])) S.run() self.assertEqual( std.distance(S.cbegin_idempotents(), S.cend_idempotents()), S.nr_idempotents(), ) self.assertEqual( list(S.idempotents()), [ Transformation([0, 0, 0]), Transformation([0, 1, 0]), Transformation([1, 1, 1]), ], )