diff --git a/src/aho-corasick.cpp b/src/aho-corasick.cpp index 4dd51993b..7560f5e71 100644 --- a/src/aho-corasick.cpp +++ b/src/aho-corasick.cpp @@ -74,12 +74,17 @@ Construct an :any:`AhoCorasick` containing only the root that corresponds to the empty word :math:`\varepsilon`.)pbdoc"); thing.def( - "__copy__", - [](const AhoCorasick& that) { return AhoCorasick(that); }, + "copy", + [](AhoCorasick const& self) { return AhoCorasick(self); }, R"pbdoc( -Default copy constructor. +:sig=(self: AhoCorasick) -> AhoCorasick: -Default copy constructor)pbdoc"); +Copy a :any:`AhoCorasick` object. + +:returns: A copy. +:rtype: AhoCorasick)pbdoc"); + thing.def("__copy__", + [](AhoCorasick const& self) { return AhoCorasick(self); }); thing.def("child", &AhoCorasick::child, diff --git a/src/bmat8.cpp b/src/bmat8.cpp index 4dd46d807..5f08cb500 100644 --- a/src/bmat8.cpp +++ b/src/bmat8.cpp @@ -203,9 +203,6 @@ lists in ``rows``. R"pbdoc( Copy a BMat8. -:param other: the BMat8 to copy. -:type other: BMat8 - :returns: A copy of the argument. :rtype: BMat8 )pbdoc"); diff --git a/src/dot.cpp b/src/dot.cpp index bcf1158c8..afb81989c 100644 --- a/src/dot.cpp +++ b/src/dot.cpp @@ -64,6 +64,17 @@ Default constructor that constructs an empty :any:`Dot` object with no nodes, edges, attributes, or subgraphs. )pbdoc"); dot.def("__copy__", [](Dot const& d) { return Dot(d); }); + dot.def( + "copy", + [](Dot const& d) { return Dot(d); }, + R"pbdoc( +:sig=(self: Dot) -> Dot: + +Copy a :any:`Dot` object. + +:returns: A copy. +:rtype: Dot +)pbdoc"); dot.def("add_node", &Dot::add_node, diff --git a/src/froidure-pin.cpp b/src/froidure-pin.cpp index 1967dfd2c..8caf5d5c7 100644 --- a/src/froidure-pin.cpp +++ b/src/froidure-pin.cpp @@ -369,8 +369,8 @@ instance and ``False`` if it does not. Copy and add a list of generators. -This function is equivalent to copy constructing a new :any:`FroidurePin` -instance and then calling :any:`FroidurePin.add_generators` on the copy. +This function is equivalent to copying a :any:`FroidurePin` +instance and then calling :any:`FroidurePin.add_generators` on the copy. But this function avoids copying the parts of the initial instance that are immediately invalidated by :any:`FroidurePin.add_generators`. @@ -403,7 +403,7 @@ immediately invalidated by :any:`FroidurePin.add_generators`. Copy and add non-redundant generators. -This function is equivalent to copy constructing a new :any:`FroidurePin` +This function is equivalent to copying a :any:`FroidurePin` instance and then calling :any:`closure` on the copy. But this function avoids copying the parts of the initial :any:`FroidurePin` instance that are immediately discarded by :any:`closure`. diff --git a/src/gabow.cpp b/src/gabow.cpp index 9998de0d6..eb728ab88 100644 --- a/src/gabow.cpp +++ b/src/gabow.cpp @@ -68,6 +68,17 @@ at most :math:`O(mn)` where ``m`` is :any:`WordGraph.number_of_nodes()` and thing.def("__repr__", [](Gabow_ const& g) { return to_human_readable_repr(g); }); thing.def("__copy__", [](Gabow_ const& g) { return Gabow_(g); }); + thing.def( + "copy", + [](Gabow_ const& self) { return Gabow_(self); }, + R"pbdoc( +:sig=(self: Gabow) -> Gabow: + +Copy a :any:`Gabow` object. + +:returns: A copy. +:rtype: Gabow +)pbdoc"); thing.def(py::init const&>(), py::arg("wg"), R"pbdoc( diff --git a/src/knuth-bendix.cpp b/src/knuth-bendix.cpp index f9bab3d7c..175846944 100644 --- a/src/knuth-bendix.cpp +++ b/src/knuth-bendix.cpp @@ -359,9 +359,20 @@ redundant in this way, then ``None`` is returned. return to_human_readable_repr(nfr); }); - thing.def("__copy__", [](NormalFormRange const& nfr) { - return NormalFormRange(nfr); + thing.def("__copy__", [](NormalFormRange const& self) { + return NormalFormRange(self); }); + thing.def( + "copy", + [](NormalFormRange const& self) { return NormalFormRange(self); }, + R"pbdoc( +:sig=(self: NormalFormRange) -> NormalFormRange: + +Copy a :any:`NormalFormRange` object. + +:returns: A copy. +:rtype: NormalFormRange +)pbdoc"); // __len__ is not allowed to return anything other than an int, hence // __len__ and count don't have the same behaviour. thing.def("__len__", [](NormalFormRange const& nfr) { diff --git a/src/konieczny.cpp b/src/konieczny.cpp index ee710353f..cb1dd59e4 100644 --- a/src/konieczny.cpp +++ b/src/konieczny.cpp @@ -68,9 +68,6 @@ the size, partial order of :math:`\mathscr{D}`-classes, and frames for each :sig=(self: Konieczny) -> Konieczny: Copy a Konieczny. -:param other: the Konieczny to copy. -:type other: Konieczny - :returns: A copy of the argument. :rtype: Konieczny )pbdoc"); diff --git a/src/paths.cpp b/src/paths.cpp index 2b3c7e05a..3a0c1cf80 100644 --- a/src/paths.cpp +++ b/src/paths.cpp @@ -66,6 +66,17 @@ paths in a :any:`WordGraph` from a given :any:`source` (to a possible thing1.def("__repr__", [](Paths_ const& p) { return to_human_readable_repr(p); }); thing1.def("__copy__", [](Paths_ const& p) { return Paths_(p); }); + thing1.def( + "copy", + [](Paths_ const& self) { return Paths_(self); }, + R"pbdoc( +:sig=(self: Paths) -> Paths: + +Copy a :any:`Paths` object. + +:returns: A copy. +:rtype: Paths +)pbdoc"); thing1.def("__or__", [](Paths_ const& p, ToString const& to_str) { using rx::operator|; return p | to_str; diff --git a/src/present.cpp b/src/present.cpp index 3fa91c84c..189cc6f1b 100644 --- a/src/present.cpp +++ b/src/present.cpp @@ -91,12 +91,18 @@ Default constructor. Constructs an empty presentation with no rules and no alphabet.)pbdoc"); thing.def( - "__copy__", - [](const Presentation_& that) { return Presentation_(that); }, + "copy", + [](Presentation_ const& self) { return Presentation_(self); }, R"pbdoc( -Default copy constructor. +:sig=(self: Presentation) -> Presentation: + +Copy a :any:`Presentation` object. -Default copy constructor)pbdoc"); +:returns: A copy. +:rtype: Presentation +)pbdoc"); + thing.def("__copy__", + [](Presentation_ const& that) { return Presentation_(that); }); thing.def( "alphabet", [](Presentation_ const& self) { return self.alphabet(); }, @@ -1289,14 +1295,22 @@ Default constructor. Constructs an empty :any:`InversePresentation` with no rules, no alphabet and no inverses.)pbdoc"); thing.def( - "__copy__", - [](const InversePresentation_& that) { - return InversePresentation_(that); + "copy", + [](InversePresentation_ const& self) { + return InversePresentation_(self); }, R"pbdoc( -Default copy constructor. +:sig=(self: InversePresentation) -> InversePresentation: + +Copy a :any:`InversePresentation` object. + +:returns: A copy. +:rtype: InversePresentation +)pbdoc"); + thing.def("__copy__", [](InversePresentation_ const& that) { + return InversePresentation_(that); + }); -Default copy constructor)pbdoc"); thing.def("inverse", &InversePresentation_::inverse, py::arg("x"), diff --git a/src/runner.cpp b/src/runner.cpp index 3eaa1939e..16036c4c9 100644 --- a/src/runner.cpp +++ b/src/runner.cpp @@ -73,9 +73,18 @@ Default construct a :any:`Reporter` object such that the following hold: - :any:`last_report()` is now; - :any:`start_time()` is now. )pbdoc"); - thing.def(py::init(), R"pbdoc( -Default copy constructor. + thing.def( + "copy", + [](Reporter const& self) { return Reporter(self); }, + R"pbdoc( +:sig=(self: Reporter) -> Reporter: + +Copy a :any:`Reporter` object. + +:returns: A copy. +:rtype: Reporter )pbdoc"); + thing.def("__copy__", [](Reporter const& self) { return Reporter(self); }); thing.def( "init", [](Reporter& r) -> Reporter& { return r.init(); }, diff --git a/src/schreier-sims.cpp b/src/schreier-sims.cpp index fb1b939b3..492ecd55b 100644 --- a/src/schreier-sims.cpp +++ b/src/schreier-sims.cpp @@ -79,19 +79,16 @@ the list *gens*. )pbdoc"); thing.def("__copy__", - [](const SchreierSims_& that) { return SchreierSims_(that); }); + [](SchreierSims_ const& self) { return SchreierSims_(self); }); thing.def( "copy", - [](SchreierSims_ const& S) { return SchreierSims_(S); }, + [](SchreierSims_ const& self) { return SchreierSims_(self); }, R"pbdoc( :sig=(self: SchreierSims) -> SchreierSims: Copy a :any:`SchreierSims`. -:param other: the :any:`SchreierSims` to copy. -:type other: SchreierSims - -:returns: A copy of the argument. +:returns: A copy. :rtype: SchreierSims )pbdoc"); thing.def("add_base_point", diff --git a/src/sims.cpp b/src/sims.cpp index 415a532dd..9c09b75f1 100644 --- a/src/sims.cpp +++ b/src/sims.cpp @@ -589,17 +589,16 @@ Default constructor. Constructs a :any:`SimsStats` object with all statistics set to zero. )pbdoc"); - st.def(py::init(), - py::arg("that"), - R"pbdoc( -Copy constructor. - -This function returns a :any:`SimsStats` object that is a copy of *that*. The -state of the new :any:`SimsStats` object is the same as *that*. This triggers -an atomic load on the member variables of *that*. + st.def("__copy__", [](SimsStats const& self) { return SimsStats(self); }); + st.def( + "copy", + [](SimsStats const& self) { return SimsStats(self); }, + R"pbdoc( +Copy a :any:`SimsStats` object. -:param that: the :any:`SimsStats` to copy. -:type that: SimsStats +This function returns a :any:`SimsStats` object that is a copy of *self*. The +state of the new :any:`SimsStats` object is the same as *self*. This triggers +an atomic load on the member variables of *self*. )pbdoc"); st.def( diff --git a/src/stephen.cpp b/src/stephen.cpp index 5e793a5c6..4d8f90c48 100644 --- a/src/stephen.cpp +++ b/src/stephen.cpp @@ -91,10 +91,10 @@ This function constructs :any:`Stephen` from a presentation. R"pbdoc( :sig=(self: Stephen) -> Stephen: -This function costructs a :any:`Stephen` object by copying another :any:`Stephen` object. +This function returns a copy of a :any:`Stephen` object. -:param s: the :any:`Stephen` object to copy. -:type s: Stephen +:returns: A copy. +:rtype: Stephen )pbdoc"); thing.def("accept_state", &Stephen_::accept_state, diff --git a/src/transf.cpp b/src/transf.cpp index 325cc17df..c8d82c76e 100644 --- a/src/transf.cpp +++ b/src/transf.cpp @@ -127,9 +127,6 @@ the image of the point ``i`` under the {0} is ``imgs[i]``. :sig=(self: {1}) -> {1}: Copy a {0}. -:param self: the {0} to copy. -:type self: {1} - :returns: A copy of the argument. :rtype: {1} )pbdoc", diff --git a/src/ukkonen.cpp b/src/ukkonen.cpp index 9fe4f99e9..a1a288819 100644 --- a/src/ukkonen.cpp +++ b/src/ukkonen.cpp @@ -581,8 +581,17 @@ Construct from index and position. :param ppos: the position in the edge leading to vv. :type ppos: int )pbdoc"); - state.def(py::init(), R"pbdoc( -Default copy constructor.)pbdoc"); + state.def( + "copy", + [](Ukkonen::State const& self) { return Ukkonen::State(self); }, + R"pbdoc( +:sig=(self: Ukkonen.State) -> Ukkonen.State: + +Copy a :any:`Ukkonen.State` object. + +:returns: A copy. +:rtype: Ukkonen.State +)pbdoc"); state.def("__copy__", [](Ukkonen::State const& that) { return Ukkonen::State(that); }); state.def(py::self == py::self, py::arg("that")); @@ -639,8 +648,16 @@ Construct a node from left most index, right most index, and parent. )pbdoc"); node.def("__copy__", [](Ukkonen::Node const& that) { return Ukkonen::Node(that); }); - node.def(py::init(), R"pbdoc( -Default copy constructor. + node.def( + "copy", + [](Ukkonen::Node const& self) { return Ukkonen::Node(self); }, + R"pbdoc( +:sig=(self: Ukkonen.Node) -> Ukkonen.Node: + +Copy a :any:`Ukkonen.Node` object. + +:returns: A copy. +:rtype: Ukkonen.Node )pbdoc"); node.def( "child", @@ -697,10 +714,18 @@ The length of the edge leading into the current node. uk.def(py::init<>(), R"pbdoc( Constructs an empty generalised suffix tree. )pbdoc"); - uk.def(py::init(), R"pbdoc( -Default copy constructor. + uk.def( + "copy", + [](Ukkonen const& self) { return Ukkonen(self); }, + R"pbdoc( +:sig=(self: Ukkonen) -> Ukkonen: + +Copy a :any:`Ukkonen` object. + +:returns: A copy. +:rtype: Ukkonen )pbdoc"); - uk.def("__copy__", [](Ukkonen const& that) { return Ukkonen(that); }); + uk.def("__copy__", [](Ukkonen const& self) { return Ukkonen(self); }); uk.def("__iter__", [](Ukkonen const& self) { return py::make_iterator(self.begin(), self.end()); }); diff --git a/src/words.cpp b/src/words.cpp index 7efdbe969..031d685c6 100644 --- a/src/words.cpp +++ b/src/words.cpp @@ -167,14 +167,27 @@ Example )pbdoc"); thing1.def("__repr__", [](WordRange const& wr) { return to_human_readable_repr(wr); }); - thing1.def("__copy__", [](WordRange const& w) { return WordRange(w); }); + thing1.def("__copy__", + [](WordRange const& self) { return WordRange(self); }); + thing1.def( + "copy", + [](WordRange const& self) { return WordRange(self); }, + R"pbdoc( +:sig=(self: WordRange) -> WordRange: + +Copy a :any:`WordRange` object. + +:returns: A copy. +:rtype: WordRange +)pbdoc"); // TODO(now) Should we hide the return type of this? thing1.def( "__or__", [](WordRange const& w, ToString const& to_str) { if (!to_str.can_convert_letter(w.alphabet_size() - 1)) { LIBSEMIGROUPS_EXCEPTION( - "expected the alphabet size ({}) of the ToString object to be " + "expected the alphabet size ({}) of the ToString object " + "to be " ">= the alphabet size ({}) of the WordRange object", to_str.alphabet().size(), w.alphabet_size()); @@ -209,8 +222,7 @@ Constructs an empty range with: * :any:`WordRange.alphabet_size()` equal to ``0``. )pbdoc"); - thing1.def(py::init(), R"pbdoc( -Default copy constructor.)pbdoc"); + thing1.def("at_end", &WordRange::at_end, R"pbdoc( @@ -545,7 +557,20 @@ Example thing2.def("__repr__", [](StringRange const& sr) { return to_human_readable_repr(sr); }); - thing2.def("__copy__", [](StringRange const& w) { return StringRange(w); }); + thing2.def("__copy__", + [](StringRange const& self) { return StringRange(self); }); + thing2.def( + "copy", + [](StringRange const& self) { return StringRange(self); }, + R"pbdoc( +:sig=(self: StringRange) -> StringRange: + +Copy a :any:`StringRange` object. + +:returns: A copy. +:rtype: StringRange +)pbdoc"); + thing2.def( "__or__", [](StringRange const& sr, ToWord const& to_wrd) { @@ -555,8 +580,10 @@ Example return to_wrd.can_convert_letter(c); })) { LIBSEMIGROUPS_EXCEPTION( - "expected every letter of the alphabet (\"{}\") of the " - "StringRange object to belong to the alphabet (\"{}\") of the " + "expected every letter of the alphabet (\"{}\") of " + "the " + "StringRange object to belong to the alphabet " + "(\"{}\") of the " "ToWord object", sr.alphabet(), to_wrd.alphabet()); @@ -590,9 +617,6 @@ Constructs an empty range with: * :any:`StringRange.upper_bound()` equal to ``0`` ; * :any:`StringRange.alphabet()` equal to the empty string. -)pbdoc"); - thing2.def(py::init(), R"pbdoc( -Default copy constructor. )pbdoc"); thing2.def( "alphabet", @@ -927,9 +951,18 @@ Construct a :any:`ToWord` object with the given alphabet. :raises LibsemigroupsError: if there are repeated letters in *alphabet*. )pbdoc"); - thing3.def(py::init(), R"pbdoc( -Default copy constructor. + thing3.def( + "copy", + [](ToWord const& self) { return ToWord(self); }, + R"pbdoc( +:sig=(self: ToWord) -> ToWord: + +Copy a :any:`ToWord` object. + +:returns: A copy. +:rtype: ToWord )pbdoc"); + thing3.def("__copy__", [](ToWord const& self) { return ToWord(self); }); thing3.def("empty", &ToWord::empty, R"pbdoc( @@ -1079,9 +1112,18 @@ Construct a :any:`ToString` object with the given alphabet. :raises LibsemigroupsError: if there are repeated letters in *alphabet*. )pbdoc"); - thing4.def(py::init(), R"pbdoc( -Default copy constructor. + thing4.def( + "copy", + [](ToString const& self) { return ToString(self); }, + R"pbdoc( +:sig=(self: ToString) -> ToString: + +Copy a :any:`ToString` object. + +:returns: A copy. +:rtype: ToString )pbdoc"); + thing4.def("__copy__", [](ToString const& self) { return ToString(self); }); thing4.def("alphabet", &ToString::alphabet, R"pbdoc( diff --git a/tests/runner.py b/tests/runner.py index ff4f57171..29c1c1685 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -42,7 +42,7 @@ def check_runner(x, t=timedelta(microseconds=1000)): assert x.timed_out() try: - x = type(x)(x) # copy construct + x = x.copy() # copy except: # noqa: E722 pylint: disable=bare-except pass diff --git a/tests/test_froidure_pin.py b/tests/test_froidure_pin.py index 03d0eda41..670115da5 100644 --- a/tests/test_froidure_pin.py +++ b/tests/test_froidure_pin.py @@ -39,7 +39,7 @@ def check_constructors(coll): S = FroidurePin([coll[0]]) S.add_generators(coll[1:]) - # copy constructor + # copy U = S.copy() assert S is not U assert S.number_of_generators() == U.number_of_generators() @@ -87,9 +87,7 @@ def check_mem_compare(S): ReportGuard(False) with pytest.raises(RuntimeError): - froidure_pin.current_position( - S, [0, 0, 0, 0, 0, 0, 0, S.number_of_generators(), 1] - ) + froidure_pin.current_position(S, [0, 0, 0, 0, 0, 0, 0, S.number_of_generators(), 1]) with pytest.raises(RuntimeError): S.position_of_generator(S.number_of_generators()) @@ -101,15 +99,14 @@ def check_mem_compare(S): # self.assertEqual( # [S.position(froidure_pin.factorisation(S, x)) for x in S], list(range(S.size())) # ) - assert [ - froidure_pin.current_position(S, froidure_pin.factorisation(S, x)) - for x in S - ] == list(range(S.size())) + assert [froidure_pin.current_position(S, froidure_pin.factorisation(S, x)) for x in S] == list( + range(S.size()) + ) assert [S.current_position(x) for x in S] == list(range(S.size())) - assert [ - S.position_of_generator(i) for i in range(S.number_of_generators()) - ] == list(range(S.number_of_generators())) + assert [S.position_of_generator(i) for i in range(S.number_of_generators())] == list( + range(S.number_of_generators()) + ) for x in S: assert S.sorted_position(x) == S.to_sorted_position(S.position(x)) @@ -152,14 +149,10 @@ def check_idempotents(S): pass assert all( - S.fast_product(S.position(x), S.position(x)) == S.position(x) - for x in S.idempotents() + S.fast_product(S.position(x), S.position(x)) == S.position(x) for x in S.idempotents() ) - assert ( - sum(1 for x in range(S.size()) if S.is_idempotent(x)) - == S.number_of_idempotents() - ) + assert sum(1 for x in range(S.size()) if S.is_idempotent(x)) == S.number_of_idempotents() def check_cayley_graphs(S): @@ -191,30 +184,20 @@ def check_factor_prod_rels(S): # (minimal_)factorisation + to_element for i, x in enumerate(S): assert froidure_pin.to_element(S, froidure_pin.factorisation(S, x)) == x - assert ( - froidure_pin.to_element(S, froidure_pin.minimal_factorisation(S, i)) - == x - ) + assert froidure_pin.to_element(S, froidure_pin.minimal_factorisation(S, i)) == x # rules, number_of_rules assert len(list(froidure_pin.rules(S))) == S.number_of_rules() for lhs, rhs in froidure_pin.rules(S): - assert froidure_pin.current_position( - S, lhs - ) == froidure_pin.current_position(S, rhs) - assert ( - froidure_pin.factorisation(S, froidure_pin.current_position(S, rhs)) - == rhs - ) + assert froidure_pin.current_position(S, lhs) == froidure_pin.current_position(S, rhs) + assert froidure_pin.factorisation(S, froidure_pin.current_position(S, rhs)) == rhs # product_by_reduction + fast_product try: for i in range(S.size()): for j in range(S.size()): - assert froidure_pin.product_by_reduction(S, i, j) == S.position( - S[i] * S[j] - ) + assert froidure_pin.product_by_reduction(S, i, j) == S.position(S[i] * S[j]) assert S.fast_product(i, j) == S.position(S[i] * S[j]) except TypeError: # no product defined pass @@ -477,9 +460,7 @@ def test_froidure_pin_min_plus(checks_for_froidure_pin, checks_for_generators): check(FroidurePin(gens)) -def test_froidure_pin_proj_max_plus( - checks_for_froidure_pin, checks_for_generators -): +def test_froidure_pin_proj_max_plus(checks_for_froidure_pin, checks_for_generators): ReportGuard(False) x = Matrix(MatrixKind.ProjMaxPlus, 2, 2) gens = [Matrix(MatrixKind.ProjMaxPlus, [[1, 0], [0, x.scalar_zero()]])] @@ -492,9 +473,7 @@ def test_froidure_pin_proj_max_plus( check(FroidurePin(gens)) -def test_froidure_pin_max_plus_trunc( - checks_for_froidure_pin, checks_for_generators -): +def test_froidure_pin_max_plus_trunc(checks_for_froidure_pin, checks_for_generators): ReportGuard(False) gens = [Matrix(MatrixKind.MaxPlusTrunc, 11, [[1, 0], [0, 1]])] assert FroidurePin(gens).size() == 12 @@ -506,9 +485,7 @@ def test_froidure_pin_max_plus_trunc( check(FroidurePin(gens)) -def test_froidure_pin_min_plus_trunc( - checks_for_froidure_pin, checks_for_generators -): +def test_froidure_pin_min_plus_trunc(checks_for_froidure_pin, checks_for_generators): ReportGuard(False) gens = [Matrix(MatrixKind.MinPlusTrunc, 11, [[1, 0], [0, 1]])] assert FroidurePin(gens).size() == 2 @@ -557,9 +534,7 @@ def test_froidure_pin_method_wrap(): S.init() with pytest.raises(LibsemigroupsError): - S.add_generators( - [Perm([0, 1, 2, 3, 4, 5]), Perm([0, 1, 2, 3, 4, 5, 6])] - ) + S.add_generators([Perm([0, 1, 2, 3, 4, 5]), Perm([0, 1, 2, 3, 4, 5, 6])]) S = FroidurePin(Perm([1, 0, 2, 3, 4, 5, 6]), Perm([1, 2, 3, 4, 5, 6, 0])) diff --git a/tests/test_runner.py b/tests/test_runner.py index c5d63cb14..bf7539d6f 100644 --- a/tests/test_runner.py +++ b/tests/test_runner.py @@ -39,7 +39,7 @@ def test_reporter_000(): r.report_prefix("Banana") r.report_every(timedelta(seconds=32)) - s = Reporter(r) + s = r.copy() assert s.report_prefix() == "Banana" assert s.report_every() == timedelta(seconds=32) assert s.last_report() == r.last_report() diff --git a/tests/test_schreier_sims.py b/tests/test_schreier_sims.py index f1ae8490e..f6b8cabda 100644 --- a/tests/test_schreier_sims.py +++ b/tests/test_schreier_sims.py @@ -34,7 +34,7 @@ def check_constructors(gens): S1 = SchreierSims(gens) - # copy constructor + # copy S2 = copy(S1) assert S1 is not S2 @@ -381,45 +381,27 @@ def check_SchreierSims_001(n): S.init() assert S.size() == 1 S.add_generator( - Perm( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 0] - + list(range(17, n)) - ) + Perm([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 0] + list(range(17, n))) ) S.add_generator( - Perm( - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 14] - + list(range(17, n)) - ) + Perm([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 14] + list(range(17, n))) ) assert not S.currently_contains( - Perm( - [1, 0, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] - + list(range(17, n)) - ) + Perm([1, 0, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] + list(range(17, n))) ) assert S.current_size() == 17 assert S.size() == 177843714048000 assert S.base(0) == 0 assert S.contains( - Perm( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 0] - + list(range(17, n)) - ) + Perm([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 0] + list(range(17, n))) ) assert not S.contains( - Perm( - [1, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] - + list(range(17, n)) - ) + Perm([1, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] + list(range(17, n))) ) assert S.contains( - Perm( - [1, 0, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] - + list(range(17, n)) - ) + Perm([1, 0, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] + list(range(17, n))) ) S.init() @@ -430,18 +412,12 @@ def check_SchreierSims_001(n): S.add_base_point(14) S.add_base_point(15) S.add_generator( - Perm( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 0] - + list(range(17, n)) - ) + Perm([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 0] + list(range(17, n))) ) S.add_base_point(1) S.add_base_point(3) S.add_generator( - Perm( - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 14] - + list(range(17, n)) - ) + Perm([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 14] + list(range(17, n))) ) assert S.base_size() == 4 assert S.size() == 177843714048000 @@ -457,39 +433,24 @@ def check_SchreierSims_001(n): S.base(15) assert S.contains( - Perm( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 0] - + list(range(17, n)) - ) + Perm([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 0] + list(range(17, n))) ) assert not S.contains( - Perm( - [1, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] - + list(range(17, n)) - ) + Perm([1, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] + list(range(17, n))) ) assert S.contains( - Perm( - [1, 0, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] - + list(range(17, n)) - ) + Perm([1, 0, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] + list(range(17, n))) ) with pytest.raises(LibsemigroupsError): S.add_base_point(1) S.init() S.add_generator( - Perm( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 0] - + list(range(17, n)) - ) + Perm([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 0] + list(range(17, n))) ) assert S.size() == 17 S.add_generator( - Perm( - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 14] - + list(range(17, n)) - ) + Perm([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 14] + list(range(17, n))) ) assert S.size() == 177843714048000