From f55ded323b9987d43336c3c5fe8fa476ca5af542 Mon Sep 17 00:00:00 2001 From: James Mitchell Date: Tue, 3 Jun 2025 11:50:59 +0100 Subject: [PATCH 1/4] Replace List -> list --- .../elements/matrix/matrix.rst | 16 +-- .../data-structures/presentations/index.rst | 2 +- .../presentations/inverse-present.rst | 2 +- .../presentations/present-helpers.rst | 2 +- .../data-structures/presentations/present.rst | 2 +- .../presentations/to-inverse-present.rst | 15 ++- .../presentations/to-present.rst | 26 ++-- .../main-algorithms/congruence/to-cong.rst | 4 +- .../knuth-bendix/to-knuth-bendix.rst | 14 +-- .../todd-coxeter/to-todd-coxeter.rst | 4 +- src/aho-corasick.cpp | 17 +-- src/bipart.cpp | 8 +- src/bmat8.cpp | 3 +- src/cong-common.cpp | 56 ++++----- src/dot.cpp | 10 +- src/forest.cpp | 8 +- src/freeband.cpp | 4 +- src/froidure-pin-base.cpp | 22 ++-- src/froidure-pin.cpp | 50 ++++---- src/gabow.cpp | 6 +- src/knuth-bendix-impl.cpp | 4 +- src/knuth-bendix.cpp | 13 +- src/konieczny.cpp | 8 +- src/libsemigroups_pybind11/action.py | 24 ++-- src/libsemigroups_pybind11/congruence.py | 8 +- .../detail/congruence_common.py | 9 +- src/libsemigroups_pybind11/kambites.py | 3 +- src/libsemigroups_pybind11/knuth_bendix.py | 10 +- src/libsemigroups_pybind11/matrix.py | 18 ++- .../presentation/__init__.py | 12 +- src/libsemigroups_pybind11/sims.py | 35 ++---- src/libsemigroups_pybind11/to.py | 14 +-- src/libsemigroups_pybind11/todd_coxeter.py | 5 +- src/libsemigroups_pybind11/transf.py | 6 +- src/matrix.cpp | 6 +- src/order.cpp | 32 ++--- src/paths.cpp | 2 +- src/pbr.cpp | 6 +- src/presentation-examples.cpp | 4 +- src/schreier-sims.cpp | 4 +- src/sims.cpp | 2 +- src/stephen.cpp | 16 +-- src/todd-coxeter.cpp | 32 ++--- src/transf.cpp | 26 ++-- src/ukkonen.cpp | 74 ++++++------ src/word-graph.cpp | 12 +- src/words.cpp | 48 ++++---- tests/test_present.py | 6 +- tests/test_sims.py | 41 ++----- tests/test_stephen.py | 112 +++++------------- tests/test_to.py | 89 ++++++-------- 51 files changed, 416 insertions(+), 536 deletions(-) diff --git a/docs/source/data-structures/elements/matrix/matrix.rst b/docs/source/data-structures/elements/matrix/matrix.rst index 223a089a5..946abd359 100644 --- a/docs/source/data-structures/elements/matrix/matrix.rst +++ b/docs/source/data-structures/elements/matrix/matrix.rst @@ -201,7 +201,7 @@ The Matrix class Instances of this class implement matrices over the semirings listed above in :any:`MatrixKind`. - .. py:method:: __init__(self: Matrix, kind: MatrixKind, rows: List[List[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]]) -> None + .. py:method:: __init__(self: Matrix, kind: MatrixKind, rows: list[list[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]]) -> None :noindex: Construct a matrix from rows. @@ -210,7 +210,7 @@ The Matrix class :type kind: MatrixKind :param rows: the rows of the matrix. - :type rows: List[List[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]] + :type rows: list[list[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]] :raise RunTimeError: if *kind* is :py:attr:`MatrixKind.MaxPlusTrunc`, @@ -225,7 +225,7 @@ The Matrix class the underlying semiring. - .. py:method:: __init__(self: Matrix, kind: MatrixKind, threshold: int, rows: List[List[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]]) -> None + .. py:method:: __init__(self: Matrix, kind: MatrixKind, threshold: int, rows: list[list[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]]) -> None :noindex: Construct a matrix from threshold and rows. @@ -237,7 +237,7 @@ The Matrix class :type threshold: int :param rows: the rows of the matrix. - :type rows: List[List[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]] + :type rows: list[list[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]] :raise RunTimeError: if *kind* is not :py:attr:`MatrixKind.MaxPlusTrunc`, or @@ -251,7 +251,7 @@ The Matrix class the underlying semiring. - .. py:method:: __init__(self: Matrix, kind: MatrixKind, threshold: int, period: int, rows: List[List[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]]) -> None + .. py:method:: __init__(self: Matrix, kind: MatrixKind, threshold: int, period: int, rows: list[list[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]]) -> None :noindex: Construct a matrix from rows. @@ -266,7 +266,7 @@ The Matrix class :type period: int :param rows: the rows of the matrix. - :type rows: List[List[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]] + :type rows: list[list[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]] :raise RunTimeError: if *kind* is not :py:attr:`MatrixKind.NTP`. @@ -438,12 +438,12 @@ The Matrix class if *i* is greater than or equal to :any:`number_of_rows`. - .. py:method:: rows(self: Matrix) -> List[Matrix] + .. py:method:: rows(self: Matrix) -> list[Matrix] Returns a list of all rows of a matrix. :returns: A list of the rows. - :rtype: List[Matrix] + :rtype: list[Matrix] .. py:method:: scalar_one(self: Matrix) -> int diff --git a/docs/source/data-structures/presentations/index.rst b/docs/source/data-structures/presentations/index.rst index e0aa505d4..0527113cb 100644 --- a/docs/source/data-structures/presentations/index.rst +++ b/docs/source/data-structures/presentations/index.rst @@ -25,7 +25,7 @@ of the type :any:`int`, words will be lists of :any:`int` types. be changed.** In what follows, we will use the pseudo-types ``Letter`` and ``Word`` instead of -``str | int`` and ``str | List[int]`` to further indicate that two types of +``str | int`` and ``str | list[int]`` to further indicate that two types of letters and words cannot be interchanged once a presentation is constructed. All of the classes for finitely presented semigroups and monoids in diff --git a/docs/source/data-structures/presentations/inverse-present.rst b/docs/source/data-structures/presentations/inverse-present.rst index e1f83c7c5..98a2a9a10 100644 --- a/docs/source/data-structures/presentations/inverse-present.rst +++ b/docs/source/data-structures/presentations/inverse-present.rst @@ -24,7 +24,7 @@ Types In what follows, we use the following pseudo-types: - ``Letter`` for ``str | int`` - - ``Word`` for ``str | List[int]`` + - ``Word`` for ``str | list[int]`` Recall that, once a presentation has been constructed, the type of its letters and words are fixed. diff --git a/docs/source/data-structures/presentations/present-helpers.rst b/docs/source/data-structures/presentations/present-helpers.rst index 750226acc..989c3479f 100644 --- a/docs/source/data-structures/presentations/present-helpers.rst +++ b/docs/source/data-structures/presentations/present-helpers.rst @@ -21,7 +21,7 @@ Types In what follows, we use the following pseudo-types: - ``Letter`` for ``str | int`` - - ``Word`` for ``str | List[int]`` + - ``Word`` for ``str | list[int]`` Recall that, once a presentation has been constructed, the type of its letters and words are fixed. diff --git a/docs/source/data-structures/presentations/present.rst b/docs/source/data-structures/presentations/present.rst index 8e8776429..3d4968479 100644 --- a/docs/source/data-structures/presentations/present.rst +++ b/docs/source/data-structures/presentations/present.rst @@ -24,7 +24,7 @@ Types In what follows, we use the following pseudo-types: - ``Letter`` for ``str | int`` - - ``Word`` for ``str | List[int]`` + - ``Word`` for ``str | list[int]`` Recall that, once a presentation has been constructed, the type of its letters and words are fixed. diff --git a/docs/source/data-structures/presentations/to-inverse-present.rst b/docs/source/data-structures/presentations/to-inverse-present.rst index 148b7f595..997bfa858 100644 --- a/docs/source/data-structures/presentations/to-inverse-present.rst +++ b/docs/source/data-structures/presentations/to-inverse-present.rst @@ -96,8 +96,8 @@ Additionally, specify one of the following for *Return*: - ``(InversePresentation, str)`` for constructing an - :any:`InversePresentation` over words of type ``str``. - - ``(InversePresentation, List[int])`` for constructing an - :any:`InversePresentation` over words of type ``List[int]``. + - ``(InversePresentation, list[int])`` for constructing an + :any:`InversePresentation` over words of type ``list[int]``. This function behaves in one of two ways, depending on type of words in *p*, and the type of words specified in *Return*: @@ -106,7 +106,7 @@ the type of words specified in *Return*: are not the same, this function returns an :any:`InversePresentation` equivalent to the input :any:`InversePresentation` *ip* but with words a different type (for example, can be used to convert from ``str`` to - ``List[int]``). + ``list[int]``). 2. When the type of words in *ip* and type of words specified in *Return* are the same, this function just returns its argument *ip*, and is included solely for the purpose of simplifying certain client code, where @@ -116,7 +116,7 @@ the type of words specified in *Return*: If the alphabet of of *ip* is :math:`\{a_0, a_1, \dots a_{n-1}\}`, where each letter is of type ``str``, then the conversion from one type to another is :math:`a_i \mapsto` ``human_readable_index(a_i)``. Conversely, if each letter is -of type ``List[int]``, then the conversion from one type to another is +of type ``list[int]``, then the conversion from one type to another is :math:`a_i \mapsto` ``human_readable_letter(a_i)``. This function throws a :any:`LibsemigroupsError` if the type of words in *ip* is @@ -131,7 +131,6 @@ not the same as that specified in *Return* and .. doctest:: Python - >>> from typing import List >>> from libsemigroups_pybind11 import presentation, Presentation, to >>> ip = InversePresentation('abc') @@ -143,7 +142,7 @@ not the same as that specified in *Return* and >>> ip == to(ip, Return=(InversePresentation, str)) True - >>> iq = to(ip, Return=(InversePresentation, List[int])) + >>> iq = to(ip, Return=(InversePresentation, list[int])) >>> iq.alphabet() [0, 1, 2] >>> iq.inverses() @@ -169,8 +168,8 @@ Additionally, specify one of the following for *Return*: - ``(InversePresentation, str)`` for constructing an :any:`InversePresentation` over words of type ``str``. - - ``(InversePresentation, List[int])`` for constructing a - :any:`InversePresentation` over words of type ``List[int]``. + - ``(InversePresentation, list[int])`` for constructing a + :any:`InversePresentation` over words of type ``list[int]``. This function returns an :any:`InversePresentation` equivalent to the input :any:`InversePresentation` *ip* but over words with letters of a different type diff --git a/docs/source/data-structures/presentations/to-present.rst b/docs/source/data-structures/presentations/to-present.rst index 740d1e3dc..bb93cfb74 100644 --- a/docs/source/data-structures/presentations/to-present.rst +++ b/docs/source/data-structures/presentations/to-present.rst @@ -46,8 +46,8 @@ Additionally, specify one of the following for *Return*: - ``(Presentation, str)`` for constructing a :any:`Presentation` over words of type ``str``. - - ``(Presentation, List[int])`` for constructing a :any:`Presentation` over - words of type ``List[int]``. + - ``(Presentation, list[int])`` for constructing a :any:`Presentation` over + words of type ``list[int]``. This function behaves in one of two ways, depending on type of words in *p*, and the type of words specified in *Return*: @@ -55,7 +55,7 @@ the type of words specified in *Return*: 1. When the type of words in *p* and type of words specified in *Return* are not the same, this function returns a :any:`Presentation` equivalent to the input :any:`Presentation` *p* but with words a different type (for - example, can be used to convert from ``str`` to ``List[int]``). + example, can be used to convert from ``str`` to ``list[int]``). 2. When the type of words in *p* and type of words specified in *Return* are the same, this function just returns its argument *p*, and is included solely for the purpose of simplifying certain client code, where @@ -65,7 +65,7 @@ the type of words specified in *Return*: If the alphabet of of *p* is :math:`\{a_0, a_1, \dots a_{n-1}\}`, where each letter is of type ``str``, then the conversion from one type to another is :math:`a_i \mapsto` ``human_readable_index(a_i)``. Conversely, if each letter is -of type ``List[int]``, then the conversion from one type to another is +of type ``list[int]``, then the conversion from one type to another is :math:`a_i \mapsto` ``human_readable_letter(a_i)``. This function throws a :any:`LibsemigroupsError` if the type of words in *p* is @@ -80,7 +80,6 @@ not the same as that specified in *Return*, and .. doctest:: Python - >>> from typing import List >>> from libsemigroups_pybind11 import presentation, Presentation, to >>> p = Presentation('abcdef') @@ -91,7 +90,7 @@ not the same as that specified in *Return*, and >>> p == to(p, Return=(Presentation, str)) True - >>> q = to(p, Return=(Presentation, List[int])) + >>> q = to(p, Return=(Presentation, list[int])) >>> q.alphabet() [0, 1, 2, 3, 4, 5] >>> q.rules @@ -116,8 +115,8 @@ Additionally, specify one of the following for *Return*: - ``(Presentation, str)`` for constructing a :any:`Presentation` over words of type ``str``. - - ``(Presentation, List[int])`` for constructing a :any:`Presentation` over - words of type ``List[int]``. + - ``(Presentation, list[int])`` for constructing a :any:`Presentation` over + words of type ``list[int]``. This function returns a :any:`Presentation` equivalent to the input :any:`Presentation` *p* but over words with letters of a different type (for @@ -136,7 +135,6 @@ specified in *Return*. .. doctest:: Python - >>> from typing import List >>> from libsemigroups_pybind11 import presentation, Presentation, to >>> p = Presentation([0, 2, 4, 6]) @@ -149,7 +147,7 @@ specified in *Return*. >>> q = to( ... p, # p ... double, # f - ... Return=(Presentation, List[int]) + ... Return=(Presentation, list[int]) ... ) >>> q.alphabet() [0, 4, 8, 12] @@ -173,8 +171,8 @@ Additionally, specify one of the following for *Return*: the same type as that in *kb*. - ``(Presentation, str)`` for constructing a :any:`Presentation` over words of type ``str``. - - ``(Presentation, List[int]`` for constructing a :any:`Presentation` over - words of type ``List[int]``. + - ``(Presentation, list[int]`` for constructing a :any:`Presentation` over + words of type ``list[int]``. This function constructs and returns a :any:`Presentation` object using the currently active rules of *kb*. @@ -230,8 +228,8 @@ Additionally, specify the following for *Return*: - ``(Presentation, str)`` for constructing a :any:`Presentation` over words of type ``str``. - - ``(Presentation, List[int])`` for constructing a :any:`Presentation` over - words of type ``List[int]``. + - ``(Presentation, list[int])`` for constructing a :any:`Presentation` over + words of type ``list[int]``. This function constructs and returns a :any:`Presentation` object using the rules of a :any:`FroidurePin` object. diff --git a/docs/source/main-algorithms/congruence/to-cong.rst b/docs/source/main-algorithms/congruence/to-cong.rst index 862ed3346..27784d21f 100644 --- a/docs/source/main-algorithms/congruence/to-cong.rst +++ b/docs/source/main-algorithms/congruence/to-cong.rst @@ -46,8 +46,8 @@ Additionally, specify one of the following tuples for *Return*: - ``(Congruence, str)`` for constructing a :any:`Congruence` on words of type ``str``; or - - ``(Congruence, List[int])`` for constructing a :any:`Congruence` on words - of type ``List[int]``. + - ``(Congruence, list[int])`` for constructing a :any:`Congruence` on words + of type ``list[int]``. This function converts the :any:`FroidurePin` object *fpb* into a :any:`Congruence` object using the :any:`WordGraph` *wg* (which should be either diff --git a/docs/source/main-algorithms/knuth-bendix/to-knuth-bendix.rst b/docs/source/main-algorithms/knuth-bendix/to-knuth-bendix.rst index f19248fd9..8ff008b21 100644 --- a/docs/source/main-algorithms/knuth-bendix/to-knuth-bendix.rst +++ b/docs/source/main-algorithms/knuth-bendix/to-knuth-bendix.rst @@ -157,28 +157,26 @@ Additionally, specify one of the following for *Return*: - ``(KnuthBendix, str, 'RewriteTrie')`` for constructing a :any:`KnuthBendix` on words with type ``str`` using the ``RewriteTrie'`` rewriter. - - ``(KnuthBendix, List[int], 'RewriteTrie')`` for constructing a - :any:`KnuthBendix` on words with type ``List[int]`` using the + - ``(KnuthBendix, list[int], 'RewriteTrie')`` for constructing a + :any:`KnuthBendix` on words with type ``list[int]`` using the ``RewriteTrie'`` rewriter. - ``(KnuthBendix, str, 'RewriteFromLeft')`` for constructing a :any:`KnuthBendix` on words with type ``str`` using the ``RewriteFromLeft'`` rewriter. - - ``(KnuthBendix, List[int], 'RewriteFromLeft')`` for constructing a - :any:`KnuthBendix` on words with type ``List[int]`` using the + - ``(KnuthBendix, list[int], 'RewriteFromLeft')`` for constructing a + :any:`KnuthBendix` on words with type ``list[int]`` using the ``RewriteFromLeft'`` rewriter. This function converts a :any:`FroidurePin` object *fpb* to a :any:`KnuthBendix` object with the word type and rewriter as specified above. This is done using the presentation obtained from ``to(fpb, Return=(Presentation, Word)`` where -``Word`` is either ``str`` or ``List[int]``. +``Word`` is either ``str`` or ``list[int]``. This returned :any:`KnuthBendix` object represents the trivial congruence over the semigroup defined by *fpb*. .. doctest:: Python - >>> from typing import List - >>> from libsemigroups_pybind11 import ( ... Bipartition, ... congruence_kind, @@ -198,7 +196,7 @@ the semigroup defined by *fpb*. >>> kb = to( ... congruence_kind.twosided, # knd ... S, # tc - ... Return=(KnuthBendix, List[int], 'RewriteFromLeft') + ... Return=(KnuthBendix, list[int], 'RewriteFromLeft') ... ) >>> kb.run() diff --git a/docs/source/main-algorithms/todd-coxeter/to-todd-coxeter.rst b/docs/source/main-algorithms/todd-coxeter/to-todd-coxeter.rst index dd9c64b99..0b1da22bc 100644 --- a/docs/source/main-algorithms/todd-coxeter/to-todd-coxeter.rst +++ b/docs/source/main-algorithms/todd-coxeter/to-todd-coxeter.rst @@ -48,8 +48,8 @@ Additionally, specify one of the following for *Return*: - ``(ToddCoxeter, str)`` for constructing a :any:`ToddCoxeter` on words with type ``str``. - - ``(ToddCoxeter, List[int])`` for constructing a :any:`ToddCoxeter` on - words with type ``List[int]``. + - ``(ToddCoxeter, list[int])`` for constructing a :any:`ToddCoxeter` on + words with type ``list[int]``. This function converts the :any:`FroidurePin` object *fpb* into a :any:`ToddCoxeter` object using the :any:`WordGraph` *wg* (which should be diff --git a/src/aho-corasick.cpp b/src/aho-corasick.cpp index 7560f5e71..ee4eef2ef 100644 --- a/src/aho-corasick.cpp +++ b/src/aho-corasick.cpp @@ -178,7 +178,7 @@ of the unique path from the root to :type i: int :returns: The signature -:rtype: List[int] +:rtype: list[int] :complexity: Linear in the height of the node )pbdoc"); @@ -306,7 +306,7 @@ This function checks if the node with index *i* is terminal or not. py::arg("ac"), py::arg("w"), R"pbdoc( -:sig=(ac: AhoCorasick, w: List[int] | str) -> int: +:sig=(ac: AhoCorasick, w: list[int] | str) -> int: :only-document-once: Add a word to the trie of *ac* @@ -321,7 +321,7 @@ this function does nothing. :type ac: AhoCorasick :param w: the word to add -:type w: List[int] +:type w: list[int] :returns: The index corresponding to the final node added to the trie of *ac*. This node will have a :any:`signature` equal to that of *w*. @@ -337,7 +337,8 @@ this function does nothing. py::arg("ac"), py::arg("w"), R"pbdoc( -:sig=(ac: AhoCorasick, w: List[int] | str) -> int: +:sig=(ac: AhoCorasick, w: list[int] | str) -> int: +TODO )pbdoc"); m.def("rm_word", &aho_corasick::rm_word, @@ -364,7 +365,7 @@ nothing. :type ac: AhoCorasick :param w: the word to remove -:type w: List[int] +:type w: list[int] :returns: The index corresponding to the node with signature equal to *w*. :rtype: int @@ -382,7 +383,7 @@ nothing. Remove a word from the trie of *ac*. This function performs the same as ``rm_word(ac, w)``, -but *w* is a :any:`string` rather than List[:any:`int`]. +but *w* is a :any:`string` rather than list[:any:`int`]. )pbdoc"); m.def( @@ -406,7 +407,7 @@ index *start*, and traversing using the letters in the word *w*. :type start: int :param w: Word to traverse by -:type w: List[int] +:type w: list[int] :returns: The result of the traversal :rtype: int @@ -424,7 +425,7 @@ index *start*, and traversing using the letters in the word *w*. Traverse the trie of *ac* using suffix links where necessary. This function performs the same as ``traverse_word(ac, w)``, -but *w* is a :any:`string` rather than List[:any:`int`]. +but *w* is a :any:`string` rather than list[:any:`int`]. )pbdoc"); m.def( "traverse_word", diff --git a/src/bipart.cpp b/src/bipart.cpp index 9c7d8563d..745a80a7f 100644 --- a/src/bipart.cpp +++ b/src/bipart.cpp @@ -161,7 +161,7 @@ index ``i`` is transverse and ``False`` if it is not. :returns: The transverse block lookup list. :rtype: - List[bool] + list[bool] )pbdoc"); thing.def("number_of_blocks", &Blocks::number_of_blocks, @@ -217,7 +217,7 @@ partition* of a :any:`Blocks` object *x* is the partition of a subset :returns: The underlying partition of the parameter *x*. :rtype: - List[List[int]] + list[list[int]] )pbdoc"); } // init_blocks @@ -276,7 +276,7 @@ The items in *blocks* should be: positive integer :math:`n`. :param blocks: the underlying partition. -:type blocks: List[List[int]] +:type blocks: list[list[int]] :raises LibsemigroupsError: if any of the conditions above is not met. )pbdoc"); @@ -529,7 +529,7 @@ partition* of a bipartition *x* is the partition of a subset :math:`P` of :returns: The underlying partition of the :any:`Bipartition`. :rtype: - List[List[int]] + list[list[int]] )pbdoc"); } // init_bipart diff --git a/src/bmat8.cpp b/src/bmat8.cpp index 5f08cb500..48d117c74 100644 --- a/src/bmat8.cpp +++ b/src/bmat8.cpp @@ -121,7 +121,7 @@ the submodule ``bmat8``. // following argument types are supported: // 1. (self: _libsemigroups_pybind11.FroidurePinPerm16, x: // _libsemigroups_pybind11.StaticPerm16) -> int - // 2. (self: _libsemigroups_pybind11.FroidurePinBase, w: List[int]) -> int + // 2. (self: _libsemigroups_pybind11.FroidurePinBase, w: list[int]) -> int // 3. (self: _libsemigroups_pybind11.FroidurePinBase, i: int) -> int thing2.def("__len__", [](BMat8 const& x) { return 8; }); thing2.def("__repr__", @@ -150,6 +150,7 @@ the submodule ``bmat8``. thing2.def(py::self != py::self); thing2.def(py::self <= py::self); thing2.def(py::self >= py::self); + thing2.def(py::self += py::self); thing2.def(py::self + py::self); thing2.def(py::self * bool()); diff --git a/src/cong-common.cpp b/src/cong-common.cpp index c167eb614..15a5e0ef6 100644 --- a/src/cong-common.cpp +++ b/src/cong-common.cpp @@ -481,7 +481,7 @@ number of classes in the congruence represented by a :any:`{name}` instance. py::arg("v"), make_doc( R"pbdoc( -:sig=(self: {name}, u: List[int] | str, v: List[int] | str) -> {name}: +:sig=(self: {name}, u: list[int] | str, v: list[int] | str) -> {name}: {only_document_once} Add a generating pair. @@ -492,10 +492,10 @@ This function adds a generating pair to the congruence represented by a {detail} :param u: the first item in the pair. -:type u: List[int] | str +:type u: list[int] | str :param v: the second item in the pair. -:type v: List[int] | str +:type v: list[int] | str :returns: ``self``. :rtype: {name} @@ -561,7 +561,7 @@ This function adds a generating pair to the congruence represented by a py::arg("u"), py::arg("v"), make_doc(R"pbdoc( -:sig=(self: {name}, u: List[int] | str, v: List[int] | str) -> tril: +:sig=(self: {name}, u: list[int] | str, v: list[int] | str) -> tril: {only_document_once} Check whether a pair of words is already known to belong to the congruence. @@ -572,10 +572,10 @@ This function performs no enumeration, so it is possible for the words to be contained in the congruence, but that this is not currently known. :param u: the first word. -:type u: List[int] | str +:type u: list[int] | str :param v: the second word. -:type v: List[int] | str +:type v: list[int] | str :returns: * :any:`tril.true` if the words are known to belong to the congruence; @@ -644,7 +644,7 @@ contained in the congruence, but that this is not currently known. py::arg("u"), py::arg("v"), make_doc(R"pbdoc( -:sig=(self: {name}, u: List[int] | str, v: List[int] | str) -> bool: +:sig=(self: {name}, u: list[int] | str, v: list[int] | str) -> bool: {only_document_once} Check containment of a pair of words. @@ -653,10 +653,10 @@ This function checks whether or not the words *u* and *v* are contained in the congruence represented by a :py:class:`{name}` instance. :param u: the first word. -:type u: List[int] | str +:type u: list[int] | str :param v: the second word. -:type v: List[int] | str +:type v: list[int] | str :returns: Whether or not the pair belongs to the congruence. :rtype: bool @@ -717,7 +717,7 @@ congruence represented by a :py:class:`{name}` instance. }, py::arg("w"), make_doc(R"pbdoc( -:sig=(self: {name}, w: List[int] | str) -> List[int] | str: +:sig=(self: {name}, w: list[int] | str) -> list[int] | str: {only_document_once} Reduce a word. @@ -728,10 +728,10 @@ normal form for the input word *w*. {detail} :param w: the input word. -:type w: List[int] | str +:type w: list[int] | str :returns: A word equivalent to the input word. -:rtype: List[int] | str +:rtype: list[int] | str :raises LibsemigroupsError: if any of the values in *w* is out of range, i.e. they do not belong to @@ -790,7 +790,7 @@ normal form for the input word *w*. }, py::arg("w"), make_doc(R"pbdoc( -:sig=(self: {name}, w: List[int] | str) -> List[int] | str: +:sig=(self: {name}, w: list[int] | str) -> list[int] | str: {only_document_once} Reduce a word. @@ -802,10 +802,10 @@ input word. {detail} :param w: the input word. -:type w: List[int] | str +:type w: list[int] | str :returns: A normal form for the input word. -:rtype: List[int] | str +:rtype: list[int] | str :raises LibsemigroupsError: if any of the values in *w* is out of range, i.e. they do not belong to @@ -858,7 +858,7 @@ input word. &Thing::generating_pairs, make_doc( R"pbdoc( -:sig=(self : {name}) -> List[List[int] | str]: +:sig=(self : {name}) -> list[list[int] | str]: {only_document_once} Get the generating pairs of the congruence. @@ -869,7 +869,7 @@ This function returns the generating pairs of the congruence as added via :returns: The list of generating pairs. :rtype: - List[List[int] | str] + list[list[int] | str] )pbdoc", name, extra_doc)); @@ -983,7 +983,7 @@ presentation, then this presentation is returned by this function. py::arg(extra_doc.var.data()), py::arg("words"), make_doc(R"pbdoc( -:sig=({var}: {name}, words: List[List[int] | str]) -> List[List[List[int]] | List[str]]: +:sig=({var}: {name}, words: list[list[int] | str]) -> list[list[list[int]] | list[str]]: {only_document_once} Partition a list of words. @@ -998,10 +998,10 @@ triggers a full enumeration of *{var}*. :type {var}: {name} :param words: the input list of words. -:type words: List[List[int] | str] +:type words: list[list[int] | str] :returns: The partitioned list of words. -:rtype: List[List[List[int]] | List[str]] +:rtype: list[list[list[int]] | list[str]] {raises} )pbdoc", @@ -1051,7 +1051,7 @@ triggers a full enumeration of *{var}*. py::arg("words"), make_doc( R"pbdoc( -:sig=({var}: {name}, words: List[List[int] | str]) -> List[List[List[int]] | List[str]]: +:sig=({var}: {name}, words: list[list[int] | str]) -> list[list[list[int]] | list[str]]: {only_document_once} Find the non-trivial classes in the partition of a list of words. @@ -1066,10 +1066,10 @@ instance *{var}*. :type {var}: {name} :param words: the input list of words. -:type words: List[List[int] | str] +:type words: list[list[int] | str] :returns: The partition of the input list. -:rtype: List[List[List[int]] | List[str]] +:rtype: list[list[list[int]] | list[str]] {raises})pbdoc", class_name, @@ -1115,7 +1115,7 @@ instance *{var}*. }, py::arg(extra_doc.var.data()), make_doc(R"pbdoc( -:sig=({var}: {name}) -> Iterator[str | List[int]]: +:sig=({var}: {name}) -> Iterator[str | list[int]]: {only_document_once} Returns an iterator yielding normal forms. @@ -1129,7 +1129,7 @@ the congruence represented by an instance of :any:`{name}`. :type {var}: {name} :returns: An iterator yielding normal forms. -:rtype: Iterator[str | List[int]] +:rtype: Iterator[str | list[int]] {raises} @@ -1192,13 +1192,13 @@ This function returns the kind of the congruence represented by ``self``. See thing.def("internal_generating_pairs", &detail::CongruenceCommon::internal_generating_pairs, R"pbdoc( -:sig=(self: detail::CongruenceCommon) -> List[List[int]]: +:sig=(self: detail::CongruenceCommon) -> list[list[int]]: Returns the generating pairs of the congruence. This function returns the generating pairs of the congruence represented by any derived class of a :any:`detail::CongruenceCommon`. This is always a -``List[List[int]]``, regardless of the type of presentation used to construct +``list[list[int]]``, regardless of the type of presentation used to construct the derived class. :complexity: @@ -1208,7 +1208,7 @@ the derived class. The generating pairs. :rtype: - List[List[int]] + list[list[int]] )pbdoc"); thing.def("number_of_generating_pairs", diff --git a/src/dot.cpp b/src/dot.cpp index afb81989c..dda2a0bd1 100644 --- a/src/dot.cpp +++ b/src/dot.cpp @@ -148,14 +148,14 @@ The following transformations are performed dot.def("edges", py::overload_cast<>(&Dot::edges, py::const_), R"pbdoc( -:sig=(self:Dot)->List[Dot.Edge]: +:sig=(self:Dot)->list[Dot.Edge]: Returns a list of the current edges (:any:`Edge` objects) in the represented graph. :returns: The list of current edges. :rtype: - List[Dot.Edge] + list[Dot.Edge] )pbdoc"); dot.def("subgraphs", @@ -167,7 +167,7 @@ represented graph. :returns: The list of current subgraphs. :rtype: - List[Dot] + list[Dot] )pbdoc"); dot.def("attrs", @@ -264,14 +264,14 @@ Set the name of the represented graph. return d.nodes() | rx::to_vector(); }, R"pbdoc( -:sig=(self: Dot) -> List[Dot.Node]: +:sig=(self: Dot) -> list[Dot.Node]: Returns a list of the current nodes in the represented graph. :returns: The list of current nodes. :rtype: - List[Dot.Node] + list[Dot.Node] )pbdoc"); dot.def( "node", diff --git a/src/forest.cpp b/src/forest.cpp index cc19753cf..77d5d7413 100644 --- a/src/forest.cpp +++ b/src/forest.cpp @@ -78,14 +78,14 @@ Constructs a forest with *n* nodes, that is initialised so that the py::arg("parents"), py::arg("labels"), R"pbdoc( -:sig=(self: Forest, parents:List[int | Undefined], labels:List[int | Undefined]) -> None: +:sig=(self: Forest, parents:list[int | Undefined], labels:list[int | Undefined]) -> None: Construct a :any:`Forest` from list of *parents* and *labels*. :param parent: the list of parents of nodes. -:type parent: List[int | Undefined] +:type parent: list[int | Undefined] :param labels: the list of edge labels. -:type labels: List[int | Undefined] +:type labels: list[int | Undefined] :raises LibsemigroupsError: if *parent* and *labels* have different sizes; @@ -290,7 +290,7 @@ to *i*. :type i: int :returns: The word labelling the path from the root to *i*. -:rtype: List[int] +:rtype: list[int] :raises LibsemigroupsError: if *i* is greater than or equal to :any:`number_of_nodes`. diff --git a/src/freeband.cpp b/src/freeband.cpp index fc7da5ff3..00a07b204 100644 --- a/src/freeband.cpp +++ b/src/freeband.cpp @@ -47,9 +47,9 @@ in the generators of :math:`FB(A)` are the same as elements of the free band. :param x: the first word to compare in the free band. -:type x: List[int] +:type x: list[int] :param v: the second word to compare in the free band. -:type v: List[int] +:type v: list[int] :return: ``True`` if both words are the same as elements of the free band and diff --git a/src/froidure-pin-base.cpp b/src/froidure-pin-base.cpp index b2e7833c3..569645a49 100644 --- a/src/froidure-pin-base.cpp +++ b/src/froidure-pin-base.cpp @@ -574,7 +574,7 @@ path in the left Cayley graph from *j* labelled by py::arg("fp"), py::arg("pos"), R"pbdoc( -:sig=(fp: FroidurePin, pos: int) -> List[int]: +:sig=(fp: FroidurePin, pos: int) -> list[int]: Returns the short-lex least word representing an element given by index. @@ -589,7 +589,7 @@ This function returns the short-lex least word (in the generators) representing :type pos: int :returns: A minimal factorisation of the element with index *pos*. -:rtype: List[int] +:rtype: list[int] :raises LibsemigroupsError: if *pos* is not strictly less than :any:`FroidurePin.current_size`. @@ -618,7 +618,7 @@ This function returns the short-lex least word (in the generators) representing fp.cend_current_normal_forms()); }, R"pbdoc( -:sig=(fp: FroidurePin) -> Iterator[List[int]]: +:sig=(fp: FroidurePin) -> Iterator[list[int]]: Returns an iterator yielding the so-far enumerated normal forms (if any). @@ -633,9 +633,9 @@ complete set of rules, then use :any:`normal_forms` instead. FroidurePin :returns: - An iterator yielding a ``List[int]``. + An iterator yielding a ``list[int]``. :rtype: - Iterator[List[int]] + Iterator[list[int]] :complexity: Constant. @@ -648,7 +648,7 @@ complete set of rules, then use :any:`normal_forms` instead. fp.cend_current_rules()); }, R"pbdoc( -:sig=(fp: FroidurePin) -> Iterator[Tuple[List[int],List[int]]]: +:sig=(fp: FroidurePin) -> Iterator[Tuple[list[int],list[int]]]: Returns an iterator yielding the so-far enumerated rules. @@ -664,7 +664,7 @@ to obtain the complete set of rules, then use :any:`rules` instead. :returns: An iterator. -:rtype: Iterator[Tuple[List[int], List[int]]] +:rtype: Iterator[Tuple[list[int], list[int]]] :complexity: Constant @@ -715,7 +715,7 @@ to obtain the complete set of rules, then use :any:`rules` instead. fp.cend_normal_forms()); }, R"pbdoc( -:sig=(fp: FroidurePin) -> Iterator[List[int]]: +:sig=(fp: FroidurePin) -> Iterator[list[int]]: Returns an iterator yielding normal forms. This function returns an iterator yielding normal forms for the elements of the semigroup represented by @@ -731,7 +731,7 @@ then use :any:`current_normal_forms` instead. :returns: An iterator of normal forms. :rtype: - Iterator[List[int]] + Iterator[list[int]] )pbdoc"); m.def( @@ -740,7 +740,7 @@ then use :any:`current_normal_forms` instead. return py::make_iterator(fp.cbegin_rules(), fp.cend_rules()); }, R"pbdoc( -:sig=(fp: FroidurePin) -> Iterator[Tuple[List[int],List[int]]]: +:sig=(fp: FroidurePin) -> Iterator[Tuple[list[int],list[int]]]: Returns an iterator yielding the rules. @@ -758,7 +758,7 @@ use :any:`current_rules` instead. :returns: An iterator yielding rules. :rtype: - Iterator[Tuple[List[int],List[int]]]: + Iterator[Tuple[list[int],list[int]]]: )pbdoc"); } } // init_froidure_pin_base diff --git a/src/froidure-pin.cpp b/src/froidure-pin.cpp index 8caf5d5c7..2e1277e61 100644 --- a/src/froidure-pin.cpp +++ b/src/froidure-pin.cpp @@ -51,7 +51,7 @@ namespace libsemigroups { // overload is to be changed, :sig=...: should be specified in the // docstring of that py::init function. R"pbdoc( -:sig=(self: FroidurePin, gens: List[Element]) -> None: +:sig=(self: FroidurePin, gens: list[Element]) -> None: Class implementing the Froidure-Pin algorithm. @@ -107,7 +107,7 @@ Calling this function does not trigger any enumeration. }), py::arg("gens"), R"pbdoc( -:sig=(self: FroidurePin, gens: List[Element]) -> None: +:sig=(self: FroidurePin, gens: list[Element]) -> None: Construct from a list of generators. @@ -115,7 +115,7 @@ This function constructs a :any:`FroidurePin` instance with generators in the list *gens*. :param gens: the list of generators. -:type gens: List[Element] +:type gens: list[Element] :raises LibsemigroupsError: if the generators do not all have the same degree. )pbdoc"); @@ -181,14 +181,14 @@ elements than before (whether it is fully enumerating or not). }, py::arg("gens"), R"pbdoc( -:sig=(self: FroidurePin, gens: List[Element]) -> None: +:sig=(self: FroidurePin, gens: list[Element]) -> None: Add a list of generators. See :any:`add_generator` for a detailed description. :param gens: the list of generators. -:type gens: List[Element] +:type gens: list[Element] :returns: ``self``. :rtype: FroidurePin @@ -312,7 +312,7 @@ instance. }, py::arg("gens"), R"pbdoc( -:sig=(self: FroidurePin, gens: List[Element]) -> FroidurePin: +:sig=(self: FroidurePin, gens: list[Element]) -> FroidurePin: Add non-redundant generators in list. @@ -326,7 +326,7 @@ some previously computed information, such as the left or right Cayley graphs, or number of idempotents, for example. :param gens: the list of generators. -:type gens: List[Element] +:type gens: list[Element] :returns: ``self``. :rtype: FroidurePin @@ -365,7 +365,7 @@ instance and ``False`` if it does not. }, py::arg("gens"), R"pbdoc( -:sig=(self: FroidurePin, gens: List[Element]) -> FroidurePin: +:sig=(self: FroidurePin, gens: list[Element]) -> FroidurePin: Copy and add a list of generators. @@ -375,7 +375,7 @@ But this function avoids copying the parts of the initial instance that are immediately invalidated by :any:`FroidurePin.add_generators`. :param gens: the list of generators. -:type gens: List[Element] +:type gens: list[Element] :returns: A new :any:`FroidurePin` instance by value generated by the generators of @@ -399,7 +399,7 @@ immediately invalidated by :any:`FroidurePin.add_generators`. }, py::arg("gens"), R"pbdoc( -:sig=(self: FroidurePin, gens: List[Element]) -> FroidurePin: +:sig=(self: FroidurePin, gens: list[Element]) -> FroidurePin: Copy and add non-redundant generators. @@ -409,7 +409,7 @@ avoids copying the parts of the initial :any:`FroidurePin` instance that are immediately discarded by :any:`closure`. :param gens: the list of generators. -:type gens: List[Element] +:type gens: list[Element] :returns: A new :any:`FroidurePin` instance by value generated by the generators of @@ -520,7 +520,7 @@ This function re-initializes a :any:`FroidurePin` object so that it is in the same state as if it had just been constructed from *gens*. :param gens: the generators. -:type gens: List[Element] +:type gens: list[Element] :returns: ``self``. :rtype: FroidurePin @@ -728,7 +728,7 @@ elements are sorted, or :any:`UNDEFINED` if *i* is greater than py::arg("fpb"), py::arg("w"), R"pbdoc( -:sig=(self: FroidurePin, w: List[int]) -> int | Undefined: +:sig=(self: FroidurePin, w: list[int]) -> int | Undefined: :only-document-once: Returns the position corresponding to a word. @@ -742,7 +742,7 @@ determined. :type fp: FroidurePin :param w: a word in the generators. -:type w: List[int] +:type w: list[int] :returns: The current position of the element represented by a word. :rtype: int | Undefined @@ -763,7 +763,7 @@ determined. py::arg("x"), py::arg("y"), R"pbdoc( -:sig=(fp: FroidurePin, x: List[int], y: List[int]) -> bool: +:sig=(fp: FroidurePin, x: list[int], y: list[int]) -> bool: :only-document-once: Check equality of words in the generators. @@ -775,10 +775,10 @@ element of *fp* and ``False`` otherwise. :type fp: FroidurePin :param x: the first word for comparison. -:type x: List[int] +:type x: list[int] :param y: the second word for comparison. -:type y: List[int] +:type y: list[int] :returns: Whether or not the words *x* and *y* represent the same element. :rtype: bool @@ -800,7 +800,7 @@ element of *fp* and ``False`` otherwise. py::arg("fp"), py::arg("x"), R"pbdoc( -:sig=(fp: FroidurePin, x: Union[Element, int]) -> List[int]: +:sig=(fp: FroidurePin, x: Union[Element, int]) -> list[int]: :only-document-once: Returns a word containing a factorisation (in the generators) of an @@ -817,7 +817,7 @@ is that the resulting factorisation may not be minimal. :type x: Element | int :returns: Returns a word in the generators which evaluates to *x*. -:rtype: List[int] +:rtype: list[int] :raises LibsemigroupsError: if *x* is an ``Element`` and *x* does not belong to *fp*. @@ -843,7 +843,7 @@ is that the resulting factorisation may not be minimal. py::arg("fp"), py::arg("x"), R"pbdoc( -:sig=(fp: FroidurePin, x: Union[Element, int]) -> List[int]: +:sig=(fp: FroidurePin, x: Union[Element, int]) -> list[int]: :only-document-once: Returns a word containing a minimal factorisation (in the generators) @@ -859,7 +859,7 @@ that evaluates to *x*. :type x: Element | int :returns: A word in the generators that evaluates to *x*. -:rtype: List[int] +:rtype: list[int] :raises LibsemigroupsError: if *x* is an ``Element`` and *x* does not belong to *fp*. @@ -885,7 +885,7 @@ that evaluates to *x*. py::arg("fp"), py::arg("w"), R"pbdoc( -:sig=(fp: FroidurePin, x: List[int]) -> int: +:sig=(fp: FroidurePin, x: list[int]) -> int: :only-document-once: Returns the position corresponding to a word. @@ -897,7 +897,7 @@ full enumeration is triggered by calls to this function. :type fp: FroidurePin :param w: a word in the generators. -:type w: List[int] +:type w: list[int] :returns: The position of the element represented by a word. :rtype: int @@ -916,7 +916,7 @@ full enumeration is triggered by calls to this function. py::arg("fp"), py::arg("w").noconvert(), R"pbdoc( -:sig=(fp: FroidurePin, w: List[int]) -> Element: +:sig=(fp: FroidurePin, w: list[int]) -> Element: :only-document-once: Convert a word in the generators to an element. @@ -927,7 +927,7 @@ This function returns the element of *fp* obtained by evaluating *w*. :type fp: FroidurePin :param w: the word in the generators to evaluate. -:type w: List[int] +:type w: list[int] :returns: The element of *fp* corresponding to the word *w*. :rtype: Element diff --git a/src/gabow.cpp b/src/gabow.cpp index eb728ab88..1a87f166a 100644 --- a/src/gabow.cpp +++ b/src/gabow.cpp @@ -99,7 +99,7 @@ to construct the :any:`Gabow` instance. :type i: int :returns: The component with index *i*. -:rtype: List[int] +:rtype: list[int] :raises LibsemigroupsError: if there is *i* is greater than or equal to @@ -126,7 +126,7 @@ construct the :any:`Gabow` instance. :type n: int :returns: The component of the node *n*. -:rtype: List[int] +:rtype: list[int] :raises LibsemigroupsError: if *n* is greater than or equal to ``word_graph().number_of_nodes()``. @@ -146,7 +146,7 @@ construct the :any:`Gabow` instance. :returns: The strongly connected components of :any:`Gabow.word_graph`. :rtype: - List[List[int]] + list[list[int]] .. note:: This function triggers the computation of the strongly connected diff --git a/src/knuth-bendix-impl.cpp b/src/knuth-bendix-impl.cpp index 611faec93..859520745 100644 --- a/src/knuth-bendix-impl.cpp +++ b/src/knuth-bendix-impl.cpp @@ -452,7 +452,7 @@ The semigroup is finite if the graph is acyclic, and infinite otherwise. thing.def("gilman_graph_node_labels", &KnuthBendixImpl::gilman_graph_node_labels, R"pbdoc( -:sig=(self: KnuthBendix) -> List[str]: +:sig=(self: KnuthBendix) -> list[str]: Return the node labels of the Gilman :py:class:`WordGraph` @@ -460,7 +460,7 @@ Return the node labels of the Gilman :py:class:`WordGraph`, corresponding to the unique prefixes of the left-hand sides of the rules of the rewriting system. :return: The node labels of the Gilman :py:class:`WordGraph` -:rtype: List[str] +:rtype: list[str] .. seealso:: :any:`gilman_graph`. )pbdoc", diff --git a/src/knuth-bendix.cpp b/src/knuth-bendix.cpp index 175846944..a8dfca4b7 100644 --- a/src/knuth-bendix.cpp +++ b/src/knuth-bendix.cpp @@ -148,7 +148,6 @@ construct *kb*. This function triggers a full enumeration of *kb*. >>> from libsemigroups_pybind11 import (KnuthBendix, Presentation, ... presentation, congruence_kind, knuth_bendix) - >>> from typing import List >>> p = Presentation("abc") >>> presentation.add_rule(p, "aaaa", "a") >>> presentation.add_rule(p, "bbbb", "b") @@ -192,7 +191,7 @@ before those overlaps of length :math:`n + 1`. py::arg("kb1"), py::arg("kb2"), R"pbdoc( -:sig=(kb1: KnuthBendix, kb2: KnuthBendix) -> List[List[List[int]] | List[str]]: +:sig=(kb1: KnuthBendix, kb2: KnuthBendix) -> list[list[list[int]] | list[str]]: :only-document-once: Find the non-trivial classes of the quotient of one @@ -216,7 +215,7 @@ classes. :type kb2: KnuthBendix :returns: The non-trivial classes of *kb1* in *kb2*. -:rtype: List[List[List[int]] | List[str]] +:rtype: list[list[list[int]] | list[str]] :raises LibsemigroupsError: if *kb1* has infinitely many classes and *kb2* has finitely many classes (so @@ -237,7 +236,6 @@ classes. >>> from libsemigroups_pybind11 import (knuth_bendix, presentation, ... Presentation, congruence_kind, KnuthBendix) - >>> from typing import List >>> p = Presentation("abc") >>> p.rules = ["ab", "ba", "ac", "ca", "aa", "a", "ac", "a", "ca", ... "a", "bc", "cb", "bbb", "b", "bc", "b", "cb", "b"] @@ -289,7 +287,7 @@ Check if the all rules are reduced with respect to each other. return {}; }, R"pbdoc( -:sig=(p: Presentation, t: datetime.timedelta) -> Tuple[List[int], List[int]] | Tuple[str, str] | None: +:sig=(p: Presentation, t: datetime.timedelta) -> Tuple[list[int], list[int]] | Tuple[str, str] | None: :only-document-once: Return a redundant rule or ``None``. @@ -310,7 +308,7 @@ redundant in this way, then ``None`` is returned. :type t: datetime.timedelta :returns: A redundant rule or ``None``. -:rtype: Tuple[List[int], List[int]] | Tuple[str, str] | None +:rtype: Tuple[list[int], list[int]] | Tuple[str, str] | None .. warning:: The progress of the Knuth-Bendix algorithm may differ between @@ -344,8 +342,9 @@ redundant in this way, then ``None`` is returned. return {}; }, R"pbdoc( -:sig=(p: Presentation, t: datetime.timedelta) -> Tuple[List[int], List[int]] | Tuple[str, str] | None: +:sig=(p: Presentation, t: datetime.timedelta) -> Tuple[list[int], list[int]] | Tuple[str, str] | None: :only-document-once: +TODO where's the doc? )pbdoc"); } // bind_knuth_bendix diff --git a/src/konieczny.cpp b/src/konieczny.cpp index cb1dd59e4..85a984b88 100644 --- a/src/konieczny.cpp +++ b/src/konieczny.cpp @@ -88,7 +88,7 @@ unspecified generators. }), py::arg("gens"), R"pbdoc( -:sig=(self: Konieczny, gens: List[Element]) -> None: +:sig=(self: Konieczny, gens: list[Element]) -> None: Construct from generators. @@ -99,7 +99,7 @@ words, the generators are precisely (a copy of) *gens* in the same order they occur in *gens*. :param gens: the generators represented by this. -:type gens: List[Element] +:type gens: list[Element] :raises LibsemigroupsError: if *gens* is empty. :raises LibsemigroupsError: @@ -132,14 +132,14 @@ times. }, py::arg("coll"), R"pbdoc( -:sig=(self: Konieczny, coll: List[Element]) -> None: +:sig=(self: Konieczny, coll: list[Element]) -> None: Add collection of generators from a list. See :any:`Konieczny.add_generator` for a detailed description. :param coll: the collection of generators to add. -:type coll: List[Element] +:type coll: list[Element] :raises LibsemigroupsError: the degree of any item in *coll* is incompatible diff --git a/src/libsemigroups_pybind11/action.py b/src/libsemigroups_pybind11/action.py index 808b8ec47..44d81f656 100644 --- a/src/libsemigroups_pybind11/action.py +++ b/src/libsemigroups_pybind11/action.py @@ -175,9 +175,7 @@ class Action(_CxxWrapper): # pylint: disable=missing-class-docstring ######################################################################## # pylint: disable=redefined-outer-name - def __init__( - self: _Self, *args, generators=None, seeds=None, func=None, side=None - ) -> None: + def __init__(self: _Self, *args, generators=None, seeds=None, func=None, side=None) -> None: """ :sig=(self: Action, generators=None, seeds=None, func=None, side=None) -> None: @@ -185,8 +183,8 @@ def __init__( :Keyword Arguments: - * **generators** (*List[Element]*)-- at least one generator for the action. - * **seeds** (*List[Point]*) -- at least one seed point for the action. + * **generators** (*list[Element]*)-- at least one generator for the action. + * **seeds** (*list[Point]*) -- at least one seed point for the action. * **func** (*Callable[[Point, Element], Point]*) -- the function defining the action. * **side** (:py:class:`side `)-- the side of the action. @@ -209,9 +207,7 @@ def __init__( if _to_cxx(self) is not None: return if len(args) != 0: - raise ValueError( - f"expected 0 positional arguments, but found {len(args)}" - ) + raise ValueError(f"expected 0 positional arguments, but found {len(args)}") if not isinstance(generators, list): raise TypeError( "expected the keyword argument 'generators' to be " @@ -274,9 +270,7 @@ def generators(self: _Self) -> Iterator[Element]: _copy_cxx_mem_fns(_RightActionPPerm1PPerm1, Action) -for ( - _type -) in ( +for _type in ( Action._py_template_params_to_cxx_type.values() # pylint: disable=protected-access ): _register_cxx_wrapped_type(_type, Action) @@ -304,8 +298,8 @@ def __init__(self: _Self, *args, generators=None, seeds=None) -> None: :Keyword Arguments: - * **generators** (*List[Element]*)-- at least one generator for the action. - * **seeds** (*List[Point]*) -- at least one seed point for the action. + * **generators** (*list[Element]*)-- at least one generator for the action. + * **seeds** (*list[Point]*) -- at least one seed point for the action. :raises TypeError: if *generators* or *seeds* is not a list. @@ -346,8 +340,8 @@ def __init__(self: _Self, *args, generators=None, seeds=None) -> None: :Keyword Arguments: - * **generators** (*List[Element]*)-- at least one generator for the action. - * **seeds** (*List[Point]*) -- at least one seed point for the action. + * **generators** (*list[Element]*)-- at least one generator for the action. + * **seeds** (*list[Point]*) -- at least one seed point for the action. :raises TypeError: if *generators* or *seeds* is not a list. diff --git a/src/libsemigroups_pybind11/congruence.py b/src/libsemigroups_pybind11/congruence.py index d5e82dc53..21c534b82 100644 --- a/src/libsemigroups_pybind11/congruence.py +++ b/src/libsemigroups_pybind11/congruence.py @@ -12,7 +12,7 @@ the submodule ``congruence``. """ -from typing import List, Union +from typing import Union from typing_extensions import Self as _Self from _libsemigroups_pybind11 import ( # pylint: disable=no-name-in-module @@ -43,7 +43,7 @@ class Congruence(_CongruenceCommon): # pylint: disable=missing-class-docstring __doc__ = _CongruenceWord.__doc__ _py_template_params_to_cxx_type = { - (List[int],): _CongruenceWord, + (list[int],): _CongruenceWord, (str,): _CongruenceString, } @@ -71,9 +71,7 @@ def __init__(self: _Self, *args, **kwargs) -> None: ) self.init_cxx_obj(*args) - def get( - self: _Self, t: type - ) -> Union[_Kambites, _KnuthBendix, _ToddCoxeter]: + def get(self: _Self, t: type) -> Union[_Kambites, _KnuthBendix, _ToddCoxeter]: """ :sig=(self: Congruence, t: type) -> Kambites | KnuthBendix | ToddCoxeter: Returns the *t* instance used to compute the congruence (if any). diff --git a/src/libsemigroups_pybind11/detail/congruence_common.py b/src/libsemigroups_pybind11/detail/congruence_common.py index f9f79d36a..ed902c48d 100644 --- a/src/libsemigroups_pybind11/detail/congruence_common.py +++ b/src/libsemigroups_pybind11/detail/congruence_common.py @@ -11,7 +11,6 @@ Kambites, KnuthBendix, and ToddCoxeter. """ -from typing import List from typing_extensions import Self from _libsemigroups_pybind11 import ( # pylint: disable=no-name-in-module @@ -41,9 +40,7 @@ def __init__(self: Self, *args, wrong_num_args_msg="", **kwargs) -> None: # checks that we have 0 args and 1 kwarg or 2 args and 0 kwargs, and # that the types of these are correct if len(args) not in (0, 2): - raise TypeError( - f"expected 0 or 2 positional arguments, found {len(args)}" - ) + raise TypeError(f"expected 0 or 2 positional arguments, found {len(args)}") if len(args) != 0 and len(kwargs) != 0: if len(wrong_num_args_msg) == 0: wrong_num_args_msg = ( @@ -52,9 +49,9 @@ def __init__(self: Self, *args, wrong_num_args_msg="", **kwargs) -> None: ) raise TypeError(wrong_num_args_msg) if len(args) == 0: - if kwargs["Word"] not in (str, List[int]): + if kwargs["Word"] not in (str, list[int]): raise ValueError( - 'expected the keyword argument "Word" to be "str" or "List[int]" ' + 'expected the keyword argument "Word" to be "str" or "list[int]" ' f"but found {kwargs['Word']}" ) self.py_template_params = (kwargs["Word"],) diff --git a/src/libsemigroups_pybind11/kambites.py b/src/libsemigroups_pybind11/kambites.py index 0562c521f..ac424544f 100644 --- a/src/libsemigroups_pybind11/kambites.py +++ b/src/libsemigroups_pybind11/kambites.py @@ -11,7 +11,6 @@ contains helper functions for the :any:`Kambites` class. """ -from typing import List from typing_extensions import Self from _libsemigroups_pybind11 import ( # pylint: disable=no-name-in-module @@ -45,7 +44,7 @@ class Kambites(_CongruenceCommon): # pylint: disable=missing-class-docstring __doc__ = _KambitesWord.__doc__ _py_template_params_to_cxx_type = { - (List[int],): _KambitesWord, + (list[int],): _KambitesWord, (str,): _KambitesMultiStringView, } diff --git a/src/libsemigroups_pybind11/knuth_bendix.py b/src/libsemigroups_pybind11/knuth_bendix.py index b53de2134..6a97392c7 100644 --- a/src/libsemigroups_pybind11/knuth_bendix.py +++ b/src/libsemigroups_pybind11/knuth_bendix.py @@ -12,8 +12,6 @@ are contained in the submodule ``knuth_bendix``. """ -from typing import List - from _libsemigroups_pybind11 import ( # pylint: disable=no-name-in-module KnuthBendixStringRewriteFromLeft as _KnuthBendixStringRewriteFromLeft, KnuthBendixStringRewriteTrie as _KnuthBendixStringRewriteTrie, @@ -54,9 +52,9 @@ class KnuthBendix(_CongruenceCommon): # pylint: disable=missing-class-docstring __doc__ = _KnuthBendixStringRewriteTrie.__doc__ _py_template_params_to_cxx_type = { - (List[int], "RewriteTrie"): _KnuthBendixWordRewriteTrie, + (list[int], "RewriteTrie"): _KnuthBendixWordRewriteTrie, (str, "RewriteTrie"): _KnuthBendixStringRewriteTrie, - (List[int], "RewriteFromLeft"): _KnuthBendixWordRewriteFromLeft, + (list[int], "RewriteFromLeft"): _KnuthBendixWordRewriteFromLeft, (str, "RewriteFromLeft"): _KnuthBendixStringRewriteFromLeft, } @@ -91,9 +89,7 @@ def __init__(self, *args, Rewriter="RewriteTrie", **kwargs) -> None: return if len(args) == 2: if isinstance(args[1], _Presentation): - self.py_template_params = args[1].py_template_params + ( - Rewriter, - ) + self.py_template_params = args[1].py_template_params + (Rewriter,) else: raise TypeError( f"expected the 2nd argument to be a Presentation, but found {type(args[1])}" diff --git a/src/libsemigroups_pybind11/matrix.py b/src/libsemigroups_pybind11/matrix.py index d7673e66f..20bb51e82 100644 --- a/src/libsemigroups_pybind11/matrix.py +++ b/src/libsemigroups_pybind11/matrix.py @@ -12,7 +12,7 @@ """ from enum import Enum as _Enum -from typing import Union, List +from typing import Union from _libsemigroups_pybind11 import ( # pylint: disable=no-name-in-module,unused-import BMat as _BMat, @@ -72,11 +72,7 @@ def _convert_matrix_args(*args): *args[:-1], [ [ - ( - z.to_int() - if isinstance(z, (_PositiveInfinity, _NegativeInfinity)) - else z - ) + (z.to_int() if isinstance(z, (_PositiveInfinity, _NegativeInfinity)) else z) for z in y ] for y in args[-1] @@ -98,8 +94,8 @@ def _convert_cxx_entry_to_py( def _convert_cxx_row_to_py( - row: List[int], -) -> List[Union[int, _PositiveInfinity, _NegativeInfinity]]: + row: list[int], +) -> list[Union[int, _PositiveInfinity, _NegativeInfinity]]: # TODO remove this, sink into C++ for i, val in enumerate(row): row[i] = _convert_cxx_entry_to_py(val) @@ -107,8 +103,8 @@ def _convert_cxx_row_to_py( def _convert_cxx_rows_to_py( - rows: List[int], -) -> List[List[Union[int, _PositiveInfinity, _NegativeInfinity]]]: + rows: list[int], +) -> list[list[Union[int, _PositiveInfinity, _NegativeInfinity]]]: # TODO remove this, sink into C++ for i, val in enumerate(rows): rows[i] = _convert_cxx_row_to_py(val) @@ -148,7 +144,7 @@ def row_basis(x): and :math:`c` is the number of columns in ``x``. :returns: A basis for the row space of *x*. - :rtype: List[List[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]] + :rtype: list[list[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]] """ return _convert_cxx_rows_to_py(_row_basis(x)) diff --git a/src/libsemigroups_pybind11/presentation/__init__.py b/src/libsemigroups_pybind11/presentation/__init__.py index 950e130ad..2bae452bd 100644 --- a/src/libsemigroups_pybind11/presentation/__init__.py +++ b/src/libsemigroups_pybind11/presentation/__init__.py @@ -10,7 +10,7 @@ The full API for :any:`Presentation` helper functions is given below. """ -from typing import List, Any as _Any, Union +from typing import Any as _Any, Union from typing_extensions import Self from _libsemigroups_pybind11 import ( # pylint: disable=no-name-in-module @@ -73,7 +73,7 @@ class Presentation(_CxxWrapper): # pylint: disable=missing-class-docstring __doc__ = _PresentationStrings.__doc__ _py_template_params_to_cxx_type = { - (List[int],): _PresentationWords, + (list[int],): _PresentationWords, (str,): _PresentationStrings, } @@ -128,7 +128,7 @@ def __init__(self: Self, *args, **kwargs) -> None: if isinstance(args[0], str): self.py_template_params = (str,) if isinstance(args[0], list): - self.py_template_params = (List[int],) + self.py_template_params = (list[int],) if len(args) == 0 or not isinstance(args[0], Presentation): assert self.py_template_params is not None @@ -139,12 +139,12 @@ def __init__(self: Self, *args, **kwargs) -> None: @_copydoc(_PresentationWords.rules) @property - def rules(self: Self) -> List[Union[List[int], str]]: + def rules(self: Self) -> list[Union[list[int], str]]: # pylint: disable=missing-function-docstring return _to_cxx(self).rules @rules.setter - def rules(self: Self, val: List[Union[List[int], str]]) -> None: + def rules(self: Self, val: list[Union[list[int], str]]) -> None: _to_cxx(self).rules = val @@ -162,7 +162,7 @@ class InversePresentation(Presentation): __doc__ = _InversePresentationStrings.__doc__ _py_template_params_to_cxx_type = { - (List[int],): _InversePresentationWords, + (list[int],): _InversePresentationWords, (str,): _InversePresentationStrings, (Presentation,): Union[_InversePresentationWords, _InversePresentationStrings], } diff --git a/src/libsemigroups_pybind11/sims.py b/src/libsemigroups_pybind11/sims.py index 9647d1eaa..5dbad3101 100644 --- a/src/libsemigroups_pybind11/sims.py +++ b/src/libsemigroups_pybind11/sims.py @@ -11,7 +11,6 @@ The full API for the helper functions is given below. """ -from typing import List from typing_extensions import Self as _Self from _libsemigroups_pybind11 import ( # pylint: disable=no-name-in-module @@ -51,17 +50,13 @@ def __init__(self: _Self, *args, **kwargs) -> None: if _to_cxx(self) is not None: return if len(args) not in (0, 1): - raise TypeError( - f"expected 0 or 1 positional arguments but found {len(args)}" - ) + raise TypeError(f"expected 0 or 1 positional arguments but found {len(args)}") if len(kwargs) != 0: - raise TypeError( - f"expected 0 keyword arguments, but found {len(kwargs)}" - ) + raise TypeError(f"expected 0 keyword arguments, but found {len(kwargs)}") if len(args) == 0: # self.Word = kwargs["Word"] - self.py_template_params = (List[int],) + self.py_template_params = (list[int],) else: if isinstance(args[0], _Presentation): self.py_template_params = args[0].py_template_params @@ -81,7 +76,7 @@ class Sims1(_SimsBase): # pylint: disable=missing-class-docstring __doc__ = _Sims1.__doc__ _py_template_params_to_cxx_type = { - (List[int],): _Sims1, + (list[int],): _Sims1, } _cxx_to_py_type_dict = dict( @@ -110,7 +105,7 @@ class Sims2(_SimsBase): # pylint: disable=missing-class-docstring __doc__ = _Sims2.__doc__ _py_template_params_to_cxx_type = { - (List[int],): _Sims2, + (list[int],): _Sims2, } _cxx_type_to_py_template_params = dict( @@ -139,7 +134,7 @@ class RepOrc(_SimsBase): # pylint: disable=missing-class-docstring __doc__ = _RepOrc.__doc__ _py_template_params_to_cxx_type = { - (List[int],): _RepOrc, + (list[int],): _RepOrc, } _cxx_type_to_py_template_params = dict( @@ -168,7 +163,7 @@ class MinimalRepOrc(_SimsBase): # pylint: disable=missing-class-docstring __doc__ = _MinimalRepOrc.__doc__ _py_template_params_to_cxx_type = { - (List[int],): _MinimalRepOrc, + (list[int],): _MinimalRepOrc, } _cxx_type_to_py_template_params = dict( @@ -198,7 +193,7 @@ class SimsRefinerIdeals(_SimsBase): # pylint: disable=missing-class-docstring __doc__ = _SimsRefinerIdeals.__doc__ _py_template_params_to_cxx_type = { - (List[int],): _SimsRefinerIdeals, + (list[int],): _SimsRefinerIdeals, } _cxx_type_to_py_template_params = dict( @@ -223,13 +218,11 @@ def __init__(self: _Self, *args, **kwargs) -> None: ######################################################################## -class SimsRefinerFaithful( - _CxxWrapper -): # pylint: disable=missing-class-docstring +class SimsRefinerFaithful(_CxxWrapper): # pylint: disable=missing-class-docstring __doc__ = _SimsRefinerFaithful.__doc__ _py_template_params_to_cxx_type = { - (List[int],): _SimsRefinerFaithful, + (list[int],): _SimsRefinerFaithful, } _cxx_type_to_py_template_params = dict( @@ -249,7 +242,7 @@ def __init__(self: _Self, *args, **kwargs) -> None: if len(args) == 0: # self.Word = kwargs["Word"] - self.py_template_params = (List[int],) + self.py_template_params = (list[int],) else: assert len(args) == 1 if ( @@ -257,11 +250,9 @@ def __init__(self: _Self, *args, **kwargs) -> None: and all(isinstance(x, list) for x in args[0]) and all(isinstance(y, int) for x in args[0] for y in x) ): - self.py_template_params = (List[int],) + self.py_template_params = (list[int],) else: - raise TypeError( - "expected the 1st argument to be a List[List[int]]" - ) + raise TypeError("expected the 1st argument to be a list[list[int]]") self.init_cxx_obj(*args) diff --git a/src/libsemigroups_pybind11/to.py b/src/libsemigroups_pybind11/to.py index f6220653f..2fecc0ce7 100644 --- a/src/libsemigroups_pybind11/to.py +++ b/src/libsemigroups_pybind11/to.py @@ -11,7 +11,7 @@ ``libsemigroups_pybind11`` objects from one type to another. """ -from typing import List, _GenericAlias +from typing import _GenericAlias from _libsemigroups_pybind11 import ( # pylint: disable=no-name-in-module to_congruence_string as _to_congruence_string, @@ -69,22 +69,22 @@ def _nice_name(type_list): _RETURN_TYPE_TO_CONVERTER_FUNCTION = { (_Congruence, str): _to_congruence_string, - (_Congruence, List[int]): _to_congruence_word, + (_Congruence, list[int]): _to_congruence_word, (_FroidurePin,): _to_froidure_pin, (_InversePresentation,): _to_inverse_presentation, - (_InversePresentation, List[int]): _to_inverse_presentation_word, + (_InversePresentation, list[int]): _to_inverse_presentation_word, (_InversePresentation, str): _to_inverse_presentation_string, (_KnuthBendix,): _to_knuth_bendix, (_KnuthBendix, "RewriteTrie"): _to_knuth_bendix_RewriteTrie, (_KnuthBendix, "RewriteFromLeft"): _to_knuth_bendix_RewriteFromLeft, ( _KnuthBendix, - List[int], + list[int], "RewriteFromLeft", ): _to_knuth_bendix_word_RewriteFromLeft, ( _KnuthBendix, - List[int], + list[int], "RewriteTrie", ): _to_knuth_bendix_word_RewriteTrie, ( @@ -95,10 +95,10 @@ def _nice_name(type_list): (_KnuthBendix, str, "RewriteTrie"): _to_knuth_bendix_string_RewriteTrie, (_Presentation,): _to_presentation, (_Presentation, str): _to_presentation_string, - (_Presentation, List[int]): _to_presentation_word, + (_Presentation, list[int]): _to_presentation_word, (_ToddCoxeter,): _to_todd_coxeter, (_ToddCoxeter, str): _to_todd_coxeter_string, - (_ToddCoxeter, List[int]): _to_todd_coxeter_word, + (_ToddCoxeter, list[int]): _to_todd_coxeter_word, } _VALID_TYPES = (_nice_name(x) for x in _RETURN_TYPE_TO_CONVERTER_FUNCTION) diff --git a/src/libsemigroups_pybind11/todd_coxeter.py b/src/libsemigroups_pybind11/todd_coxeter.py index f42a3d93c..f0ea8542c 100644 --- a/src/libsemigroups_pybind11/todd_coxeter.py +++ b/src/libsemigroups_pybind11/todd_coxeter.py @@ -12,7 +12,6 @@ are contained in the subpackage ``todd_coxeter``. """ -from typing import List from typing_extensions import Self as _Self from _libsemigroups_pybind11 import ( # pylint: disable=no-name-in-module @@ -48,7 +47,7 @@ class ToddCoxeter(_CongruenceCommon): # pylint: disable=missing-class-docstring __doc__ = _ToddCoxeterWord.__doc__ _py_template_params_to_cxx_type = { - (List[int],): _ToddCoxeterWord, + (list[int],): _ToddCoxeterWord, (str,): _ToddCoxeterString, } @@ -72,7 +71,7 @@ def __init__(self: _Self, *args, **kwargs) -> None: if isinstance(args[1], _Presentation): self.py_template_params = args[1].py_template_params elif isinstance(args[1], _WordGraph): - self.py_template_params = (List[int],) + self.py_template_params = (list[int],) elif isinstance(args[1], ToddCoxeter): self.py_template_params = args[1].py_template_params else: diff --git a/src/libsemigroups_pybind11/transf.py b/src/libsemigroups_pybind11/transf.py index 18c3ee5bb..f694cf551 100644 --- a/src/libsemigroups_pybind11/transf.py +++ b/src/libsemigroups_pybind11/transf.py @@ -14,7 +14,7 @@ import abc -from typing import Any as _Any, List, Union +from typing import Any as _Any, Union from typing_extensions import Self from _libsemigroups_pybind11 import ( # pylint: disable=no-name-in-module @@ -182,7 +182,7 @@ class Transf(_PTransfBase): # pylint: disable=missing-class-docstring # This method only exists to copy the doc. . . @_copydoc(_Transf1.__init__) - def __init__(self: Self, imgs: List[int]) -> None: + def __init__(self: Self, imgs: list[int]) -> None: super().__init__(imgs) # We retain a separate __repr__ so that we can distinguish the cxx objects @@ -323,7 +323,7 @@ class Perm(_PTransfBase): # pylint: disable=missing-class-docstring # This method only exists to copy the doc. . . @_copydoc(_Perm1.__init__) - def __init__(self: Self, imgs: List[int]) -> None: + def __init__(self: Self, imgs: list[int]) -> None: super().__init__(imgs) # We retain a separate __repr__ so that we can distinguish the cxx objects diff --git a/src/matrix.cpp b/src/matrix.cpp index 4470dd924..7f6ebf720 100644 --- a/src/matrix.cpp +++ b/src/matrix.cpp @@ -396,7 +396,7 @@ Construct a matrix from rows. :type kind: MatrixKind :param rows: the rows of the matrix. -:type rows: List[List[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]] +:type rows: list[list[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]] :raise RunTimeError: if *kind* is :py:attr:`MatrixKind.MaxPlusTrunc`, @@ -569,7 +569,7 @@ the size of the row space of the boolean matrix *x*. }, py::arg("x"), R"pbdoc( -:sig=(x:Matrix)->List[List[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]]: +:sig=(x:Matrix)->list[list[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]]: Returns a row space basis of a matrix as a list of lists. The matrix *x* which must be one of: @@ -587,7 +587,7 @@ of rows. and :math:`c` is the number of columns in ``x``. :returns: A basis for the row space of *x*. -:rtype: List[List[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]] +:rtype: list[list[int | POSITIVE_INFINITY | NEGATIVE_INFINITY]] )pbdoc"); m.def("row_basis", [](MaxPlusTruncMat<0, 0, 0, int64_t> const& x) { std::vector> result; diff --git a/src/order.cpp b/src/order.cpp index 1e2720c9f..9cae51394 100644 --- a/src/order.cpp +++ b/src/order.cpp @@ -84,15 +84,15 @@ The valid values are: py::arg("x"), py::arg("y"), R"pbdoc( -:sig=(x: str | List[int], y: str | List[int]) -> bool: +:sig=(x: str | list[int], y: str | list[int]) -> bool: :only-document-once: -Compare two values of type :any:`str` or ``List[int]`` using using lexicographical ordering. +Compare two values of type :any:`str` or ``list[int]`` using using lexicographical ordering. :param x: the first object for comparison. -:type x: str | List[int] +:type x: str | list[int] :param y: the second object for comparison. -:type y: str | List[int] +:type y: str | list[int] :returns: The boolean value ``True`` if *x* is lexicographically less than *y*, and ``False`` otherwise. :rtype: bool @@ -108,7 +108,7 @@ Compare two values of type :any:`str` or ``List[int]`` using using lexicographic py::arg("x"), py::arg("y"), R"pbdoc( -:sig=(x: str | List[int], y: str | List[int]) -> bool: +:sig=(x: str | list[int], y: str | list[int]) -> bool: :only-document-once: )pbdoc"); @@ -120,15 +120,15 @@ Compare two values of type :any:`str` or ``List[int]`` using using lexicographic py::arg("x"), py::arg("y"), R"pbdoc( -:sig=(x: str | List[int], y: str | List[int]) -> bool: +:sig=(x: str | list[int], y: str | list[int]) -> bool: :only-document-once: -Compare two values of type :any:`str` or ``List[int]`` using shortlex ordering. +Compare two values of type :any:`str` or ``list[int]`` using shortlex ordering. :param x: the first object for comparison. -:type x: str | List[int] +:type x: str | list[int] :param y: the second object for comparison. -:type y: str | List[int] +:type y: str | list[int] :returns: The boolean value ``True`` if *x`* is short-lex less than *y*, and ``False`` otherwise. :rtype: bool @@ -144,7 +144,7 @@ Compare two values of type :any:`str` or ``List[int]`` using shortlex ordering. py::arg("x"), py::arg("y"), R"pbdoc( -:sig=(x: str | List[int], y: str | List[int]) -> bool: +:sig=(x: str | list[int], y: str | list[int]) -> bool: :only-document-once: )pbdoc"); @@ -156,11 +156,11 @@ Compare two values of type :any:`str` or ``List[int]`` using shortlex ordering. py::arg("x"), py::arg("y"), R"pbdoc( -:sig=(x: str | List[int], y: str | List[int]) -> bool: +:sig=(x: str | list[int], y: str | list[int]) -> bool: :only-document-once: -Compare two values of type :any:`str` or ``List[int]`` using recursive-path ordering. +Compare two values of type :any:`str` or ``list[int]`` using recursive-path ordering. -Compare two values of type :any:`str` or ``List[int]`` using the recursive path comparison described in :cite:`Jantzen2012aa` (Definition 1.2.14, page 24). +Compare two values of type :any:`str` or ``list[int]`` using the recursive path comparison described in :cite:`Jantzen2012aa` (Definition 1.2.14, page 24). If :math:`u, v\in X ^ {*}`, :math:`u \neq v`, and :math:`u = a'u`, :math:`v = bv'` for some :math:`a,b \in X`, :math:`u',v'\in X ^ {*}`, then @@ -174,10 +174,10 @@ This documentation and the implementation of :any:`recursive_path_compare` is based on the source code of :cite:`Holt2018aa`. :param x: the first object for comparison. -:type x: str | List[int] +:type x: str | list[int] :param y: the second object for comparison. -:type y: str | List[int] +:type y: str | list[int] :returns: The boolean value ``True`` if *x* is less than *y* with respect to the recursive path ordering, and ``False`` otherwise. :rtype: bool @@ -193,7 +193,7 @@ is based on the source code of :cite:`Holt2018aa`. py::arg("x"), py::arg("y"), R"pbdoc( -:sig=(x: str | List[int], y: str | List[int]) -> bool: +:sig=(x: str | list[int], y: str | list[int]) -> bool: :only-document-once: )pbdoc"); } diff --git a/src/paths.cpp b/src/paths.cpp index 3a0c1cf80..6981c498a 100644 --- a/src/paths.cpp +++ b/src/paths.cpp @@ -198,7 +198,7 @@ Get the current path in the range. :returns: The current path. :rtype: - List[int] + list[int] :raises LibsemigroupsError: if ``source() == UNDEFINED``. )pbdoc"); diff --git a/src/pbr.cpp b/src/pbr.cpp index c8f896bf9..8bfa8b9e9 100644 --- a/src/pbr.cpp +++ b/src/pbr.cpp @@ -68,10 +68,10 @@ adjacent to ``i`` in the :any:`PBR`, and the vector in position ``i`` of A negative value ``i`` corresponds to ``n - i``. :param left: container of adjacencies of ``1`` to ``n`` -:type left: List[List[int]] +:type left: list[list[int]] :param right: container of adjacencies of ``n + 1`` to ``2n``. -:type right: List[List[int]] +:type right: list[list[int]] :raises LibsemigroupsError: if the resultant PBR: @@ -90,7 +90,7 @@ and the vector in position ``i`` is the list of points adjacent to ``i`` in the :any:`PBR` constructed. :param x: the container of vectors of adjacencies. -:type x: List[List[int]] +:type x: list[list[int]] :raises LibsemigroupsError: if the resultant PBR: diff --git a/src/presentation-examples.cpp b/src/presentation-examples.cpp index e0d936124..b5702e8ad 100644 --- a/src/presentation-examples.cpp +++ b/src/presentation-examples.cpp @@ -126,7 +126,7 @@ degree *n*, as in Theorem 41 of :cite:`East2011aa`. &examples::sigma_plactic_monoid_AHMNT24, py::arg("sigma"), R"pbdoc( -:sig=(sigma: List[int]) -> Presentation: +:sig=(sigma: list[int]) -> Presentation: A presentation for the :math:`\sigma`-plactic monoid. This function returns a presentation for the :math:`\sigma`-plactic monoid with @@ -1704,7 +1704,7 @@ includes the rules from :any:`plactic_monoid_Knu70`. &examples::sigma_plactic_monoid, py::arg("sigma"), R"pbdoc( -:sig=(sigma: List[int]) -> Presentation: +:sig=(sigma: list[int]) -> Presentation: A presentation for the :math:`\sigma`-plactic monoid. This function returns a presentation for the :math:`\sigma`-plactic monoid with diff --git a/src/schreier-sims.cpp b/src/schreier-sims.cpp index 492ecd55b..410753f84 100644 --- a/src/schreier-sims.cpp +++ b/src/schreier-sims.cpp @@ -63,7 +63,7 @@ acting on a relatively small number of points (< 1000). return to_human_readable_repr(S); }); thing.def(py::init<>(), R"pbdoc( -:sig=(self: SchreierSims, gens: List[Element]) -> None: +:sig=(self: SchreierSims, gens: list[Element]) -> None: Construct from a list of generators. @@ -71,7 +71,7 @@ This function constructs a :any:`SchreierSims` instance with generators in the list *gens*. :param gens: the list of generators. -:type gens: List[Element] +:type gens: list[Element] :raises LibsemigroupsError: if the generators do not have degree equal to :math:`255` or :math:`511`, or the number of generators exceeds the diff --git a/src/sims.cpp b/src/sims.cpp index 9c09b75f1..783237030 100644 --- a/src/sims.cpp +++ b/src/sims.cpp @@ -235,7 +235,7 @@ only taken among those whose word graphs are accepted by all pruners returned by :py:meth:`~Sims1.pruners`. :returns: A list of boolean functions on word graphs, the set of all pruners. -:rtype: List[Callable[[WordGraph], bool]] +:rtype: list[Callable[[WordGraph], bool]] )pbdoc", py::return_value_policy::reference_internal); diff --git a/src/stephen.cpp b/src/stephen.cpp index 4d8f90c48..9c581308e 100644 --- a/src/stephen.cpp +++ b/src/stephen.cpp @@ -217,14 +217,14 @@ Get the input presentation. }, py::arg("word"), R"pbdoc( -:sig=(self: Stephen, word: List[int]) -> Stephen: +:sig=(self: Stephen, word: list[int]) -> Stephen: Set the initial word. This function sets the word whose left factors, or equivalent words, are sought. :param word: the word to be set. -:type word: List[int] +:type word: list[int] :returns: ``self``. :rtype: Stephen @@ -236,14 +236,14 @@ This function sets the word whose left factors, or equivalent words, are sought. thing.def("word", &Stephen_::word, R"pbdoc( -:sig=(self: Stephen) -> List[int]: +:sig=(self: Stephen) -> list[int]: Get the initial word. Returns the word set by :py:meth:`~Stephen.set_word`. :returns: A word. -:rtype: List[int] +:rtype: list[int] :raises LibsemigroupsError: if no presentation was set at the construction or @@ -285,7 +285,7 @@ Get the initial state of the word graph. py::arg("s"), py::arg("w"), R"pbdoc( -:sig=(s: Stephen, w: List[int]) -> bool: +:sig=(s: Stephen, w: list[int]) -> bool: :only-document-once: Check if a word is accepted by a :any:`Stephen` instance. @@ -307,7 +307,7 @@ word *w* is accepted if and only if :math:`uu^{-1}w` is equivalent to :type s: Stephen :param w: the input word. -:type w: List[int] +:type w: list[int] :returns: A ``bool``. :rtype: bool @@ -341,7 +341,7 @@ Return a :any:`Dot` object representing the underlying word graph of the py::arg("s"), py::arg("w"), R"pbdoc( -:sig=(s: Stephen, w: List[int]) -> bool: +:sig=(s: Stephen, w: list[int]) -> bool: :only-document-once: Check if a word is a left factor of :any:`Stephen.word`. @@ -355,7 +355,7 @@ it labels a path in :any:`Stephen.word_graph` with source ``0``. :type s: Stephen :param w: the input word. -:type w: List[int] +:type w: list[int] :returns: A ``bool``. :rtype: bool diff --git a/src/todd-coxeter.cpp b/src/todd-coxeter.cpp index 7c80e20d8..9f36d2de8 100644 --- a/src/todd-coxeter.cpp +++ b/src/todd-coxeter.cpp @@ -251,7 +251,7 @@ semigroup. }, py::arg("w"), R"pbdoc( -:sig=(self: ToddCoxeter, w: List[int] | str) -> int | Undefined: +:sig=(self: ToddCoxeter, w: list[int] | str) -> int | Undefined: Returns the current index of the class containing a word. @@ -265,7 +265,7 @@ The returned index is obtained by following the path in there is no such path, then :any:`UNDEFINED` is returned. :param w: the word. -:type w: List[int] | str +:type w: list[int] | str :returns: The current index of the class containing the word. :rtype: int | Undefined @@ -283,7 +283,7 @@ there is no such path, then :any:`UNDEFINED` is returned. }, py::arg("w"), R"pbdoc( -:sig=(self: ToddCoxeter, w: List[int] | str) -> int: +:sig=(self: ToddCoxeter, w: list[int] | str) -> int: Returns the index of the class containing a word. @@ -298,7 +298,7 @@ calls to this function, the word graph is complete, and so the return value is never :any:`UNDEFINED`. :param w: the word. -:type w: List[int] | str +:type w: list[int] | str :returns: The index of the class containing the word. :rtype: int @@ -315,7 +315,7 @@ value is never :any:`UNDEFINED`. return todd_coxeter::current_word_of(self, i); }, R"pbdoc( -:sig=(i: int) -> List[int] | str: +:sig=(i: int) -> list[int] | str: Returns a current word representing a class with given index. This function returns the current word representing the class with index *i*. @@ -329,7 +329,7 @@ the root of that tree. :type i: int :returns: The word representing the *i*-th class. -:rtype: List[int] | str +:rtype: list[int] | str :raises LibsemigroupsError: if *i* is out of bounds. )pbdoc"); @@ -349,7 +349,7 @@ is obtained by following a path in :any:`current_spanning_tree` from the node corresponding to index *i* back to the root of that tree. :returns: The word representing the *i*-th class. -:rtype: List[int] +:rtype: list[int] :param i: the index of the class. :type i: int @@ -406,7 +406,7 @@ enumeration of ``tc``.)pbdoc", py::arg("p"), py::arg("t"), R"pbdoc( -:sig=(p: Presentation, t: timedelta) -> Tuple[List[int], List[int]] | Tuple[str, str] | None: +:sig=(p: Presentation, t: timedelta) -> Tuple[list[int], list[int]] | Tuple[str, str] | None: :only-document-once: Return a redundant rule or ``None``. @@ -426,7 +426,7 @@ be shown to be redundant in this way, then ``None`` is returned. :type t: timedelta :returns: A redundant rule or ``None``. -:rtype: Tuple[List[int], List[int]] | Tuple[str, str] | None +:rtype: Tuple[list[int], list[int]] | Tuple[str, str] | None )pbdoc"); m.def( @@ -440,7 +440,7 @@ be shown to be redundant in this way, then ``None`` is returned. return {}; }, R"pbdoc( -:sig=(p: Presentation, t: timedelta) -> Tuple[List[int], List[int]] | Tuple[str, str] | None: +:sig=(p: Presentation, t: timedelta) -> Tuple[list[int], list[int]] | Tuple[str, str] | None: :only-document-once: )pbdoc"); @@ -454,10 +454,10 @@ be shown to be redundant in this way, then ``None`` is returned. py::arg("tc"), py::arg("n"), R"pbdoc( -:sig=(tc: ToddCoxeter, n: int) -> Iterator[List[int] | str]: +:sig=(tc: ToddCoxeter, n: int) -> Iterator[list[int] | str]: :only-document-once: -Returns an iterator yielding every word ``List[int]`` or ``str`` in the +Returns an iterator yielding every word ``list[int]`` or ``str`` in the congruence class with given index. This function returns an iterator yielding every word belonging to the @@ -471,7 +471,7 @@ instance *tc*. Calls to this function trigger a full enumeration of *tc*. :type n: int :returns: A iterator yielding the class with index *n*. -:rtype: Iterator[List[int] | str] +:rtype: Iterator[list[int] | str] :raises LibsemigroupsError: if *n* is greater than or equal to ``tc.number_of_classes()``. @@ -487,7 +487,7 @@ instance *tc*. Calls to this function trigger a full enumeration of *tc*. py::arg("tc"), py::arg("w"), R"pbdoc( -:sig=(tc: ToddCoxeter, w: List[int] | str) -> Iterator[List[int] | str]: +:sig=(tc: ToddCoxeter, w: list[int] | str) -> Iterator[list[int] | str]: :only-document-once: Returns an iterator yielding every word (of the same type as *w*) in @@ -502,10 +502,10 @@ full enumeration of *tc*. :type tc: ToddCoxeter :param w: the input word. -:type w: List[int] | str +:type w: list[int] | str :returns: An iterator yielding words in the class of the input word. -:rtype: Iterator[List[int] | str] +:rtype: Iterator[list[int] | str] :raises LibsemigroupsError: if any of the values in *w* is out of range, i.e. they do not belong to diff --git a/src/transf.cpp b/src/transf.cpp index c8d82c76e..ce9df8bd1 100644 --- a/src/transf.cpp +++ b/src/transf.cpp @@ -74,13 +74,13 @@ namespace libsemigroups { }), py::arg("imgs"), fmt::format(R"pbdoc( -:sig=(self: {2}, imgs: List[int]) -> None: +:sig=(self: {2}, imgs: list[int]) -> None: A {0} can be constructed from a list of images, as follows: the image of the point ``i`` under the {0} is ``imgs[i]``. :param imgs: the list of images. -:type imgs: List[int] +:type imgs: list[int] :complexity: Linear in :py:meth:`degree`. @@ -315,12 +315,12 @@ that fixes every value from ``0`` to ``f.degree()``. [](PTransfSubclass const& f) { return image(f); }, py::arg("f"), R"pbdoc( -:sig=(f: Transf | PPerm | Perm) -> List[int]: +:sig=(f: Transf | PPerm | Perm) -> list[int]: :only-document-once: Returns the set of points in the image of a partial transformation. -Returns a ``List[int]`` containing those values ``f[i]`` such that: +Returns a ``list[int]`` containing those values ``f[i]`` such that: * :math:`i\in \{0, \ldots, n - 1\}` where `n` is the degree of *f*; and * ``f[i] != UNDEFINED``. @@ -331,7 +331,7 @@ Returns a ``List[int]`` containing those values ``f[i]`` such that: :complexity: Linear in the degree of *f*. :returns: The sorted list of points in the image. -:rtype: List[int] +:rtype: list[int] )pbdoc"); m.def( @@ -339,12 +339,12 @@ Returns a ``List[int]`` containing those values ``f[i]`` such that: [](PTransfSubclass const& f) { return domain(f); }, py::arg("f"), R"pbdoc( -:sig=(f: Transf | PPerm | Perm) -> List[int]: +:sig=(f: Transf | PPerm | Perm) -> list[int]: :only-document-once: Returns the set of points where a partial transformation is defined. -This function returns a ``List[int]`` containing those values ``i`` such that: +This function returns a ``list[int]`` containing those values ``i`` such that: * :math:`i\in \{0, \ldots, n - 1\}` where `n` is the degree of *f*; and * ``f[i] != UNDEFINED`` (only applies to partial perms). @@ -355,7 +355,7 @@ This function returns a ``List[int]`` containing those values ``i`` such that: :complexity: Linear in the degree of *f*. :returns: The sorted list of points in the domain. -:rtype: List[int] +:rtype: list[int] )pbdoc"); } @@ -525,13 +525,13 @@ among the points where :math:`f` is defined). }), py::arg("imgs"), R"pbdoc( -:sig=(self: PPerm, imgs: List[int | Undefined]) -> None: +:sig=(self: PPerm, imgs: list[int | Undefined]) -> None: A partial perm can be constructed from a list of images, as follows: the image of the point ``i`` under the {1} is ``imgs[i]``. :param imgs: the list of images. -:type imgs: List[int | Undefined] +:type imgs: list[int | Undefined] :complexity: Linear in :py:meth:`degree`. @@ -548,7 +548,7 @@ the image of the point ``i`` under the {1} is ``imgs[i]``. py::arg("im"), py::arg("M"), R"pbdoc( -:sig=(self: PPerm, dom: List[int], im: List[int]) -> None: +:sig=(self: PPerm, dom: list[int], im: list[int]) -> None: Construct from domain, range, and degree. @@ -557,9 +557,9 @@ all ``i`` and which is :any:`UNDEFINED` on every other value in the range :math:`[0, M)`. :param dom: the domain. -:type dom: List[int] +:type dom: list[int] :param ran: the image. -:type ran: List[int] +:type ran: list[int] :param M: the degree. :type M: int diff --git a/src/ukkonen.cpp b/src/ukkonen.cpp index a1a288819..38785b6a1 100644 --- a/src/ukkonen.cpp +++ b/src/ukkonen.cpp @@ -45,7 +45,7 @@ namespace libsemigroups { }, py::arg("w"), R"pbdoc( -:sig=(self: Ukkonen, w: str | List[int]) -> int: +:sig=(self: Ukkonen, w: str | list[int]) -> int: :only-document-once: Find the index of a word in the suffix tree. @@ -56,7 +56,7 @@ returns the index of that word. If the word *w* is not one of the words that the suffix tree represents, then :any:`UNDEFINED` is returned. :param w: the word to check. -:type w: str | List[int] +:type w: str | list[int] :returns: The index of *w*. :rtype: int @@ -72,7 +72,7 @@ suffix tree represents, then :any:`UNDEFINED` is returned. }, py::arg("w"), R"pbdoc( -:sig=(self: Ukkonen, w: str | List[int]) -> None: +:sig=(self: Ukkonen, w: str | list[int]) -> None: :only-document-once: Throw if the word *w* contains a letter equal to any of the unique letters added to the end of words in the suffix tree. @@ -81,7 +81,7 @@ This function throws an exception if the word *w* contains a letter equal to any of the unique letters added to the end of words in the suffix tree. :param w: the word to check. -:type w: str | List[int] +:type w: str | list[int] :raises LibsemigroupsError: if *w* contains a letter equal to any of the unique letters added to the end of words in the suffix tree. @@ -98,7 +98,7 @@ of the unique letters added to the end of words in the suffix tree. py::arg("u"), py::arg("w"), R"pbdoc( -:sig=(u: Ukkonen, w: str | List[int]) -> None: +:sig=(u: Ukkonen, w: str | list[int]) -> None: :only-document-once: Check and add a word to the suffix tree. @@ -113,7 +113,7 @@ If *w* is empty, then this function does nothing. :param u: the :any:`Ukkonen` object. :type u: Ukkonen :param w: the word to add. -:type w: str | List[int] +:type w: str | list[int] :raises LibsemigroupsError: if ``u.throw_if_contains_unique_letter(w)`` throws. @@ -132,14 +132,14 @@ If *w* is empty, then this function does nothing. py::arg("u"), py::arg("words"), R"pbdoc( -:sig=(u: Ukkonen, words: List[str] | List[List[int]]) -> bool: +:sig=(u: Ukkonen, words: list[str] | list[list[int]]) -> bool: :only-document-once: Add all words in a list to an :any:`Ukkonen` object. :param u: the :any:`Ukkonen` object. :type u: Ukkonen :param words: the list of words to add. -:type w: List[str] | List[List[int]] +:type w: list[str] | list[list[int]] :raises LibsemigroupsError: if ``u.throw_if_contains_unique_letter(w)`` throws for any ``w`` in *words*. @@ -155,7 +155,7 @@ Add all words in a list to an :any:`Ukkonen` object. py::arg("u"), py::arg("w"), R"pbdoc( -:sig=(u: Ukkonen, w: str | List[int]) -> bool: +:sig=(u: Ukkonen, w: str | list[int]) -> bool: :only-document-once: Check if a word is a piece (occurs in two distinct places in the words of the suffix tree). @@ -167,7 +167,7 @@ then `False` is returned. :param u: the :any:`Ukkonen` object. :type u: Ukkonen :param w: the word to check. -:type w: str | List[int] +:type w: str | list[int] :returns: Whether *w* is a piece. :rtype: bool @@ -189,7 +189,7 @@ then `False` is returned. py::arg("u"), py::arg("w"), R"pbdoc( -:sig=(u: Ukkonen, w: str | List[int]) -> bool: +:sig=(u: Ukkonen, w: str | list[int]) -> bool: :only-document-once: Check if a word is a subword of any word in a suffix tree. @@ -200,7 +200,7 @@ represented by the :any:`Ukkonen` instance *u*. :param u: the :any:`Ukkonen` object. :type u: Ukkonen :param w: the word to check. -:type w: str | List[int] +:type w: str | list[int] :returns: Whether *w* is a subword of any word in *u*. :rtype: bool @@ -222,7 +222,7 @@ represented by the :any:`Ukkonen` instance *u*. py::arg("u"), py::arg("w"), R"pbdoc( -:sig=(u: Ukkonen, w: str | List[int]) -> bool: +:sig=(u: Ukkonen, w: str | list[int]) -> bool: :only-document-once: Check if a word is a suffix of any word in a suffix tree. @@ -233,7 +233,7 @@ represented by the :any:`Ukkonen` instance *u*. :param u: the :any:`Ukkonen` object. :type u: Ukkonen :param w: the word to check. -:type w: str | List[int] +:type w: str | list[int] :returns: Whether *w* is a suffix of any word in *u*. :rtype: bool @@ -251,7 +251,7 @@ represented by the :any:`Ukkonen` instance *u*. py::arg("u"), py::arg("w"), R"pbdoc( -:sig=(u: Ukkonen, w: str | List[int]) -> int: +:sig=(u: Ukkonen, w: str | list[int]) -> int: :only-document-once: Find the length of the maximal prefix of a word occurring in two different places in a word in a suffix tree. @@ -263,7 +263,7 @@ If no such prefix exists, then ``0`` is returned. :param u: the :any:`Ukkonen` object. :type u: Ukkonen :param w: the word. -:type w: str | List[int] +:type w: str | list[int] :returns: The length of the maximal piece prefix. :rtype: int @@ -285,7 +285,7 @@ If no such prefix exists, then ``0`` is returned. py::arg("u"), py::arg("w"), R"pbdoc( -:sig=(u: Ukkonen, w: str | List[int]) -> int: +:sig=(u: Ukkonen, w: str | list[int]) -> int: :only-document-once: Find the length of the maximal suffix of a word occurring in two different places in a word in a suffix tree. @@ -297,7 +297,7 @@ If no such prefix exists, then ``0`` is returned. :param u: the :any:`Ukkonen` object. :type u: Ukkonen :param w: the word. -:type w: str | List[int] +:type w: str | list[int] :returns: The length of the maximal piece suffix. :rtype: int @@ -318,7 +318,7 @@ If no such prefix exists, then ``0`` is returned. py::arg("u"), py::arg("w"), R"pbdoc( -:sig=(u: Ukkonen, w: str | List[int]) -> str | List[int]: +:sig=(u: Ukkonen, w: str | list[int]) -> str | list[int]: :only-document-once: Find the maximal prefix of a word occurring in two different places in a word in a suffix tree. @@ -329,10 +329,10 @@ contained in *u*. If no such prefix exists, then an empty word is returned. :param u: the :any:`Ukkonen` object. :type u: Ukkonen :param w: the word. -:type w: str | List[int] +:type w: str | list[int] :returns: The maximal piece prefix. -:rtype: str | List[int] +:rtype: str | list[int] :raises LibsemigroupsError: if ``u.throw_if_contains_unique_letter(w)`` throws. @@ -351,7 +351,7 @@ contained in *u*. If no such prefix exists, then an empty word is returned. py::arg("u"), py::arg("w"), R"pbdoc( -:sig=(u: Ukkonen, w: str | List[int]) -> str | List[int]: +:sig=(u: Ukkonen, w: str | list[int]) -> str | list[int]: :only-document-once: Find the maximal suffix of a word occurring in two different places in a word in a suffix tree. @@ -362,10 +362,10 @@ contained in *u*. If no such suffix exists, then an empty word is returned. :param u: the :any:`Ukkonen` object. :type u: Ukkonen :param w: the word. -:type w: str | List[int] +:type w: str | list[int] :returns: The maximal piece suffix. -:rtype: str | List[int] +:rtype: str | list[int] :raises LibsemigroupsError: if ``u.throw_if_contains_unique_letter(w)`` throws. @@ -383,7 +383,7 @@ contained in *u*. If no such suffix exists, then an empty word is returned. py::arg("u"), py::arg("w"), R"pbdoc( -:sig=(u: Ukkonen, w: str | List[int]) -> int: +:sig=(u: Ukkonen, w: str | list[int]) -> int: :only-document-once: Find the number of pieces in a decomposition of a word (if any). @@ -397,7 +397,7 @@ Recall that a *piece* is a word that occurs in two distinct positions :param u: the :any:`Ukkonen` object. :type u: Ukkonen :param w: the word. -:type w: str | List[int] +:type w: str | list[int] :returns: The number of pieces. :rtype: int @@ -417,7 +417,7 @@ Recall that a *piece* is a word that occurs in two distinct positions py::arg("u"), py::arg("w"), R"pbdoc( -:sig=(u: Ukkonen, w: str | List[int]) -> List[str] | List[List[int]]: +:sig=(u: Ukkonen, w: str | list[int]) -> list[str] | list[list[int]]: :only-document-once: Find the pieces in a decomposition of a word (if any). @@ -430,10 +430,10 @@ overlapping) of the words in the suffix tree *u*. :param u: the :any:`Ukkonen` object. :type u: Ukkonen :param w: the word. -:type w: str | List[int] +:type w: str | list[int] :returns: The of pieces in the decomposition of *w*. -:rtype: List[str] | List[List[int]] +:rtype: list[str] | list[list[int]] :raises LibsemigroupsError: if ``u.throw_if_contains_unique_letter(w)`` throws. @@ -455,7 +455,7 @@ overlapping) of the words in the suffix tree *u*. py::arg("u"), py::arg("w"), R"pbdoc( -:sig=(u: Ukkonen, w: str | List[int]) -> Tuple[Ukkonen.State, str | List[int]]: +:sig=(u: Ukkonen, w: str | list[int]) -> Tuple[Ukkonen.State, str | list[int]]: :only-document-once: Traverse the suffix tree from the root. @@ -468,10 +468,10 @@ traversal is returned. :param u: the :any:`Ukkonen` object. :type u: Ukkonen :param w: the word. -:type w: str | List[int] +:type w: str | list[int] :returns: A tuple containing the :any:`State` reached, and the word consumed. -:rtype: Tuple[Ukkonen.State, str | List[int]] +:rtype: Tuple[Ukkonen.State, str | list[int]] :raises LibsemigroupsError: if ``u.throw_if_contains_unique_letter(w)`` throws. @@ -492,7 +492,7 @@ traversal is returned. py::arg("st"), py::arg("w"), R"pbdoc( -:sig=(u: Ukkonen, w: str | List[int]) -> str | List[int]: +:sig=(u: Ukkonen, w: str | list[int]) -> str | list[int]: :only-document-once: Traverse the suffix tree from the root. @@ -506,11 +506,11 @@ the portion of *w* that was consumed in the traversal. :param u: the :any:`Ukkonen` object. :type u: Ukkonen :param w: the word. -:type w: str | List[int] +:type w: str | list[int] :returns: The portion of *w* that was consumed in the traversal. -:rtype: str | List[int] +:rtype: str | list[int] :raises LibsemigroupsError: if ``u.throw_if_contains_unique_letter(w)`` throws. @@ -534,7 +534,7 @@ the portion of *w* that was consumed in the traversal. For an implementation of Ukkonen's algorithm. This class implements Ukkonen's algorithm for constructing a generalised suffix -tree consisting of ``List[int]``. The implementation in this class is based on: +tree consisting of ``list[int]``. The implementation in this class is based on: `https://cp-algorithms.com/string/suffix-tree-ukkonen.html `_ The suffix tree is updated when the member function :any:`ukkonen.add_word` is @@ -828,7 +828,7 @@ This function returns the number of times that the word corresponding to the ind Returns the nodes in the suffix tree. :returns: A list of nodes. -:rtype: List[Ukkonen.Node] +:rtype: list[Ukkonen.Node] :complexity: Constant. )pbdoc"); diff --git a/src/word-graph.cpp b/src/word-graph.cpp index 927db2d27..5f5f3f6c3 100644 --- a/src/word-graph.cpp +++ b/src/word-graph.cpp @@ -129,7 +129,7 @@ out-degree is specified by the length of the first item in *targets*. :type num_nodes: int :param targets: list of the targets. -:type targets: List[List[int]] +:type targets: list[list[int]] :raises LibsemigroupsError: if any target is specified in *targets* is greater @@ -933,10 +933,10 @@ are labelled by *lhs* lead to the same nodes as the paths labelled by *rhs*. :type last_node: int :param lhs: the first rule. -:type lhs: List[int] +:type lhs: list[int] :param rhs: the second rule. -:type rhs: List[int] +:type rhs: list[int] :returns: Whether or not the word graph is compatible with the given rules at each one @@ -1123,7 +1123,7 @@ position in the word reached. :type source: int :param w: the word. -:type w: List[int] +:type w: list[int] :returns: A pair consisting of the last node reached and the index of @@ -1348,7 +1348,7 @@ in the list. :returns: A list of the nodes of *wg* in topological order (if possible) and is otherwise empty. -:rtype: List[int] +:rtype: list[int] :complexity: :math:`O(m + n)` where :math:`m` is the number of nodes in the @@ -1379,7 +1379,7 @@ list, and the last item in the list is *source*. :returns: A list of the nodes reachable from *source* in *wg* in topological order (if possible) and is otherwise empty. -:rtype: List[int] +:rtype: list[int] :complexity: At worst :math:`O(m + n)` where :math:`m` is the number of diff --git a/src/words.cpp b/src/words.cpp index 031d685c6..cc530e69c 100644 --- a/src/words.cpp +++ b/src/words.cpp @@ -196,7 +196,7 @@ Copy a :any:`WordRange` object. return w | to_str; }, R"pbdoc( -For converting from ``List[int]`` to :any:`str`. +For converting from ``list[int]`` to :any:`str`. This allows the pipe operator ``|`` to be used with a :any:`ToString` object to convert the output of a :any:`WordRange` object strings. @@ -255,7 +255,7 @@ The current first word in the range. Returns the first word in a :any:`WordRange` object. :returns: The first word in the range. -:rtype: List[int] +:rtype: list[int] .. seealso:: :any:`WordRange.min` @@ -276,7 +276,7 @@ Similarly, if :any:`WordRange.first()` is greater than :any:`WordRange.last()` w then the object will be empty. :param frst: the first word. -:type frst: List[int] +:type frst: list[int] :returns: A reference to ``self``. :rtype: WordRange @@ -291,7 +291,7 @@ Get the current value. Returns the current word in a :any:`WordRange` object. :returns: The current word. -:rtype: List[int] +:rtype: list[int] )pbdoc"); thing1.def( "init", @@ -312,7 +312,7 @@ had been newly default constructed, and returns that object. Returns the one past the last word in a :any:`WordRange` object. :returns: One past the last word. -:rtype: List[int] +:rtype: list[int] .. seealso:: :any:`WordRange.max` @@ -331,7 +331,7 @@ function performs no checks on its arguments. If ``lst`` contains letters greater than :any:`WordRange.alphabet_size()`, then the :any:`WordRange` object will be empty. :param lst: one past the last word. -:type lst: List[int] +:type lst: list[int] :returns: A reference to ``self``. :rtype: WordRange @@ -493,8 +493,8 @@ altered by a call to one of the following: * ``alphabet_size(int)`` * ``min(int)`` * ``max(int)`` -* ``first(List[int])`` -* ``last(List[int])`` +* ``first(list[int])`` +* ``last(list[int])`` * ``upper_bound(int)`` This function returns ``True`` if none of the above settings have been changed @@ -592,10 +592,10 @@ Copy a :any:`StringRange` object. return sr | to_wrd; }, R"pbdoc( -For converting from to :any:`str` to ``List[int]``. +For converting from to :any:`str` to ``list[int]``. This allows the pipe operator ``|`` to be used with a :any:`ToWord` object to -convert the output of a :any:`StringRange` object List[int]. +convert the output of a :any:`StringRange` object list[int]. )pbdoc"); thing2.def("__len__", &StringRange::count); @@ -912,9 +912,9 @@ This setting is only used if :any:`StringRange.order()` is :any:`Order.lex`. py::class_ thing3(m, "ToWord", R"pbdoc( -Class for converting strings to ``List[int]`` with specified alphabet. +Class for converting strings to ``list[int]`` with specified alphabet. -An instance of this class is callable and used to convert from :any:`str` to ``List[int]``. +An instance of this class is callable and used to convert from :any:`str` to ``list[int]``. The characters in the string are converted to integers according to their position in the alphabet used to construct a :any:`ToWord` instance if one is provided, or using :any:`words.human_readable_index` otherwise. @@ -980,7 +980,7 @@ Return the alphabet used for conversion. This function returns a :any:`str` corresponding to the ordered-set alphabet :math:`\{a_0, a_1, \dots, a_{n-1}\}` that the initialised :any:`ToWord` -object will use to convert from :any:`str` to ``List[int]``. +object will use to convert from :any:`str` to ``list[int]``. Specifically, :math:`a_i \mapsto i` where :math:`a_i` will correspond to a letter in a :any:`str`, and :math:`i` is an :any:`int`. @@ -1054,9 +1054,9 @@ been newly constructed from *alphabet*. }, py::arg("input"), R"pbdoc( -Convert a string to a ``List[int]``. +Convert a string to a ``list[int]``. -This function converts its argument *input* into a ``List[int]``. The characters +This function converts its argument *input* into a ``list[int]``. The characters of *input* are converted using the alphabet used to construct the object or set via :any:`ToWord.init()` , or with :any:`words.human_readable_index` if :any:`ToWord.empty()` returns ``True``. @@ -1073,9 +1073,9 @@ via :any:`ToWord.init()` , or with :any:`words.human_readable_index` if py::class_ thing4(m, "ToString", R"pbdoc( -Class for converting ``List[int]`` to strings with specified alphabet. +Class for converting ``list[int]`` to strings with specified alphabet. -An instance of this class is callable and used to convert from ``List[int]`` to :any:`str`. +An instance of this class is callable and used to convert from ``list[int]`` to :any:`str`. The integers in the list are converted to characters according to their position in the alphabet used to construct a :any:`ToString` instance if one is provided, or using :any:`words.human_readable_letter` otherwise. @@ -1131,7 +1131,7 @@ Return the alphabet used for conversion. This function returns a :any:`str` corresponding to the ordered-set alphabet :math:`\{a_0, a_1, \dots, a_{n-1}\}` that the initialised :any:`ToString` -object will use to convert from ``List[int]`` to :any:`str`. +object will use to convert from ``list[int]`` to :any:`str`. Specifically, :math:`i \mapsto a_i` where :math:`i` will be an :any:`int` in a list and :math:`a_i` will be a character in a :any:`str`. @@ -1213,14 +1213,14 @@ had been newly constructed from *alphabet*. }, py::arg("input"), R"pbdoc( -Convert a ``List[int]`` to a :any:`str`. +Convert a ``list[int]`` to a :any:`str`. This function converts its argument *input* into a :any:`str`. The characters of *input* are converted using the alphabet used to construct the object or set via :any:`init()`, or with :any:`words.human_readable_letter` if :any:`empty()` returns ``True``. :param input: the string to convert. -:type input: List[int] +:type input: list[int] :raises LibsemigroupsError: if the alphabet used to define an instance of :any:`ToString` is not empty and *input* contains letters that do not correspond to letters of the alphabet. )pbdoc"); @@ -1265,7 +1265,7 @@ Returns a random word. :type length: int :return: A random word on ``[0, ..., nr_letters - 1]`` of length *length*. -:rtpye: List[int] +:rtpye: list[int] :raises LibsemigroupsError: if *nr_letters* is ``0``. @@ -1463,13 +1463,13 @@ Returns the power of a word. Returns the word *x* to the power *n*. :param x: the word to power. -:type x: List[int] +:type x: list[int] :param n: the power. :type n: int :returns: The powered word -:rtype: List[int] +:rtype: list[int] )pbdoc"); m.def( "prod", @@ -1538,7 +1538,7 @@ greatest positive integer such that :math:`f + k s > l`. R"pbdoc( Returns a product of letters. -This is the same as the above function, except with ``List[int]`` rather than +This is the same as the above function, except with ``list[int]`` rather than :any:`str`. .. doctest:: diff --git a/tests/test_present.py b/tests/test_present.py index fbc36b292..0a6761e91 100644 --- a/tests/test_present.py +++ b/tests/test_present.py @@ -12,7 +12,7 @@ # pylint: disable=fixme, missing-function-docstring, comparison-with-callable # pylint: disable=missing-class-docstring, invalid-name, too-many-lines -from typing import List, Union +from typing import Union import copy import pytest @@ -30,13 +30,13 @@ ############################################################################### -def to_string(w: Union[List[int], int]) -> chr: +def to_string(w: Union[list[int], int]) -> chr: if isinstance(w, int): return chr(w + 97) return "".join(chr(x + 97) for x in w) -def to_word(w: Union[List[int], int]) -> List[int]: +def to_word(w: Union[list[int], int]) -> list[int]: return w diff --git a/tests/test_sims.py b/tests/test_sims.py index e1b9be674..e55e6a6df 100644 --- a/tests/test_sims.py +++ b/tests/test_sims.py @@ -16,8 +16,6 @@ import os -from typing import List - import pytest from libsemigroups_pybind11 import ( @@ -121,16 +119,12 @@ def test_sims1_000(): it = S.iterator(3) assert next(it) == WordGraph(3, [[0, 0]]) - S.number_of_threads(1).for_each( - 5, lambda wg: check_right_generating_pairs(S, wg) - ) + S.number_of_threads(1).for_each(5, lambda wg: check_right_generating_pairs(S, wg)) presentation.reverse(p) S = Sims1() assert S.presentation(p).number_of_congruences(5) == 9 for wg in S.iterator(5): - assert word_graph.follow_path( - wg, 0, [1, 0, 1, 0] - ) == word_graph.follow_path(wg, 0, [0]) + assert word_graph.follow_path(wg, 0, [1, 0, 1, 0]) == word_graph.follow_path(wg, 0, [0]) S.for_each(5, lambda wg: check_right_generating_pairs(S, wg)) mat = sims.poset(S, 5) assert mat == Matrix( @@ -292,7 +286,7 @@ def test_sims1_003(): presentation.add_rule(p, "acbbACb", "e") presentation.add_rule(p, "ABabccc", "e") S = Sims1() - S.presentation(to(p, Return=(Presentation, List[int]))) + S.presentation(to(p, Return=(Presentation, list[int]))) assert S.number_of_congruences(3) == 14 @@ -338,12 +332,7 @@ def test_sims1_004(): assert T.number_of_congruences(16) == 13 orc = MinimalRepOrc() - d = ( - orc.presentation(p) - .target_size(15) - .number_of_threads(os.cpu_count()) - .word_graph() - ) + d = orc.presentation(p).target_size(15).number_of_threads(os.cpu_count()).word_graph() assert d.number_of_nodes() == 7 @@ -363,21 +352,13 @@ def test_sims_refiner_faithful_128(): S = Sims1() S.presentation(p) S.add_pruner(pruno) - assert ( - S.number_of_threads(2).number_of_congruences(9) == 4 - ) # Verified with GAP + assert S.number_of_threads(2).number_of_congruences(9) == 4 # Verified with GAP it = S.iterator(9) - assert next(it) == WordGraph( - 9, [[1, 2], [1, 3], [4, 5], [4, 4], [3, 1], [3, 0]] - ) - assert next(it) == WordGraph( - 9, [[1, 2], [3, 3], [4, 5], [1, 4], [4, 1], [3, 0]] - ) - assert next(it) == WordGraph( - 9, [[1, 2], [3, 4], [3, 5], [1, 1], [4, 3], [4, 0]] - ) + assert next(it) == WordGraph(9, [[1, 2], [1, 3], [4, 5], [4, 4], [3, 1], [3, 0]]) + assert next(it) == WordGraph(9, [[1, 2], [3, 3], [4, 5], [1, 4], [4, 1], [3, 0]]) + assert next(it) == WordGraph(9, [[1, 2], [3, 4], [3, 5], [1, 1], [4, 3], [4, 0]]) assert next(it) == WordGraph( 9, [ @@ -423,7 +404,7 @@ def test_sims1_902(): presentation.add_rule(p, "db", "bb") presentation.add_rule(p, "cc", "c") presentation.add_rule(p, "bd", "bb") - s = Sims1(to(p, Return=(Presentation, List[int]))) + s = Sims1(to(p, Return=(Presentation, list[int]))) assert s.number_of_congruences(2) == 67 assert s.number_of_threads(2).number_of_congruences(2) == 67 assert s.number_of_threads(4).number_of_congruences(2) == 67 @@ -459,7 +440,7 @@ def test_sims2_902(): p = Presentation("ab") presentation.add_rule(p, "ab", "ba") - s = Sims2(to(p, Return=(Presentation, List[int]))) + s = Sims2(to(p, Return=(Presentation, list[int]))) assert s.number_of_congruences(1) == 1 assert s.number_of_congruences(2) == 9 assert s.number_of_congruences(3) == 37 @@ -526,7 +507,7 @@ def test_sims_refiner_ideals_902(): def test_sims_return_policy(): p = Presentation("ab") p.rules = ["a" * 5, "a", "b" * 4, "b", "ab", "ba"] - s = Sims1(to(p, Return=(Presentation, List[int]))) + s = Sims1(to(p, Return=(Presentation, list[int]))) assert s.presentation() is s.presentation() diff --git a/tests/test_stephen.py b/tests/test_stephen.py index c7ced383e..5fe6962e2 100644 --- a/tests/test_stephen.py +++ b/tests/test_stephen.py @@ -15,7 +15,6 @@ # pylint: disable=duplicate-code, too-many-lines from itertools import islice -from typing import List from functools import cmp_to_key import pytest @@ -92,12 +91,7 @@ def verify_c4_normal_form(p, word, nf): S = Stephen(p) S.set_word(word).run() - assert ( - sorted( - list(stephen.words_accepted(S)), key=lexicographic_compare_key_func - )[0] - == nf - ) + assert sorted(list(stephen.words_accepted(S)), key=lexicographic_compare_key_func)[0] == nf assert all(stephen.accepts(S, w) for w in stephen.words_accepted(S)) assert stephen.number_of_words_accepted(S) == len(stephen.words_accepted(S)) @@ -192,25 +186,18 @@ def test_stephen_001(): [1, 1, 0, 0, 1], ] assert stephen.number_of_left_factors(s) == POSITIVE_INFINITY - assert all( - stephen.is_left_factor(s, ww) - for ww in islice(stephen.left_factors(s), 10) - ) + assert all(stephen.is_left_factor(s, ww) for ww in islice(stephen.left_factors(s), 10)) s.set_word([0, 0]).run() assert s.word_graph().number_of_nodes() == 5 - assert s.word_graph() == WordGraph( - 5, [[1, UNDEFINED], [2, 3], [1, 4], [4, 1], [3, 2]] - ) + assert s.word_graph() == WordGraph(5, [[1, UNDEFINED], [2, 3], [1, 4], [4, 1], [3, 2]]) p.rules = [] presentation.add_rule(p, [0, 0, 0], [0]) presentation.add_rule(p, [1, 1, 1], [1]) s.init(p).set_word([0, 0]).run() assert s.word() == [0, 0] - assert s.word_graph() == WordGraph( - 3, [[1, UNDEFINED], [2, UNDEFINED], [1, UNDEFINED]] - ) + assert s.word_graph() == WordGraph(3, [[1, UNDEFINED], [2, UNDEFINED], [1, UNDEFINED]]) @pytest.mark.quick @@ -559,9 +546,9 @@ def test_stephen_008(): to_word("dgabcdg"), ] - assert sorted( - list(stephen.words_accepted(S)), key=lexicographic_compare_key_func - )[0] == to_word("dfabcdf") + assert sorted(list(stephen.words_accepted(S)), key=lexicographic_compare_key_func)[ + 0 + ] == to_word("dfabcdf") assert all(stephen.accepts(S, w) for w in stephen.words_accepted(S)) assert stephen.number_of_words_accepted(S) == len(stephen.words_accepted(S)) @@ -569,9 +556,7 @@ def test_stephen_008(): S.set_word(to_word("abcdfceg")).run() assert stephen.number_of_words_accepted(S) == 16 - assert sorted( - list(stephen.words_accepted(S)), key=lexicographic_compare_key_func - ) == [ + assert sorted(list(stephen.words_accepted(S)), key=lexicographic_compare_key_func) == [ to_word("abcdfabcdf"), to_word("abcdfabcdg"), to_word("abcdfcef"), @@ -590,9 +575,9 @@ def test_stephen_008(): to_word("cegceg"), ] - assert sorted( - list(stephen.words_accepted(S)), key=lexicographic_compare_key_func - )[0] == to_word("abcdfabcdf") + assert sorted(list(stephen.words_accepted(S)), key=lexicographic_compare_key_func)[ + 0 + ] == to_word("abcdfabcdf") assert stephen.accepts(S, to_word("abcdfabcdf")) @@ -723,12 +708,8 @@ def test_stephen_014(): to_word = ToWord("abcd") p = Presentation(to_word("abcd")) presentation.add_rule(p, to_word("abbba"), to_word("cdc")) - verify_c4_normal_form( - p, to_word("cdcdcabbbabbbabbcd"), to_word("abbbadcabbbabbbabbcd") - ) - verify_c4_equal_to( - p, to_word("cdcdcabbbabbbabbcd"), to_word("abbbadcabbbabbbabbcd") - ) + verify_c4_normal_form(p, to_word("cdcdcabbbabbbabbcd"), to_word("abbbadcabbbabbbabbcd")) + verify_c4_equal_to(p, to_word("cdcdcabbbabbbabbcd"), to_word("abbbadcabbbabbbabbcd")) verify_c4_equal_to(p, to_word("abbbadcbbba"), to_word("cdabbbcdc")) verify_c4_equal_to(p, to_word("cdabbbcdc"), to_word("cdabbbcdc")) @@ -781,12 +762,8 @@ def test_stephen_017(): p = Presentation(to_word("abcd")) presentation.add_rule(p, to_word("abcd"), to_word("accca")) - verify_c4_normal_form( - p, to_word("bbcabcdaccaccabcddd"), to_word("bbcabcdaccaccabcddd") - ) - verify_c4_equal_to( - p, to_word("bbcabcdaccaccabcddd"), to_word("bbcabcdaccaccabcddd") - ) + verify_c4_normal_form(p, to_word("bbcabcdaccaccabcddd"), to_word("bbcabcdaccaccabcddd")) + verify_c4_equal_to(p, to_word("bbcabcdaccaccabcddd"), to_word("bbcabcdaccaccabcddd")) @pytest.mark.quick @@ -809,12 +786,8 @@ def test_stephen_019(): p = Presentation(to_word("abc")) presentation.add_rule(p, to_word("ccab"), to_word("cbac")) - verify_c4_normal_form( - p, to_word("bacbaccabccabcbacbac"), to_word("bacbacbaccbaccbacbac") - ) - verify_c4_equal_to( - p, to_word("bacbaccabccabcbacbac"), to_word("bacbacbaccbaccbacbac") - ) + verify_c4_normal_form(p, to_word("bacbaccabccabcbacbac"), to_word("bacbacbaccbaccbacbac")) + verify_c4_equal_to(p, to_word("bacbaccabccabcbacbac"), to_word("bacbacbaccbaccbacbac")) verify_c4_normal_form(p, to_word("ccabcbaccab"), to_word("cbaccbacbac")) verify_c4_equal_to(p, to_word("ccabcbaccab"), to_word("cbaccbacbac")) @@ -889,12 +862,8 @@ def test_stephen_025(): ReportGuard(False) to_word = ToWord("abcd") p = Presentation(to_word("abcd")) - presentation.add_rule( - p, to_word("ababbabbbabbbb"), to_word("abbbbbabbbbbbabbbbbbbabbbbbbbb") - ) - presentation.add_rule( - p, to_word("cdcddcdddcdddd"), to_word("cdddddcddddddcdddddddcdddddddd") - ) + presentation.add_rule(p, to_word("ababbabbbabbbb"), to_word("abbbbbabbbbbbabbbbbbbabbbbbbbb")) + presentation.add_rule(p, to_word("cdcddcdddcdddd"), to_word("cdddddcddddddcdddddddcdddddddd")) verify_c4_normal_form( p, @@ -961,9 +930,7 @@ def test_stephen_029(): p = Presentation(to_word("abcd")) presentation.add_rule(p, to_word("acba"), to_word("aabc")) presentation.add_rule(p, to_word("acba"), to_word("dbbd")) - verify_c4_normal_form( - p, to_word("bbacbcaaabcbbd"), to_word("bbacbcaaabcbbd") - ) + verify_c4_normal_form(p, to_word("bbacbcaaabcbbd"), to_word("bbacbcaaabcbbd")) verify_c4_normal_form(p, to_word("acbacba"), to_word("aabcabc")) verify_c4_normal_form(p, to_word("aabcabc"), to_word("aabcabc")) @@ -1279,7 +1246,7 @@ def test_stephen_043(): def test_stephen_044(): """inverse presentation -- operator==""" ReportGuard(False) - tc = ToddCoxeter(Word=List[int]) + tc = ToddCoxeter(Word=list[int]) p = examples.symmetric_inverse_monoid(4) assert p.contains_empty_word() @@ -1543,25 +1510,17 @@ def test_stephen_049(): presentation.add_rule(p, [0, 0, 1], [1, 0]) S = Stephen(Presentation([])) - assert ( - repr(S) - == f"" - ) + assert repr(S) == f"" S.init(p) - assert ( - repr(S) - == f"" - ) + assert repr(S) == f"" S.set_word([0, 1, 1, 0]) assert ( - repr(S) - == f"" ) S.run() assert ( - repr(S) - == f"" ) S.set_word([0, 1, 1, 0, 0, 1, 1, 0, 0]) @@ -1579,22 +1538,17 @@ def test_stephen_049(): S.set_word([0, 1, 1, 0, 0, 1, 1, 0, 0, 1]) S.run() assert ( - repr(S) - == f"" ) S.set_word([0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0]) S.run() assert ( - repr(S) - == f"" ) S.init(p) - assert ( - repr(S) - == f"" - ) + assert repr(S) == f"" to_word = ToWord("abcABC") pi = InversePresentation(to_word("abcABC")) @@ -1604,15 +1558,9 @@ def test_stephen_049(): presentation.add_rule(pi, to_word("bc"), to_word("cb")) IS = Stephen(InversePresentation([])) - assert ( - repr(IS) - == f"" - ) + assert repr(IS) == f"" IS.init(pi) - assert ( - repr(IS) - == f"" - ) + assert repr(IS) == f"" IS.set_word(to_word("BaAbaBcAb")) assert ( repr(IS) diff --git a/tests/test_to.py b/tests/test_to.py index 1942d7d35..86279177d 100644 --- a/tests/test_to.py +++ b/tests/test_to.py @@ -11,7 +11,6 @@ This module contains some tests for the to function. """ -from typing import List import pytest from _libsemigroups_pybind11 import ( FroidurePinKBERewriteFromLeft, @@ -70,11 +69,7 @@ def sample_to_str(i): def sample_to_int(x): - return ( - "mnbvcxzlkjhgfdsapoiuytrewqMNBVCXZLKJHGFDSAPOIUYTREWQ5432167890".index( - x - ) - ) + return "mnbvcxzlkjhgfdsapoiuytrewqMNBVCXZLKJHGFDSAPOIUYTREWQ5432167890".index(x) def sample_froidure_pin(): @@ -184,9 +179,7 @@ def check_froidure_pin_to_congruence(Word): def test_to_FroidurePin_000(): - fp = check_cong_to_froidure_pin( - KnuthBendix, str, Rewriter="RewriteFromLeft" - ) + fp = check_cong_to_froidure_pin(KnuthBendix, str, Rewriter="RewriteFromLeft") assert isinstance(to_cxx(fp), FroidurePinKBERewriteFromLeft) @@ -196,9 +189,7 @@ def test_to_FroidurePin_001(): def test_to_FroidurePin_002(): - fp = check_cong_to_froidure_pin( - KnuthBendix, int, Rewriter="RewriteFromLeft" - ) + fp = check_cong_to_froidure_pin(KnuthBendix, int, Rewriter="RewriteFromLeft") assert isinstance(to_cxx(fp), FroidurePinKBERewriteFromLeft) @@ -315,9 +306,7 @@ def test_to_FroidurePin_013(): def test_to_ToddCoxeter_014(): - tc = check_cong_to_todd_coxeter( - KnuthBendix, str, Rewriter="RewriteFromLeft" - ) + tc = check_cong_to_todd_coxeter(KnuthBendix, str, Rewriter="RewriteFromLeft") assert isinstance(tc, ToddCoxeter) assert tc.py_template_params == (str,) @@ -329,17 +318,15 @@ def test_to_ToddCoxeter_015(): def test_to_ToddCoxeter_016(): - tc = check_cong_to_todd_coxeter( - KnuthBendix, int, Rewriter="RewriteFromLeft" - ) + tc = check_cong_to_todd_coxeter(KnuthBendix, int, Rewriter="RewriteFromLeft") assert isinstance(tc, ToddCoxeter) - assert tc.py_template_params == (List[int],) + assert tc.py_template_params == (list[int],) def test_to_ToddCoxeter_017(): tc = check_cong_to_todd_coxeter(KnuthBendix, int, Rewriter="RewriteTrie") assert isinstance(tc, ToddCoxeter) - assert tc.py_template_params == (List[int],) + assert tc.py_template_params == (list[int],) # From FroidurePin @@ -363,7 +350,7 @@ def test_to_ToddCoxeter_019(): congruence_kind.twosided, S, S.right_cayley_graph(), - Return=(ToddCoxeter, List[int]), + Return=(ToddCoxeter, list[int]), ) assert tc.current_word_graph().number_of_nodes() == S.size() + 1 assert isinstance(tc, ToddCoxeter) @@ -404,7 +391,7 @@ def test_to_Presentation_020(): "e", ] assert p == to(p, Return=(Presentation, str)) - q = to(p, Return=(Presentation, List[int])) + q = to(p, Return=(Presentation, list[int])) assert isinstance(q, Presentation) assert q.alphabet() == [0, 1, 2, 3, 4, 5] assert q.rules == [ @@ -463,7 +450,7 @@ def test_to_Presentation_021(): with pytest.raises(TypeError): q = to(p, sample_to_str, Return=(Presentation, str)) - q = to(p, sample_to_int, Return=(Presentation, List[int])) + q = to(p, sample_to_int, Return=(Presentation, list[int])) assert isinstance(q, Presentation) assert q.alphabet() == [15, 2, 4, 13, 23] assert q.rules == [ @@ -488,7 +475,7 @@ def test_to_Presentation_021(): ] with pytest.raises(TypeError): - r = to(q, sample_to_int, Return=(Presentation, List[int])) + r = to(q, sample_to_int, Return=(Presentation, list[int])) r = to(q, sample_to_str, Return=(Presentation, str)) assert isinstance(r, Presentation) @@ -585,7 +572,7 @@ def test_to_Presentation_023(): [4, 4], [4], ] - q = to(p, lambda x: x + 10, Return=(Presentation, List[int])) + q = to(p, lambda x: x + 10, Return=(Presentation, list[int])) assert q.alphabet() == [10, 11, 12, 13, 14] assert q.rules == [ [10, 14], @@ -614,22 +601,22 @@ def test_to_Presentation_023(): def test_to_Presentation_024(): check_knuth_bendix_to_pres(str, str, "RewriteFromLeft") - check_knuth_bendix_to_pres(str, List[int], "RewriteFromLeft") + check_knuth_bendix_to_pres(str, list[int], "RewriteFromLeft") def test_to_Presentation_025(): check_knuth_bendix_to_pres(str, str, "RewriteTrie") - check_knuth_bendix_to_pres(str, List[int], "RewriteTrie") + check_knuth_bendix_to_pres(str, list[int], "RewriteTrie") def test_to_Presentation_026(): - check_knuth_bendix_to_pres(List[int], str, "RewriteFromLeft") - check_knuth_bendix_to_pres(List[int], List[int], "RewriteFromLeft") + check_knuth_bendix_to_pres(list[int], str, "RewriteFromLeft") + check_knuth_bendix_to_pres(list[int], list[int], "RewriteFromLeft") def test_to_Presentation_027(): - check_knuth_bendix_to_pres(List[int], str, "RewriteTrie") - check_knuth_bendix_to_pres(List[int], List[int], "RewriteTrie") + check_knuth_bendix_to_pres(list[int], str, "RewriteTrie") + check_knuth_bendix_to_pres(list[int], list[int], "RewriteTrie") # From FroidurePin @@ -640,7 +627,7 @@ def test_to_Presentation_028(): def test_to_Presentation_029(): - check_froidure_pin_to_pres(List[int]) + check_froidure_pin_to_pres(list[int]) ############################################################################### @@ -657,16 +644,16 @@ def test_to_InversePresentation_030(): presentation.add_rule(ip, "bac", "cab") assert ip == to(ip, Return=(InversePresentation, str)) - iq = to(ip, Return=(InversePresentation, List[int])) + iq = to(ip, Return=(InversePresentation, list[int])) assert iq.alphabet() == [0, 1, 2] assert iq.inverses() == [2, 1, 0] assert iq.rules == [[0, 0, 0], [1], [1, 0, 2], [2, 0, 1]] ir = to(iq, Return=(InversePresentation, str)) assert ir == ip - assert iq == to(ir, Return=(InversePresentation, List[int])) + assert iq == to(ir, Return=(InversePresentation, list[int])) assert ip == to(iq, Return=(Presentation, str)) - assert iq == to(ir, Return=(Presentation, List[int])) + assert iq == to(ir, Return=(Presentation, list[int])) # From function + InversePresentation @@ -678,7 +665,7 @@ def test_to_InversePresentation_031(): presentation.add_rule(ip, "aaa", "b") presentation.add_rule(ip, "bac", "cab") - iq = to(ip, sample_to_int, Return=(InversePresentation, List[int])) + iq = to(ip, sample_to_int, Return=(InversePresentation, list[int])) assert iq.alphabet() == [15, 2, 4] assert iq.inverses() == [4, 2, 15] assert iq.rules == [[15, 15, 15], [2], [2, 15, 4], [4, 15, 2]] @@ -693,7 +680,7 @@ def test_to_InversePresentation_031(): assert iu.inverses() == "nml" assert iu.rules == ["lll", "m", "mln", "nlm"] - iv = to(iq, lambda x: x + 11, Return=(InversePresentation, List[int])) + iv = to(iq, lambda x: x + 11, Return=(InversePresentation, list[int])) assert iv.alphabet() == [26, 13, 15] assert iv.inverses() == [15, 13, 26] assert iv.rules == [[26, 26, 26], [13], [13, 26, 15], [15, 26, 13]] @@ -711,21 +698,19 @@ def test_to_InversePresentation_032(): assert ip.inverses() == "defabc" assert ip.rules == p.rules - q = to(p, Return=(Presentation, List[int])) + q = to(p, Return=(Presentation, list[int])) iq = to(q, Return=(InversePresentation,)) assert iq.alphabet() == [0, 1, 2, 3, 4, 5] assert iq.inverses() == [3, 4, 5, 0, 1, 2] assert iq.rules == q.rules - assert to( - to(p, Return=(Presentation, List[int])), Return=(InversePresentation,) - ) == to( - to(p, Return=(InversePresentation,)), Return=(Presentation, List[int]) + assert to(to(p, Return=(Presentation, list[int])), Return=(InversePresentation,)) == to( + to(p, Return=(InversePresentation,)), Return=(Presentation, list[int]) ) - assert to( - to(q, Return=(Presentation, str)), Return=(InversePresentation,) - ) == to(to(q, Return=(InversePresentation,)), Return=(Presentation, str)) + assert to(to(q, Return=(Presentation, str)), Return=(InversePresentation,)) == to( + to(q, Return=(InversePresentation,)), Return=(Presentation, str) + ) ############################################################################### @@ -747,12 +732,12 @@ def test_to_KnuthBendix_034(): def test_to_KnuthBendix_035(): - kb = check_froidure_pin_to_knuth_bendix(List[int], "RewriteFromLeft") + kb = check_froidure_pin_to_knuth_bendix(list[int], "RewriteFromLeft") assert isinstance(kb, KnuthBendix) def test_to_KnuthBendix_036(): - kb = check_froidure_pin_to_knuth_bendix(List[int], "RewriteTrie") + kb = check_froidure_pin_to_knuth_bendix(list[int], "RewriteTrie") assert isinstance(kb, KnuthBendix) @@ -770,12 +755,12 @@ def test_to_KnuthBendix_038(): def test_to_KnuthBendix_039(): - kb = check_todd_coxeter_to_knuth_bendix(List[int], "RewriteFromLeft") + kb = check_todd_coxeter_to_knuth_bendix(list[int], "RewriteFromLeft") assert isinstance(kb, KnuthBendix) def test_to_KnuthBendix_040(): - kb = check_todd_coxeter_to_knuth_bendix(List[int], "RewriteTrie") + kb = check_todd_coxeter_to_knuth_bendix(list[int], "RewriteTrie") assert isinstance(kb, KnuthBendix) @@ -789,7 +774,7 @@ def test_to_KnuthBendix_041(): def test_to_KnuthBendix_042(): - kb = check_todd_coxeter_to_knuth_bendix_default(List[int]) + kb = check_todd_coxeter_to_knuth_bendix_default(list[int]) # RewriteTrie is the default rewriter assert isinstance(kb, KnuthBendix) @@ -808,9 +793,9 @@ def test_to_Congruence_043(): def test_to_Congruence_044(): - c = check_froidure_pin_to_congruence(List[int]) + c = check_froidure_pin_to_congruence(list[int]) assert isinstance(c, Congruence) - assert c.py_template_params == (List[int],) + assert c.py_template_params == (list[int],) ############################################################################### From 3a8a1beaa8498eacc576bb74a542f75817da807a Mon Sep 17 00:00:00 2001 From: James Mitchell Date: Tue, 3 Jun 2025 13:16:15 +0100 Subject: [PATCH 2/4] Replace Tuple -> tuple --- src/froidure-pin-base.cpp | 8 ++++---- src/knuth-bendix-impl.cpp | 4 ++-- src/knuth-bendix.cpp | 6 +++--- src/todd-coxeter.cpp | 6 +++--- src/ukkonen.cpp | 4 ++-- src/word-graph.cpp | 6 +++--- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/froidure-pin-base.cpp b/src/froidure-pin-base.cpp index 569645a49..a30498646 100644 --- a/src/froidure-pin-base.cpp +++ b/src/froidure-pin-base.cpp @@ -648,7 +648,7 @@ complete set of rules, then use :any:`normal_forms` instead. fp.cend_current_rules()); }, R"pbdoc( -:sig=(fp: FroidurePin) -> Iterator[Tuple[list[int],list[int]]]: +:sig=(fp: FroidurePin) -> Iterator[tuple[list[int],list[int]]]: Returns an iterator yielding the so-far enumerated rules. @@ -664,7 +664,7 @@ to obtain the complete set of rules, then use :any:`rules` instead. :returns: An iterator. -:rtype: Iterator[Tuple[list[int], list[int]]] +:rtype: Iterator[tuple[list[int], list[int]]] :complexity: Constant @@ -740,7 +740,7 @@ then use :any:`current_normal_forms` instead. return py::make_iterator(fp.cbegin_rules(), fp.cend_rules()); }, R"pbdoc( -:sig=(fp: FroidurePin) -> Iterator[Tuple[list[int],list[int]]]: +:sig=(fp: FroidurePin) -> Iterator[tuple[list[int],list[int]]]: Returns an iterator yielding the rules. @@ -758,7 +758,7 @@ use :any:`current_rules` instead. :returns: An iterator yielding rules. :rtype: - Iterator[Tuple[list[int],list[int]]]: + Iterator[tuple[list[int],list[int]]]: )pbdoc"); } } // init_froidure_pin_base diff --git a/src/knuth-bendix-impl.cpp b/src/knuth-bendix-impl.cpp index 859520745..179e8595b 100644 --- a/src/knuth-bendix-impl.cpp +++ b/src/knuth-bendix-impl.cpp @@ -376,7 +376,7 @@ to the re-initialisation of rules where possible. return py::make_iterator(rx::begin(rules), rx::end(rules)); }, R"pbdoc( -:sig=(self: KnuthBendix) -> Iterator[Tuple[str, str]]: +:sig=(self: KnuthBendix) -> Iterator[tuple[str, str]]: Return a copy of the active rules. @@ -388,7 +388,7 @@ according to the reduction ordering used by the rewriting system, on the first entry. :return: An iterator yielding the currently active rules. -:rtype: Iterator[Tuple[str, str]] +:rtype: Iterator[tuple[str, str]] )pbdoc"); ////////////////////////////////////////////////////////////////////////// diff --git a/src/knuth-bendix.cpp b/src/knuth-bendix.cpp index a8dfca4b7..a5f453579 100644 --- a/src/knuth-bendix.cpp +++ b/src/knuth-bendix.cpp @@ -287,7 +287,7 @@ Check if the all rules are reduced with respect to each other. return {}; }, R"pbdoc( -:sig=(p: Presentation, t: datetime.timedelta) -> Tuple[list[int], list[int]] | Tuple[str, str] | None: +:sig=(p: Presentation, t: datetime.timedelta) -> tuple[list[int], list[int]] | tuple[str, str] | None: :only-document-once: Return a redundant rule or ``None``. @@ -308,7 +308,7 @@ redundant in this way, then ``None`` is returned. :type t: datetime.timedelta :returns: A redundant rule or ``None``. -:rtype: Tuple[list[int], list[int]] | Tuple[str, str] | None +:rtype: tuple[list[int], list[int]] | tuple[str, str] | None .. warning:: The progress of the Knuth-Bendix algorithm may differ between @@ -342,7 +342,7 @@ redundant in this way, then ``None`` is returned. return {}; }, R"pbdoc( -:sig=(p: Presentation, t: datetime.timedelta) -> Tuple[list[int], list[int]] | Tuple[str, str] | None: +:sig=(p: Presentation, t: datetime.timedelta) -> tuple[list[int], list[int]] | tuple[str, str] | None: :only-document-once: TODO where's the doc? )pbdoc"); diff --git a/src/todd-coxeter.cpp b/src/todd-coxeter.cpp index 9f36d2de8..f50e3a0ec 100644 --- a/src/todd-coxeter.cpp +++ b/src/todd-coxeter.cpp @@ -406,7 +406,7 @@ enumeration of ``tc``.)pbdoc", py::arg("p"), py::arg("t"), R"pbdoc( -:sig=(p: Presentation, t: timedelta) -> Tuple[list[int], list[int]] | Tuple[str, str] | None: +:sig=(p: Presentation, t: timedelta) -> tuple[list[int], list[int]] | tuple[str, str] | None: :only-document-once: Return a redundant rule or ``None``. @@ -426,7 +426,7 @@ be shown to be redundant in this way, then ``None`` is returned. :type t: timedelta :returns: A redundant rule or ``None``. -:rtype: Tuple[list[int], list[int]] | Tuple[str, str] | None +:rtype: tuple[list[int], list[int]] | tuple[str, str] | None )pbdoc"); m.def( @@ -440,7 +440,7 @@ be shown to be redundant in this way, then ``None`` is returned. return {}; }, R"pbdoc( -:sig=(p: Presentation, t: timedelta) -> Tuple[list[int], list[int]] | Tuple[str, str] | None: +:sig=(p: Presentation, t: timedelta) -> tuple[list[int], list[int]] | tuple[str, str] | None: :only-document-once: )pbdoc"); diff --git a/src/ukkonen.cpp b/src/ukkonen.cpp index 38785b6a1..ae90e88bd 100644 --- a/src/ukkonen.cpp +++ b/src/ukkonen.cpp @@ -455,7 +455,7 @@ overlapping) of the words in the suffix tree *u*. py::arg("u"), py::arg("w"), R"pbdoc( -:sig=(u: Ukkonen, w: str | list[int]) -> Tuple[Ukkonen.State, str | list[int]]: +:sig=(u: Ukkonen, w: str | list[int]) -> tuple[Ukkonen.State, str | list[int]]: :only-document-once: Traverse the suffix tree from the root. @@ -471,7 +471,7 @@ traversal is returned. :type w: str | list[int] :returns: A tuple containing the :any:`State` reached, and the word consumed. -:rtype: Tuple[Ukkonen.State, str | list[int]] +:rtype: tuple[Ukkonen.State, str | list[int]] :raises LibsemigroupsError: if ``u.throw_if_contains_unique_letter(w)`` throws. diff --git a/src/word-graph.cpp b/src/word-graph.cpp index 5f5f3f6c3..b201d8927 100644 --- a/src/word-graph.cpp +++ b/src/word-graph.cpp @@ -370,7 +370,7 @@ equal to *a* that is incident to the node *s*. If ``target(s, b)`` equals :returns: Returns a pair where the first entry is the next label after *a* and the second is the next target of *s* that is not :any:`UNDEFINED`. -:rtype: Tuple[int | Undefined, int | Undefined] +:rtype: tuple[int | Undefined, int | Undefined] :complexity: At worst :math:`O(n)` where :math:`n` equals :any:`out_degree()`. @@ -1128,7 +1128,7 @@ position in the word reached. :returns: A pair consisting of the last node reached and the index of the last letter in the word labelling an edge. -:rtype: Tuple[int, int] +:rtype: tuple[int, int] :complexity: At worst the length of *w*.)pbdoc"); @@ -1327,7 +1327,7 @@ spanning tree corresponds to the order *val*. this function (i.e. it was not standardized already), and ``False`` otherwise. The second entry is a :any:`Forest` object containing a spanning tree for *wg*. -:rtype: Tuple[bool, Forest] +:rtype: tuple[bool, Forest] )pbdoc"); m.def( From 4cd7749cba3c1112082c18512a4c111c5579f338 Mon Sep 17 00:00:00 2001 From: James Mitchell Date: Tue, 3 Jun 2025 13:17:32 +0100 Subject: [PATCH 3/4] Replace Dict -> dict --- src/dot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dot.cpp b/src/dot.cpp index dda2a0bd1..0b28374c7 100644 --- a/src/dot.cpp +++ b/src/dot.cpp @@ -179,7 +179,7 @@ represented graph. :returns: A dictionary. :rtype: - Dict[str, str] + dict[str, str] )pbdoc"); dot.def( "is_node", From 757dc33526a4246c3bcb422910ebe494b605833b Mon Sep 17 00:00:00 2001 From: James Mitchell Date: Tue, 3 Jun 2025 13:18:32 +0100 Subject: [PATCH 4/4] Replace Set -> set --- src/word-graph.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/word-graph.cpp b/src/word-graph.cpp index b201d8927..eb2d56910 100644 --- a/src/word-graph.cpp +++ b/src/word-graph.cpp @@ -1154,7 +1154,7 @@ This function returns a set consisting of all the nodes in the word graph :returns: A set consisting of all the nodes in the word graph *wg* that are reachable from *source*. -:rtype: Set[int] +:rtype: set[int] :raises LibsemigroupsError: if *source* is out of bounds (greater than or equal to